0.0.5 • Published 2 years ago

graphql-workers v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

graphql-workers

⚡ 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

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago