You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,8 +29,8 @@ Fully-featured GraphQL Server with focus on easy setup, performance & great deve
29
29
* Extensible via Express middlewares
30
30
* Schema directives
31
31
* Apollo Tracing
32
-
* Accepts both `application/json` and `application/graphql` content-type
33
-
* Runs everywhere: Can be deployed via `now`, `up`, AWS Lambda, Heroku etc
32
+
* Accepts both `application/json` and `application/graphql` content-types
33
+
* Runs everywhere: Can be deployed via `now`, `up`, AWS Lambda, Heroku etc.
34
34
35
35
## Install
36
36
@@ -86,7 +86,7 @@ The `props` argument accepts the following fields:
86
86
> 1. Provide `typeDefs` and `resolvers` and omit the `schema`, in this case `graphql-yoga` will construct the `GraphQLSchema` instance using [`makeExecutableSchema`](https://www.apollographql.com/docs/graphql-tools/generate-schema.html#makeExecutableSchema) from [`graphql-tools`](https://github.com/apollographql/graphql-tools).
87
87
> 2. Provide the `schema` directly and omit `typeDefs` and `resolvers`.
88
88
89
-
> (\*\*) Notice that the `req` argument is an object of the shape `{ request, connection }` which either carries a `request: Request` property (in case it's a `Query`/`Mutation` resolver) or a `connection: SubscriptionOptions` property (in case it's a `Subscription` resolver). [`Request`](http://expressjs.com/en/api.html#req) is imported from Express.js. `SubscriptionOptions` is from the [`graphql-subscriptions`](https://github.com/apollographql/graphql-subscriptions) package. `SubscriptionOptions` are getting the connectionParams automatically injected under `SubscriptionOptions.context.[CONNECTION_PARAMETER_NAME]`
89
+
> (\*\*) Notice that the `req` argument is an object of the shape `{ request, connection }` which either carries a `request: Request` property (when it's a `Query`/`Mutation` resolver) or a `connection: SubscriptionOptions` property (when it's a `Subscription` resolver). [`Request`](http://expressjs.com/en/api.html#req) is imported from Express.js. `SubscriptionOptions` is from the [`graphql-subscriptions`](https://github.com/apollographql/graphql-subscriptions) package. `SubscriptionOptions` are getting the `connectionParams` automatically injected under `SubscriptionOptions.context.[CONNECTION_PARAMETER_NAME]`
90
90
91
91
Here is example of creating a new server:
92
92
@@ -108,14 +108,14 @@ const server = new GraphQLServer({ typeDefs, resolvers })
Once your `GraphQLServer` is instantiated, you can call the `start` method on it. It takes two arguments: `options`, the options object defined above, and `callback`, a function that's invoked right before the server is started. As an example, the `callback` can be used to print information that the server was now started.
111
+
Once your `GraphQLServer` is instantiated, you can call the `start` method on it. It takes two arguments: `options`, the options object defined above, and `callback`, a function that's invoked right before the server is started. As an example, the `callback` can be used to print information that the server has started.
112
112
113
113
The `options` object has the following fields:
114
114
115
115
| Key | Type | Default | Note |
116
116
| --- | --- | --- | --- |
117
117
|`cors`| Object |`null`| Contains [configuration options](https://github.com/expressjs/cors#configuration-options) for [cors](https://github.com/expressjs/cors)|
118
-
|`tracing`| Boolean or String |`'http-header'`| Indicates whether [Apollo Tracing](https://github.com/apollographql/apollo-tracing) should be en- or disabled for your server (if a string is provided, accepted values are: `'enabled'`, `'disabled'`, `'http-header'`) |
118
+
|`tracing`| Boolean or String |`'http-header'`| Indicates whether [Apollo Tracing](https://github.com/apollographql/apollo-tracing) should be enabled or disabled for your server (if a string is provided, accepted values are: `'enabled'`, `'disabled'`, `'http-header'`) |
119
119
|`port`| Number |`4000`| Determines the port your server will be listening on (note that you can also specify the port by setting the `PORT` environment variable) |
120
120
|`endpoint`| String |`'/'`| Defines the HTTP endpoint of your server |
121
121
|`subscriptions`| Object or String or `false`|`'/'`| Defines the subscriptions (websocket) endpoint for your server; accepts an object with [subscription server options](https://github.com/apollographql/subscriptions-transport-ws#constructoroptions-socketoptions)`path`, `keepAlive`, `onConnect` and `onDisconnect`; setting to `false` disables subscriptions completely |
@@ -131,9 +131,9 @@ Additionally, the `options` object exposes these `apollo-server` options:
131
131
|`formatError`| Number | A function to apply to every error before sending the response to clients |
132
132
|`logFunction`| LogFunction | A function called for logging events such as execution times |
133
133
|`rootValue`| any | RootValue passed to GraphQL execution |
134
-
|`validationRules`| Array of functions |DAdditional GraphQL validation rules to be applied to client-specified queries |
135
-
| `fieldResolver` | GraphQLFieldResolver | Specifify a custom default field resolver function
136
-
|`formatParams`| Function | A function applied for each query in a batch to format parameters before execution |
134
+
|`validationRules`| Array of functions |Additional GraphQL validation rules to be applied to client-specified queries |
135
+
| `fieldResolver` | GraphQLFieldResolver | Specify a custom default field resolver function
136
+
|`formatParams`| Function | A function applied to each query in a batch to format parameters before execution |
137
137
|`formatResponse`| Function | A function applied to each response after execution |
@@ -159,7 +159,7 @@ See the original documentation in [`graphql-subscriptions`](https://github.com/a
159
159
There are three examples demonstrating how to quickly get started with `graphql-yoga`:
160
160
161
161
-[hello-world](./examples/hello-world): Basic setup for building a schema and allowing for a `hello` query.
162
-
-[subscriptions](./examples/subscriptions): Basic setup for using subscriptions with a counter that increments every 2 seconds and triggers a subscriptions.
162
+
-[subscriptions](./examples/subscriptions): Basic setup for using subscriptions with a counter that increments every 2 seconds and triggers a subscription.
163
163
-[fullstack](./examples/fullstack): Fullstack example based on [`create-react-app`](https://github.com/facebookincubator/create-react-app) demonstrating how to query data from `graphql-yoga` with [Apollo Client 2.0](https://www.apollographql.com/client/).
164
164
165
165
## Workflow
@@ -183,7 +183,7 @@ To deploy your `graphql-yoga` server with [`now`](https://zeit.co/now), follow t
183
183
To deploy your `graphql-yoga` server with [Heroku](https://heroku.com), follow these instructions:
184
184
185
185
1. Download and install the [Heroku Command Line Interface](https://devcenter.heroku.com/articles/heroku-cli#download-and-install) (previously Heroku Toolbelt)
186
-
2. Log In to the Heroku CLI with `heroku login`
186
+
2. Log in to the Heroku CLI with `heroku login`
187
187
3. Navigate to the root directory of your `graphql-yoga` server
188
188
4. Create the Heroku instance by executing `heroku create`
189
189
5. Deploy your GraphQL server by executing `git push heroku master`
@@ -196,17 +196,17 @@ To deploy your `graphql-yoga` server with [Heroku](https://heroku.com), follow t
196
196
197
197
### How does `graphql-yoga` compare to `apollo-server` and other tools?
198
198
199
-
As mentioned above, `graphql-yoga` is built on top of a variety of other packages, such as `graphql.js`, `express` and `apollo-server`. Each of these provide a certain piece of functionality required for building a GraphQL server.
199
+
As mentioned above, `graphql-yoga` is built on top of a variety of other packages, such as `graphql.js`, `express` and `apollo-server`. Each of these provides a certain piece of functionality required for building a GraphQL server.
200
200
201
-
Using these packages individually incurs overhead in the setup process and requires you to write a lot of boilerplate. `graphql-yoga` abstracts away the initial complexity and required boilerplate and let's you get started quickly with a set of sensible defaults for your server configuration.
201
+
Using these packages individually incurs overhead in the setup process and requires you to write a lot of boilerplate. `graphql-yoga` abstracts away the initial complexity and required boilerplate and lets you get started quickly with a set of sensible defaults for your server configuration.
202
202
203
203
`graphql-yoga` is like [`create-react-app`](https://github.com/facebookincubator/create-react-app) for building GraphQL servers.
204
204
205
205
### Can't I just setup my own GraphQL server using `express` and `graphql.js`?
206
206
207
-
`graphql-yoga` is all about convenience and a great "Getting Started"-experience by abstracting away the complexity that comes when you're building your own GraphQL from scratch. It's a pragmatic approach to bootstrap a GraphQL server, much like [`create-react-app`](https://github.com/facebookincubator/create-react-app) removes friction when first starting out with React.
207
+
`graphql-yoga` is all about convenience and a great "Getting Started"experience by abstracting away the complexity that comes when you're building your own GraphQL server from scratch. It's a pragmatic approach to bootstrap a GraphQL server, much like how[`create-react-app`](https://github.com/facebookincubator/create-react-app) removes friction when first starting out with React.
208
208
209
-
Whenever the defaults of `graphql-yoga` are too tight of a corset for you, you can simply _eject_ from it and use the tooling it's build upon - there's no lock-in or any other kind of magic going on preventing you from this.
209
+
Whenever the defaults of `graphql-yoga` are too tight a corset for you, you can simply _eject_ from it and use the tooling it's built upon - there's no lock-in or any other kind of magic going on preventing you from doing this.
210
210
211
211
### How to eject from the standard `express` setup?
0 commit comments