GraphQL - Welcome

GraphQL Ruby Logo

GraphQL Ruby

Define Your Schema

Describe your application with a 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
end

Serve Queries

Provide custom data to clients and extend your API with mutations, subscriptions, streaming responses, and multiplexing.

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