Skip to content

Commit 2e48eee

Browse files
Squash commits for 1.0.0 release
1 parent 6b73dc8 commit 2e48eee

9 files changed

+553
-177
lines changed

.env.example

-6
This file was deleted.

README.md

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# workers-graphql-server
22

3-
An [Apollo GraphQL](https://www.apollographql.com/) server, built with [Cloudflare Workers](https://workers.cloudflare.com). Includes a GraphiQL route for testing requests.
3+
An [Apollo GraphQL](https://www.apollographql.com/) server, built with [Cloudflare Workers](https://workers.cloudflare.com). [Try a demo by looking at a deployed GraphQL playground](https://graphql-on-workers.signalnerve.com/___graphql).
44

5-
[Try a demo by looking at the GraphiQL explorer](https://graphql-on-workers.signalnerve.com/graphiql).
5+
Why this rules: Cloudflare Workers is a serverless application platform for deploying your projects across Cloudflare's massive distributed network. Deploying your GraphQL application to the edge is a huge opportunity to build consistent low-latency API servers, with the added benefits of "serverless" (I know, the project has `server` in it): usage-based pricing, no cold starts, and instant, easy-to-use deployment software, using [Wrangler](https://github.com/cloudflare/wrangler).
6+
7+
By the way - as a full-stack developer who _loves_ GraphQL, and the developer advocate for Cloudflare Workers, I would love to see what you build with this! Let me know [on Twitter](https://twitter.com/signalnerve)!
68

79
## Usage
810

@@ -12,9 +14,26 @@ You can begin building your own Workers GraphQL server by [installing Wrangler](
1214
wrangler generate my-graphql-server https://github.com/signalnerve/workers-graphql-server
1315
```
1416

15-
The source for this project includes an external REST data source, and defined types for the [PokeAPI](https://pokeapi.co/), as an example of how to integrate external APIs.
17+
You'll need to configure your project's `wrangler.toml` file to prepare your project for deployment. See the docs (["Configuring and Publishing"](https://workers.cloudflare.com/docs/quickstart/configuring-and-publishing/)) for a guide on how to do this. Note that you'll need to [find your Cloudflare API keys](https://workers.cloudflare.com/docs/quickstart/api-keys/) to set up your config file.
18+
19+
The source for this project includes an example external REST data source, and defined types for the [PokeAPI](https://pokeapi.co/), as an example of how to integrate external APIs.
20+
21+
To start using the project, configure your `graphQLOptions` object in `src/index.js`:
22+
23+
```js
24+
const graphQLOptions = {
25+
baseEndpoint: '/', // String
26+
playgroundEndpoint: '/___graphql', // ?String
27+
forwardUnmatchedRequestsToOrigin: false, // Boolean
28+
debug: false, // Boolean
29+
}
30+
```
31+
32+
Make requests to your GraphQL server at the `baseEndpoint` (e.g. `graphql-on-workers.signalnerve.com/`) and, if configured, try GraphQL queries at the `playgroundEndpoint` (e.g. `graphql-on-workers.signalnerve.com/___graphql`).
33+
34+
If you run your GraphQL server on a domain already registered with Cloudflare, you may want to pass any unmatched requests from inside your Workers script to your origin: in that case, set `forwardUnmatchedRequestToOrigin` to true (if you're running a GraphQL server on a [Workers.dev](https://workers.dev) subdomain, the default of `false` is fine).
1635

17-
By the way - as a fullstack developer who _loves GraphQL_, and the developer advocate for Cloudflare Workers, I would love to see what you build with this! Let me know [on Twitter](https://twitter.com/signalnerve)!
36+
Finally, while configuring your server, you may want to set the `debug` flag to `true`, to allow script errors to be returned in your browser. This can be useful for debugging any errors while setting up your GraphQL server.
1837

1938
## License
2039

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "graphql-on-workers",
2+
"name": "{{ project-name }}",
33
"private": true,
4-
"description": "graphql-on-workers",
5-
"version": "0.9.9",
6-
"author": "Kristian Freeman <[email protected]>",
4+
"description": "🔥Lightning-fast, globally distributed Apollo GraphQL server, deployed at the edge using Cloudflare Workers",
5+
"version": "1.1.0",
6+
"author": "{{ authors }}",
77
"dependencies": {
88
"apollo-datasource-rest": "^0.3.2",
99
"apollo-server-cloudflare": "^2.4.8",

src/handlers/apollo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const server = new ApolloServer({
4444
}),
4545
})
4646

47-
const handler = request =>
47+
const handler = (request, _graphQLOptions) =>
4848
graphqlCloudflare(() => server.createGraphQLServerOptions(request))(request)
4949

5050
module.exports = handler

src/handlers/graphiql.js

-147
This file was deleted.

0 commit comments

Comments
 (0)