This gem is a simple middleware wrapper for GraphQL Playground, a GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).
gem install graphql_playground
If you use rack, you can mount it like this
require 'graphql_playground'
map '/playground' do
use GraphQLPlayground, endpoint: '/graphql' # endpoint to your graphql server endpoint
end
# app.ru
require 'graphql_playground'
require 'graphql_server'
type_def = <<-GRAPHQL
type Query {
hello: String
}
GRAPHQL
resolver = {
"Query" => {
"hello" => Proc.new { "world" }
}
}
map '/playground' do
use GraphQLPlayground, endpoint: '/'
end
run GraphQLServer.new(type_def: type_def, resolver: resolver)
Launch it with
rackup app.ru
And then open http://localhost:9292/playground
(Reference https://github.com/betaflag/graphql-server-ruby)