この紹介文は現在英語版のみです。
Overview
workers-graphql-server is Cloudflare’s template for an Apollo GraphQL server on Cloudflare Workers. Whether your APIs run on-prem, in another cloud or on Cloudflare itself, it puts a globally distributed GraphQL layer in front of them.
Getting started
git clone https://github.com/cloudflare/workers-graphql-server
npm install
npm run dev
Configure wrangler.toml before deploying. The example resolvers call the PokeAPI, so a query like pokemon(id: 1) { name height weight } works right after deployment.
How it’s organized
- Schema in
src/schema.graphql; runnpm run codegenafter changes to regenerate the types insrc/generated/graphql.ts. - Resolvers in
src/resolvers.ts; they can use Service Bindings to call other Workers. - Options such as the base endpoint, the GraphQL sandbox, CORS and KV caching are set in
graphQLOptions.