graphql-workers
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

graphql-workers

npm add graphql-workers puts graphql on the edge

downloads size

Features

  • 🤔 Familiar — thin layer ontop of graphql-js

  • 🪢 defer/stream — incremental delivery out of the box

🚀 Usage

npm add graphql-workers \
  graphql@16.1.0-experimental-stream-defer.6

at this stage you need a custom tag to support defer/stream, but this is optional

import { makeHandler, createSchemaResponder } from 'graphql-workers';

// your schem as however you have it defined
declare const schema: GraphQLSchema;

export default {
	async fetch(req, env, ctx) {
		// ~> create a streamable schema
		const { reply } = createSchemaResponder(ctx, schema);

		// ~> get the paramaters in way you wish
		// maybe its a KV read for Relay persisted queries
		const { query, variables, operationName } = await req.json();

		// ~> then simply reply
		return reply(query, variables, operationName);
	}
}

// or a module workers convience method
export default makeHandler(schema);

License

MIT © Marais Rossouw

Readme

Keywords

none

Package Sidebar

Install

npm i graphql-workers

Weekly Downloads

7

Version

0.0.5

License

MIT

Unpacked Size

5.24 kB

Total Files

5

Last publish

Collaborators

  • marais