Skip to content

Guide: Use with GraphiQL #5253

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
maxrosecollins opened this issue Feb 24, 2025 · 5 comments · Fixed by rmosolgo/graphiql-rails#125
Closed

Guide: Use with GraphiQL #5253

maxrosecollins opened this issue Feb 24, 2025 · 5 comments · Fixed by rmosolgo/graphiql-rails#125

Comments

@maxrosecollins
Copy link

If I try to user @defer with graphiql then I get an error

No number after minus sign in JSON at position 3 (line 2 column 2)

This is I guess because the response is changed to a multipart, how can I fix this issue?

When will it be updated? https://graphql-ruby.org/defer/graphiql.html

At the bottom of this page you mention supporting it out of the box once a issue is resolved and as far as I can tell the issue has been resolved? graphql/graphiql#3470

@rmosolgo
Copy link
Owner

Hey! I'd be happy to help get these things working together. Could you share a little background info?

  • What was the response from your GraphQL server? (You can get the full response from the network tab of your browser's devtools)
  • How are you running GraphiQL? Is it GraphiQL-Rails or another setup? What version of GraphiQL is running?

Let me know what you find and we'll go from there 👍

@maxrosecollins
Copy link
Author

Hello

---
Content-Type: application/json
Content-Length: 82

{"hasNext":true,"data":{"domain":{"uuid":"d839e508-2869-467d-b552-7790d452fec0"}}}
---
Content-Type: application/json
Content-Length: 89

{"incremental":[{"path":["domain","host"],"data":"www.ranktracker.com"}],"hasNext":false}
-----

I am using the gem gem 'graphiql-rails' and from my lockfile graphiql-rails (1.10.1)

Thanks for your help

@rmosolgo
Copy link
Owner

Thanks for sharing that, @maxrosecollins. It all looks right to me. I spent some time investigating how the new support from GraphiQL can work with GraphiQL-Rails, and I realized that it doesn't work out-of-the-box because GraphiQL-Rails doesn't use GraphiQL's createGraphiQLFetcher function. Instead, it creates its own fetch function here:

https://github.com/rmosolgo/graphiql-rails/blob/9995e163f8c0994d28847bf4e8405c60afa73e1e/app/assets/javascripts/graphiql/rails/graphiql_show.js#L4-L5

I'll take a look later today at improving GraphiQL-Rails to support multipart responses out of the box.

In the meantime, you could work around this issue by installing GraphiQL directly into your app, without graphiql-rails. For example, you can see here:

Then, you could create a fetcher using const fetcher = createGraphiQLFetcher({ url: "/your/graphql", enableIncrementalDelivery: true })

@maxrosecollins
Copy link
Author

Hello,

Do I still need to follow this work around with your new merged PR?

@rmosolgo
Copy link
Owner

I expect not -- just update your bundle to 1.10.4, mount GraphiQL::Rails::Engine in your routes.rb, then open GraphIQL, and I expect @defer will work normally!

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 a pull request may close this issue.

2 participants