⚡️ 1.1.0
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.