
So we've been using GraphQL with Rails (via graphql-ruby) for quite some time now and thought it would be nice to share our approach.
The two key topics we had to solve when we did our implementation was (1) authorization with query scoping (Pundit) and (2) automatically generating resources and filters (because it gets quite manual otherwise)
We've shared our approach in the blog article below:
https://www.keypup.io/blog/graphql-the-rails-way-part-1-exposing-your-resources-for-querying
The principle is to use introspection and customer resolvers to automatically infer (Pundit) policy classes as well as generate filters based on exposed attributes (GraphQL types) and model columns.
This reduces the amount of code required to exposes resources to almost a one-liner (modulo type definition).
If you have a different approach on implementing GraphQL for Rails, I would be keen to hear about it!
This is actually a rarely
goodgreat RoR article on IH. Keep it up with GraphQL + RoR!Thanks mate. There shall be more parts!
The next one is actually going to be about mutations. It's coming soon ;)
Just letting you know that episode 2 is now available :)
https://www.indiehackers.com/post/graphql-with-rails-part-2-writing-custom-and-standard-mutations-9becaf0077
Thanks for sharing.