GraphQL Ruby Logo

GraphQL Ruby

Install the Gem

# Download the gem:
bundle add graphql
# Setup with Rails:
rails generate graphql:install

Get going fast with the graphql gem, battle-tested and trusted by GitHub, Shopify, Flexport, Chime, and Kickstarter.

Define Your Schema

Describe your application with the GraphQL schema to create a self-documenting, strongly-typed API.

# 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

Run Queries

# app/controllers/graphql_controller.rb
result = MySchema.execute(
  variables: params[:variables],
  context: { current_user: current_user },
render json: result

Serve queries to build a great UI or webservice.

Add GraphQL to your Ruby app. Get Started!