GraphQL Ruby Logo

GraphQL Ruby

Install the Gem

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

Get going fast with the graphql gem, battle-tested and trusted by GitHub, Shopify 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, null: true
end

Run Queries

# app/controllers/graphql_controller.rb
result = MySchema.execute(
  params[:query],
  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!