[Awesome Ruby Gem - Graphiti] Use graphiti_graphql to support GraphQL for Graphiti
graphiti_graphql
GraphQL (and Apollo Federation) support for Graphiti. Serve traditional Rails JSON, JSON:API or GraphQL with the same codebase.
Graphiti makes RESTful Resources a first-class concept. This enables reading and writing a graph of data in a single request, a schema with backwards-compatible guarantee, end-to-end integration test patterns, seamless microservices and much more.
Installation
You can install it as a gem:
1 | gem install graphiti_graphql |
or add it into a Gemfile (Bundler):
1 | # Gemfile |
Then, run bundle install
.
1 | bundle install |
Usages
Routes
Mount the engine:
1 | # config/routes.rb |
For a default Graphiti app, you can now serve GraphQL by POSTing to /api/v1/gql
.
That’s it 🎉!
FAQs
undefined method `to_prepare’ for nil:NilClass (NoMethodError)
1 | rails s |
Check graphiti_graphql-0.1.14/lib/graphiti_graphql/engine.rb
file.
1 | # graphiti_graphql-0.1.14/lib/graphiti_graphql/engine.rb |
Local version dependency:
1 | ruby -v |
TODO
References
[2] graphiti_graphql | RubyGems.org | Ruby 社区 Gem 托管 - https://rubygems.org/gems/graphiti_graphql
[3] Stylish Graph APIs | Guides - https://www.graphiti.dev/guides/
[4] graphiti-api/graphiti: Stylish Graph APIs - https://github.com/graphiti-api/graphiti