ge
graphyne-express
npm i graphyne-express
Deprecated!
Please use graphyne-server for Express integration
ge

graphyne-express

⚡ Lightning-fast JavaScript GraphQL Server ⚡

by Hoang

0.1.2 (see all)License:MITTypeScript:Built-In
npm i graphyne-express
Readme

Graphyne Server Express

The Express and Connect integration of Graphyne.

Install

npm i graphyne-express graphql
// or
yarn add graphyne-express graphql

Usage

Check out the example.

const express = require('express');
const { GraphyneServer } = require('graphyne-express');

const graphyne = new GraphyneServer(options);

var app = express();

// GraphQL API
app.all('/graphql', graphyne.createHandler());
// GraphiQL
app.get('/___graphql', graphyle.createHandler({
  path: '/graphql' // Must be set: GraphQL's path, not GraphiQL
  graphiql: true
}))

app.listen(4000);
console.log('Running a GraphQL API server at http://localhost:4000/graphql');

API

new GraphyneServer(options)

Refer to API.

GraphyneServer#createHandler(options)

Create a handler for Express/Connect Router. Refer to API.

When options.path and options.graphiql.path is not set, they do not default to /graphql and /___graphql respectively. Instead, graphyne-express wouuld response to all incoming requests. This is because routing is delegated to Express/Connect Router (see in Usage).

Using with GraphiQL

If options.graphiql is to be used, options.path must be set. This is because routing is delegated to Express/Connect Router, so Graphyle is not aware of where the GraphQL endpoint is exposed.

Using with Connect

Connect router only has .use, which matches only the beginning of the URL. Therefore, GraphQL endpoints will also be exposed in sub-directories if path is not set.

connect.use('/graphql', graphyne.createHandler())
// `/graphql`, `/graphql/foo`, `/graphql/foo/bar` are all GraphQL endpoint.
// You should explicitly defining options.path
connect.use('/graphql', graphyne.createHandler({
  path: '/graphql'
}))

Same things applies to options.graphiql.path.

License

MIT

Downloads/wk

1

GitHub Stars

18

LAST COMMIT

2yrs ago

MAINTAINERS

1

CONTRIBUTORS

3

OPEN ISSUES

3

OPEN PRs

10
VersionTagPublished
0.1.2
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate