Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix mutation optional variables - #64

#64
Open
baransu wants to merge 2 commits into
mhallin:mastermhallin/graphql_ppx:masterfrom
baransu:optional-argumentsbaransu/graphql_ppx:optional-argumentsCopy head branch name to clipboard
Open

Fix mutation optional variables#64
baransu wants to merge 2 commits into
mhallin:mastermhallin/graphql_ppx:masterfrom
baransu:optional-argumentsbaransu/graphql_ppx:optional-argumentsCopy head branch name to clipboard

Conversation

@baransu

@baransu baransu commented Dec 9, 2018

Copy link
Copy Markdown
Contributor

It turns out there is a way to filter out null values before generating variables JSON without breaking the API. Implementation allows to None to Js.Json.null which is not compatible with GraphQL spec but later we filter that values out before creating Js.Json.object_. It doesn't force usage of Js.Nullable nor option(option(t)) so it's not API breaking change. The whole implementation is done in BuckleScript related code and I'm not sure if those changes should be applied to the native part as well.

Should fix: #26 and #59

@baransu

baransu commented Jan 6, 2019

Copy link
Copy Markdown
Contributor Author

@mhallin How can I push it forward?

@mhallin

mhallin commented Jan 17, 2019

Copy link
Copy Markdown
Owner

Thanks for this.

It looks like it basically flips the default of converting None into null to undefined instead. Is this correct?

@baransu

baransu commented Jan 17, 2019

Copy link
Copy Markdown
Contributor Author

Yes.
Since there is no Js.Json.undefined we have to filter null out and it's easier to do after encoding into Js.Json.t.

@mhallin

mhallin commented Jan 24, 2019

Copy link
Copy Markdown
Owner

I'm a bit weary about this since it changes behaviour in a way that might break clients, so it might be better to just bite the bullet and introduce either option(option(t)) or Js.Null_undefined.t instead.

@baransu

baransu commented Jan 25, 2019

Copy link
Copy Markdown
Contributor Author

But with that change we’ll have correct behaviour matching the BuckleScript implementation (None is undefined) and GraphQL nullable in arguments is undefined not null, without need for API change. Since we’re not 1.x I think we should think about it as breaking change and make major release (so since we’re 0.x a minor change).

Maybe it’s good idea to talk about it on Discord and gather feedback from the users and also ask in reason-apollo because a lot of peoples comes from there.

/cc @Gregoirevda

@MoOx

MoOx commented Mar 27, 2019

Copy link
Copy Markdown

In short, would this PR avoid to have graphql server yelling if we send None value in a mutation when undefined is supposed to be accepted?

@baransu

baransu commented Apr 3, 2019

Copy link
Copy Markdown
Contributor Author

@MoOx In JSON there is not undefined AFAIK. Right now we send null which isn't correct because null should be omitted in variables instead of being sent as null. This PR removes the variables if they are None

@MoOx

MoOx commented Apr 5, 2019

Copy link
Copy Markdown

@baransu Yeah sorry, forgot that undefined isn't a thing in JSON. This PR does what I need: omit None values.
Would love to see that released.
@mhallin Can we do something about CI? error (ERROR while compiling dune.1.6.2) here seems unrelated to the PR.

@baransu

baransu commented Oct 5, 2019

Copy link
Copy Markdown
Contributor Author

@MoOx I've ported this fix into baransu/graphql_ppx_re if you need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

None's are converted to null, which Postgres doesn't like

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.