-
Notifications
You must be signed in to change notification settings - Fork 46
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
Allowing graphiql to use an access token #202
Comments
Hey @benkovy! Thank you for opening this and sorry we've taken so long to reply. I will take a look at this soon 👍 |
Hello again, @benkovy! Sorry we took so long to reply. Thank you for looking into this a coming up with a solution 🚀
That's a real concern, it would be risky for anyone to start using this gem if it pulls code from anywhere, even if most of the time it would be setup only for dev envs. Also, I don't think we are going to include something in this gem related to views. We are trying to keep the API only as much as possible. So I can't think of a complete solution right now, that is similar to what you have proposed. Now, this might not be ideal, but I can think of something you can do and I have done in the past.
I hope that helps! I'm going to close this issue as I don't see a way to incorporate something like this in the gem. But as usual, feel free to keep discussing alternatives in this issue as it might help someone else. Just careful with security 😉 |
During development the graphiql interface is a huge bonus. But it becomes difficult when you have resources that require authentication.
If you have devise configured to change access tokens on every request this can be even more difficult.
I have a hacky solution that I am using and thought I might share it here.
graphiql-rails
gem from my Gemfile.views/graphql/graphiql.html.erb
(see bottom of issue for the example file)This uses a CDN to pull down react, react-dom and graphiql and defines a custom fetcher that populates the headers that devise looks for when sending a request to a protected resource. It also populates the graphiql interface with a default login mutation (you can add your test account credentials in the snippet below). So all that is needed to get started, is to run the login mutation.
Now I guess there are security concerns if those CDN's ever change or are compromised but this is only ever used locally...
graphiql.html.erb
inspiration: rmosolgo/graphiql-rails#85 (comment)
The text was updated successfully, but these errors were encountered: