📣 GraphQLConf 2025 • Sept 08-10 • Amsterdam • Early bird tickets available & sponsorship opportunities open • Learn more

Code Using GraphQL

Sort by:
graphql-ruby
A Ruby library for building GraphQL APIs.
Last release 3 years ago5kMIT License
README

To run a hello world script with graphql-ruby:

gem install graphql

Then run ruby hello.rb with this code in hello.rb:

require 'graphql'
 
class QueryType < GraphQL::Schema::Object
  field :hello, String
 
  def hello
    "Hello world!"
  end
end
 
class Schema < GraphQL::Schema
  query QueryType
end
 
puts Schema.execute('{ hello }').to_json

There are also nice bindings for Relay and Rails.

Agoo
A high performance web server with support for GraphQL. Agoo strives for a simple, easy to use API for GraphQL.
1kMIT License
README
require 'agoo'
 
class Query
  def hello
    'hello'
  end
end
 
class Schema
  attr_reader :query
 
  def initialize
    @query = Query.new()
  end
end
 
Agoo::Server.init(6464, 'root', thread_count: 1, graphql: '/graphql')
Agoo::Server.start()
Agoo::GraphQL.schema(Schema.new) {
  Agoo::GraphQL.load(%^type Query { hello: String }^)
}
sleep
 
# To run this GraphQL example type the following then go to a browser and enter
# a URL of localhost:6464/graphql?query={hello}
#
# ruby hello.rb
Rails GraphQL
A Fresh new GraphQL server for Rails applications, with a focus on natural and Ruby-like DSL
Last release 7 months ago175MIT License
README
require 'rails-graphql'
 
class GraphQL::AppSchema < GraphQL::Schema
  query_fields do
    field(:hello).resolve { 'Hello World!' }
  end
end
 
puts GraphQL::AppSchema.execute('{ hello }')

Less is more! Please check it out the docs.