If you’re using GraphQL with Ruby on Rails, you can use generators to:
You can add GraphQL to a Rails app with graphql:install:
rails generate graphql:install
This will:
app/graphql/Query type definitionMutation type definition with a base mutation classgraphiql-railsAfter installing you can see your new schema by:
bundle installrails serverlocalhost:3000/graphiql--relay will add Relay-specific code to your schema--batch will add GraphQL::Batch to your gemfile and include the setup in your schema--no-graphiql will exclude graphiql-rails from the setup--schema=MySchemaName will be used for naming the schema (default is #{app_name}Schema)Several generators will add GraphQL types to your project. Run them with -h to see the options:
rails g graphql:objectrails g graphql:interfacerails g graphql:unionrails g graphql:enumrails g graphql:scalarYou can prepare a Relay Classic mutation with
rails g graphql:mutation #{mutation_name}
You can prepare a GraphQL::Batch loader with
rails g graphql:loader