-
Notifications
You must be signed in to change notification settings - Fork 824
Turning Non-null to is_null #1505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'd do the PR myself, but I wonder to see if that's something maintainers agree with me or not. |
Graphql has a weird relationship with nullable field. type Mutation {
doNothing(input: DoNothingInput!): DoNothingPayload
}
type DoNothingPayload {
nullableInt: Int
}
input DoNothingInput {
nullableInt: Int
} that can be obtained with: nullable_int = graphene.Int(required=False) serves both purposes of being nullable and being optional. Indeed you can do the following 3 behavior:
mutation {
doNothing(input: { nullableInt: 1 }) {
nullableInt
}
} and in your resolver
mutation {
doNothing(input: { nullableInt: null }) {
nullableInt
}
} and in your resolver
mutation {
doNothing(input: { }) {
nullableInt
}
} and in your resolver So if you want to have a required nullable input, your only way to do it is to make the type assert "nullable_int" in input There is no way as far as I know to enforce that at schema level... |
Note that this issue is an open conversation in the grapqh specs: graphql/graphql-spec#476 |
Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.
Hey :)
so I was reading docs, and then I remembered something:
simple is better than complex.
Why would we create a new class and object type because we don't want nullable values? isn't accepting a nullable value a property? then maybe we could have used is_null=True/False, and it gives us more control, because now we can have 4 possibility:
What is the current behavior?
Using a new class/object, to adopt a behaviour that can be achieved as property
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
a github repo, https://repl.it or similar.
What is the expected behavior?
Having is_null, beside required.
What is the motivation / use case for changing the behavior?
This gives us more flexible, and less complex scalars.
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
The text was updated successfully, but these errors were encountered: