-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
null value in column "id" violates not-null constraint #189
Comments
If you want to use the defaults simply don't specify that you want the column value to be null - if you specify null then we take you at your word. This is the same behaviour as SQL. e.g. mutation CreateEvent($name: String!, date: Date!) {
createEvent(input: {event: {name: $name, date: $date}}) {
...
}
} |
@benjie According to @leebyron in this thread:
It sounds like your understanding of this is different? How can I work around this issue when interacting with Further detail from that thread:
|
From the results of the discussion I linked above, It sounds like |
A To the best of my knowledge PostGraphile's behaviour is correct in this regard. Besides changing the behaviour would be a breaking change and it would violate the Principle of Least Astonishment given it maps a PostgreSQL database which works in the same way (omit the value to use the default, specify I can totally relate to your issue though! I believe the issue is that your mapper is dealing with the input value as if it were a concrete type with fixed keys and values. Really it's a dictionary with a whitelist of keys and types those keys can be, but where every non-nullable key is optional (the entries in the dictionary itself are optional - not just the values). I hope you can find an acceptable solution - if you do I'd really appreciate it if you could share it here. Good luck! |
Thank you so much for the detail! This is very helpful. I'll go back to the author of |
Just to follow up - it’s correct that graphql should interpret an explicit null differently from an implicit missing value. That thread linked above walks through the decision making process from a couple years ago. We actually amended the spec to account for this as a result. |
[semi-automated message] To keep things manageable I'm going to close this issue as I think it's solved; but if not or you require further help please re-open it. |
Related to this issue discussed on the
graphql_ppx
project: mhallin/graphql_ppx#26For fields with default values,
NULL
is sent across rather thanDEFAULT
or omitting the values. From the postgres log:I wrote this tiny plugin to fix the issue in a very manual way:
Is there a way to solve this for all fields with default values, though?
Thanks for maintaining/expanding such an outstanding project!
The text was updated successfully, but these errors were encountered: