graphql-workers
v0.0.5
Published
<div align="right"> <p><code>npm add graphql-workers</code> puts graphql on the edge</p> <span> <a href="https://github.com/maraisr/graphql-workers/actions/workflows/ci.yml"> <img src="https://github.com/maraisr/graphql-workers/actions/workflows/ci.yml/b
Readme
graphql-workers
⚡ Features
🤔 Familiar — thin layer ontop of graphql-js
🪢 defer/stream — incremental delivery out of the box
🚀 Usage
npm add graphql-workers \
[email protected]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
