Skip to content

Allow detecting null #56

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

Closed
davidgilbertson opened this issue Mar 28, 2021 · 3 comments
Closed

Allow detecting null #56

davidgilbertson opened this issue Mar 28, 2021 · 3 comments
Labels
question Further information is requested

Comments

@davidgilbertson
Copy link

I would like to able to assert that a field on an input is optional, but not nullable (so I can do a partial update of an entity). GraphQL has no such syntax so I was hoping I could use this dirctive for that.

Something like:

input UpdateUser {
  id: ID!
  username: String @contraint(notNull: true)
  password: String @contraint(notNull: true)
}

Is this possible?

@confuser
Copy link
Owner

Not possible with GraphQL itself (graphql/graphql-spec#476) but might be possible to support via a directive. However, I'm not sure it fits in with this library; happy to be challenged though.

@confuser confuser added the question Further information is requested label Mar 28, 2021
@confuser confuser closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2022
@robross0606
Copy link

I personally think this definitely fits into the goals of this library. The problem space here is an old one. If you're providing inputs (type fields, not mutation parameters) that are optional, you need to be able to say "if provided, this field cannot be null." GraphQL does not currently distinguish between "required" and "non-nullable". That sure feels like an input constraint to me.

@JannikWempe
Copy link

If you're providing inputs (type fields, not mutation parameters) that are optional, you need to be able to say "if provided, this field cannot be null."

This is a very common use case for partial updates that include fields that should not be set to explicit null. Leaving field out of partial update is fine though and leaves the field untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants