prismagraphql/graphql-playground

Name: graphql-playground

Owner: Prisma

Description: ? GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)

Created: 2017-01-25 13:19:29.0

Updated: 2018-05-24 09:48:37.0

Pushed: 2018-05-23 23:47:12.0

Homepage:

Size: 4126

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

npm version Build Status CircleCI

GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).
You can download the desktop app or use the web version at graphqlbin.com: Demo

Installation
ew cask install graphql-playground
Features
FAQ
How is this different from GraphiQL?

GraphQL Playground uses components of GraphiQL under the hood but is meant as a more powerful GraphQL IDE enabling better (local) development workflows. Compared to GraphiQL, the GraphQL Playground ships with the following additional features:

See the following question for more additonal features.

What's the difference between the desktop app and the web version?

The desktop app is the same as the web version but includes these additional features:

How does GraphQL Bin work?

You can easily share your Playgrounds with others by clicking on the “Share” button and sharing the generated link. You can think about GraphQL Bin like Pastebin for your GraphQL queries including the context (endpoint, HTTP headers, open tabs etc).

You can also find the announcement blog post here.

Usage
Properties

All interfaces, the React component <Playground /> and all middlewares expose the same set of options:

As React Component
Install
 add graphql-playground-react
Use

GraphQL Playground provides a React component responsible for rendering the UI and Session management. There are 3 dependencies needed in order to run the graphql-playground-react React component.

  1. Open Sans and Source Code Pro fonts
  2. Including graphql-playground-react/playground.css
  3. Rendering the <Playground /> component

The GraphQL Playground requires React 16.

Including Fonts (1.)

k href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Source+Code+Pro:400,700" rel="stylesheet">

Including stylesheet and the component (2., 3.)

rt React from 'react'
rt ReactDOM from 'react-dom'
rt Playground from 'graphql-playground-react'
rt 'graphql-playground-react/playground.css'

tDOM.render(<Playground endpoint="https://api.graph.cool/simple/v1/swapi" />, document.body)
As Server Middleware
Install
ck the one that matches your server framework
 add graphql-playground-middleware-express  # for Express or Connect
 add graphql-playground-middleware-hapi
 add graphql-playground-middleware-koa
 add graphql-playground-middleware-lambda
Usage with example

We have a full example for each of the frameworks below:

As serverless handler
Install
 add graphql-playground-middleware-lambda
Usage

handler.js

rt lambdaPlayground from 'graphql-playground-middleware-lambda'
r using require()
onst lambdaPlayground = require('graphql-playground-middleware-lambda').default

rts.graphqlHandler = function graphqlHandler(event, context, callback) {
nction callbackFilter(error, output) {
// eslint-disable-next-line no-param-reassign
output.headers['Access-Control-Allow-Origin'] = '*';
callback(error, output);


nst handler = graphqlLambda({ schema: myGraphQLSchema });
turn handler(event, context, callbackFilter);


rts.playgroundHandler = lambdaPlayground({
dpoint: '/dev/graphql',

serverless.yml

tions:
aphql:
handler: handler.graphqlHandler
events:
- http:
    path: graphql
    method: post
    cors: true
ayground:
handler: handler.playgroundHandler
events:
- http:
    path: playground
    method: get
    cors: true
Development

This is a mono-repo setup containing packages for the graphql-playground-react and graphql-playground-electron.

stalls all dependencies for all packages
rn
 packages/graphql-playground-react
rn start

Open localhost:3000/middleware.html?endpoint=https://api.graph.cool/simple/v1/swapi for local development!

Versions

This is repository is a “mono repo” and contains multiple packages using Yarn workspaces. Please be aware that versions are not synchronised between packages. The versions of the release page refer to the electron app.

Packages

In the folder packages you'll find the following packages:

Help & Community Slack Status

Join our Slack community if you run into issues or have questions. We love talking to you!


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.