-
Notifications
You must be signed in to change notification settings - Fork 42
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
None's are converted to null, which Postgres doesn't like #26
Comments
Demo project here, with both sides of the interaction: https://github.com/ecliptic/reason-events |
Hello! What would be the correct behavior for graphql_ppx here? To me, the problem seems to be the fact that the fields aren't really optional if you can't set them to |
@mhallin It's the |
I misspoke above - passing |
Hmm, I see. So how would you say "use the default value for this column" - would you just omit the argument from the object? Conceptually, omitting an argument optional argument and passing an explicit I don't think this can be resolved from graphql_ppx's standpoint unfortunately. The |
Okay, this definitely makes sense. I can probably write a quick Looking through some bug reports elsewhere, it's also possible that this is related to my usage of |
No luck, sadly. Classic integer-based serial id's suffer from the same issue. I'll close this ticket and pursue as a server plugin. Thanks! |
@mhallin I got some context from the
It sounds like we need to use something other than What do you think? |
While I see the issue in this case, it appears to be more of a weakness in the ReasonML spec, since it does not allow for the concept of absent. For your case, why does CreateEventInput have an ID field in the first place? It looks like it will always be auto-generated. |
@Neitsch that's not right.
|
My mistake, thank you for the correction!! |
Alright, so one workaround right now would be to break up the input object in the query, like mutation ($name: String!) {
createEvent(input: { event: { name: $name } }) {
# ...
}
} There will be a lot of variables unfortunately, but it should work right now. As for the larger point, it seems the GraphQL spec has been amended with a distinction of null and absent values. Is this only for input object fields or for all arguments? If it's only for input object fields we could probably use doubly-nested optionals like @wokalski said, but I can't really discern this from the specification. |
@mhallin why is it impossible to implement for all arguments? |
@mhallin After some back and forth, I think your idea of breaking up the input object in the query makes the most sense and is actually the most eloquent. The parameters declared in the first line of the query is the one responsible for defining the shape of the variables, rather than the input object. This gives fine-grain control and definition to our intensions, and though it may lead to more typing I think it's for the better and likely to cause less confusion than double-nesting optionals. |
I've ported #64 into baransu/graphql_ppx_re. If you need such functionality you can try the latest version :) |
I'm using postgraphile on the backend to speed up data development.
I'm creating a new object, and the type in the module generated from the
%graphql
expression results inoption(Js.Json.t)
for myid
. I passNone
for theid
, and it's sent across in the graphql request in the variables as"id": null
.Postgraphile sees that
"id": null
and tries to set theid
field in the database tonull
, which Postgres understandably complains about:null value in column "id" violates not-null constraint
Here's my module:
And the resulting signature of the
make
function's arguments:If I pass
None
for any of those optional values, they're sent across to the server asnull
. The server thinks I'm intentionally nullifying those fields. How can I work around?Thanks for a great project!
The text was updated successfully, but these errors were encountered: