Skip to content

Releases: cloudflare/workers-graphql-server

1.2.0

06 Oct 16:17
496f299
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 1.1.1...v1.2.0

⚡️ 1.1.0

23 Aug 17:16
36ce340
Compare
Choose a tag to compare

KV cache support

workers-graphql-server now includes support for caching external requests made via instances of RESTDataSource, using KV. To use caching in your project, create a new KV namespace, and in wrangler.toml, configure your namespace, calling it WORKERS_GRAPHQL_CACHE:

# wrangler.toml

[[kv-namespaces]]
binding = "WORKERS_GRAPHQL_CACHE"
id = "$myId"

With a configured KV namespace set up, you can opt-in to KV caching by changing the kvCache config value in graphQLOptions (in index.js) to true.

CORS support for GraphQL requests

The addition of the cors configuration in graphQLOptions (in src/index.js) allows an instance of workers-graphql-server to receive cross-origin requests. By default, the cors option allows cross-origin requests to the server from any origin. You may wish to configure it to whitelist specific origins, methods, or headers. To do this, change the cors option to an object:

const graphQLOptions = {
  // ... other options ...

  cors: {
    allowCredentials: 'true',
    allowHeaders: 'Content-type',
    allowOrigin: '*',
    allowMethods: 'GET, POST, PUT',
  }
}

Note that by default, any field that you don't pass here (e.g. allowMethods) will fallback to the default value. See utils/setCors.js for the default values for these fields.

File layout re-org to follow Apollo tuts

The project layout has been re-organized to follow the structure in Apollo's full-stack tutorial.

🤗 1.0.0

31 Jul 14:59
Compare
Choose a tag to compare

workers-graphql-server is a lightning-fast, globally distributed Apollo GraphQL server, deployed at the edge using Cloudflare Workers.

To get started, check out the tutorial in the Cloudflare Workers docs!