Altair + Rails ♥️ #2235
jejacks0n
started this conversation in
Show and tell
Replies: 1 comment
-
That's awesome to hear! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm the author of a Ruby gem that I wanted to notify the authors of Altair about. The
altair-rails
gem works really nicely with a standard Rails + GraphQL Ruby + ActionCable setup.So initially I was using the
graphiql-rails
gem, which utilizes GraphiQL, because that's what kinda comes bundled as a suggestion with thegraphql-ruby
gem (which is great by the way). Anyway, I couldn't get subscriptions working because there's no support for ActionCable in GraphiQL.On top of this, I chose some unique authentication strategies because I'm using Devise. Devise is an authentication system (Rails engine) that provides a lot of user sign in / registration / recovery functionality. One of the things that that setup has, is a secure cookie (the same one that's used for "remember me") that's set after authenticating. That secure cookie can then be used (very cleanly) within the ActionCable connections for authentication there as well.
I found it really difficult to get any GraphQL clients to nicely handle this signed cookie approach, for totally valid reasons, and I didn't want to add a token authentication system on top of everything that already works cleanly and elegantly, so what I decided would be the most flexible and comprehensive long term solution would be to simply serve the static Altair (CDN) build from within the server -- so it would have access to sessions, cookies, and other useful details like that.
There's a minor CORS issue that comes up in regards to web Workers since the assets are being loaded from the CDN, but it can be resolved by allowing the domain in the application CORS policy (for development environments).
Anyway, thanks so much for such a great library in Altair. It's been a pleasure to work with, and hopefully this will help others who run into similar challenges in the future -- or might serve as an example of how to make a Rack application that does a similar thing.
Beta Was this translation helpful? Give feedback.
All reactions