guides/index.html
--- title: Welcome fullwidth: false ---
The graphql gem implements the GraphQL Server Specification in Ruby.
Use it to add a GraphQL API to your Ruby or Rails app.
Get going fast with the graphql gem, battle-tested and trusted by GitHub, Shopify, Flexport, Chime, and Kickstarter.
{% highlight bash %} # Download the gem: bundle add graphql # Setup with Rails: rails generate graphql:install {% endhighlight %}
Describe your application with a GraphQL schema to create a self-documenting, strongly-typed API.
{% highlight ruby %} # app/graphql/types/profile_type.rb class Types::ProfileType < Types::BaseObject field :id, ID, null: false field :name, String, null: false field :avatar, Types::PhotoType end {% endhighlight %}
Provide custom data to clients and extend your API with {% internal_link "mutations", "/mutations/mutation_root" %}, {% internal_link "subscriptions", "/subscriptions/overview" %}, {% internal_link "streaming responses", "/defer/overview" %}, and {% internal_link "multiplexing", "/queries/multiplex" %}.
{% highlight ruby %} # app/controllers/graphql_controller.rb result = MySchema.execute( params[:query], variables: params[:variables], context: { current_user: current_user }, ) render json: result {% endhighlight %}
Confidently deploy GraphQL with GraphQL-Ruby:
{% internal_link "graphql-ruby-client", "/javascript_client/overview" %} provides integration with {% internal_link "Apollo Client", "/javascript_client/apollo_subscriptions" %}, {% internal_link "Relay", "/javascript_client/relay_subscriptions" %}, {% internal_link "GraphiQL", "/javascript_client/graphiql_subscriptions" %}, {% internal_link "urql", "/javascript_client/urql_subscriptions" %}, or custom JavaScript.
Customize your GraphQL API: