Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql_server

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql_server

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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)

FAQs

Package last updated on 21 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc