0.0
No commit activity in last 3 years
No release in over 3 years
A simple spec-compliant GraphQL rack application and middleware
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.8
~> 1.8
~> 2.0
 Project Readme

This is a simple spec-compliant GraphQL rack application and middleware based on the graphql gem. Since it's built with Rack, it can be mounted with most ruby web servers.

Install the gem:

gem install graphql_server

Using the server

As a standalone application

# app.ru
require 'graphql_server'

type_def = <<-GRAPHQL
  type Query {
    hello: String
  }
GRAPHQL

resolver = {
  "Query" => {
    "hello" => Proc.new { "world" }
  }
}

run GraphQLServer.new(type_def: type_def, resolver: resolver)

Start using rackup

rackup app.ru

As a middleware in your existing application

# app.ru
require 'graphql_server'

type_def = ...
resolver = ...

use GraphQLServer, type_def: type_def, resolver: resolver

Options

Schema

You can get started fast by writing a type defintions and a resolver hash

GraphQLServer.new(type_def: type_def, resolver: resolver)

You can also provide your own schema

GraphQLServer.new(schema: schema)

See the examples folder for more details

GraphQL Playground

You can use the excellent GraphQL Playground IDE from Prisma

gem install graphql_playground

Map it to the url of your choice and point it to your GraphQL server endpoit

map '/playground' do
  use GraphQLPlayground, endpoint: '/'
end

run GraphQLServer.new(type_def: type_def, resolver: resolver)