Skip to content
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

Updated script to generate fragmentTypes.json #3645

Merged
merged 4 commits into from
Jul 30, 2018
Merged

Updated script to generate fragmentTypes.json #3645

merged 4 commits into from
Jul 30, 2018

Conversation

ardouglass
Copy link
Contributor

This didn't work as it was for us due to some error about not having an operation named {}, but adding variables: null, operationName: null, to the body of the fetch call solved the problem.

Checklist:

  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • If this was a change that affects the external API used in GitHunt-React, update GitHunt-React and post a link to the PR in the discussion.

This didn't work as it was for us due to some error about not having an operation named `{}`, but adding `variables: null, operationName: null,` to the body of the fetch call solved the problem.
@ghost ghost added the 📝 documentation label Jul 3, 2018
@hwillson
Copy link
Member

Thanks for submitting this PR @ardouglass. I'm curious - what GraphQL backend are you using? For example, in Apollo Server 2 variables and operationName should be optional when POSTing in a non-named query. That's why the docs don't include them. If you're seeing otherwise though, that would be great to know. If you have it handy, could you also paste in the exact error message you were seeing? Thanks!

@hwillson hwillson self-assigned this Jul 17, 2018
@ardouglass
Copy link
Contributor Author

@hwillson we're using the Ruby gem graphql 1.7.7.

@hwillson
Copy link
Member

Interesting - so the graphql-ruby gem is expecting an operationName and variables, which explains this issue.

https://github.com/rmosolgo/graphql-ruby/blob/62da40136d66b99e8b65b252601ab8028fe27c56/lib/graphql/query.rb#L334-L347

Here's what Apollo link is doing to work around this with different backends:

https://github.com/apollographql/apollo-link/blob/e1d0ed28efd3eb78e3576e036bbe2c25528e817e/packages/apollo-link/src/linkUtils.ts#L76-L90

So it's using the following defaults:

...
variables: {},
operationName: '',
...

I'll align the code sample to match the defaults Apollo Link is using, which should still fix the issue you were seeing with graphql-ruby. Thanks!

These changes align the defaults up with what Apollo Link is doing.
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @ardouglass!

@hwillson hwillson merged commit c96c5b1 into apollographql:master Jul 30, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants