Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit b862761

Browse files
authored
Fixes and improvements to the README (#748)
* Fix rootValue option description The mentioned function should be execute() instead of graphql(). Also, the branch name and line number have changed. * Fix context option description The mentioned function should be execute() instead of graphql() and the passed property should be contextValue instead of context. Also, the branch name and line number have changed. * Remove distracting session middleware from extensions example Using the session middleware in the extensions example seems unnecessary and distracting from the extensions example. * Make list items explaining POST body parsing consistent * Add missing comma in JSON example * Improve the readability of some sentences * Fix some small typos * Add missing backticks * Fix branch name in links to graphql-js repo
1 parent 2882357 commit b862761

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

README.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,18 @@ The `graphqlHTTP` function accepts the following options:
131131

132132
- **`defaultQuery`**: An optional GraphQL string to use when no query
133133
is provided and no stored query exists from a previous session.
134-
If undefined is provided, GraphiQL will use its own default query.
134+
If `undefined` is provided, GraphiQL will use its own default query.
135135

136-
- **`headerEditorEnabled`**: An optional boolean which enables the header editor when true.
137-
Defaults to false.
136+
- **`headerEditorEnabled`**: An optional boolean which enables the header editor when `true`.
137+
Defaults to `false`.
138138

139139
- **`subscriptionEndpoint`**: An optional GraphQL string contains the WebSocket server url for subscription.
140140

141-
- **`rootValue`**: A value to pass as the `rootValue` to the `graphql()`
142-
function from [`GraphQL.js/src/execute.js`](https://github.com/graphql/graphql-js/blob/master/src/execution/execute.js#L119).
141+
- **`rootValue`**: A value to pass as the `rootValue` to the `execute()`
142+
function from [`GraphQL.js/src/execute.js`](https://github.com/graphql/graphql-js/blob/main/src/execution/execute.js#L129).
143143

144-
- **`context`**: A value to pass as the `context` to the `graphql()`
145-
function from [`GraphQL.js/src/execute.js`](https://github.com/graphql/graphql-js/blob/master/src/execution/execute.js#L120). If `context` is not provided, the
144+
- **`context`**: A value to pass as the `contextValue` to the `execute()`
145+
function from [`GraphQL.js/src/execute.js`](https://github.com/graphql/graphql-js/blob/main/src/execution/execute.js#L130). If `context` is not provided, the
146146
`request` object is passed as the context.
147147

148148
- **`pretty`**: If `true`, any JSON response will be pretty-printed.
@@ -154,7 +154,7 @@ The `graphqlHTTP` function accepts the following options:
154154
of resources consumed. This may be an async function. The function is
155155
given one object as an argument: `{ document, variables, operationName, result, context }`.
156156

157-
- **`validationRules`**: Optional additional validation rules queries must
157+
- **`validationRules`**: Optional additional validation rules that queries must
158158
satisfy in addition to those defined by the GraphQL spec.
159159

160160
- **`customValidateFn`**: An optional function which will be used to validate
@@ -207,7 +207,7 @@ the parameters:
207207
named operations.
208208

209209
- **`raw`**: If the `graphiql` option is enabled and the `raw` parameter is
210-
provided raw JSON will always be returned instead of GraphiQL even when
210+
provided, raw JSON will always be returned instead of GraphiQL even when
211211
loaded from a browser.
212212

213213
GraphQL will first look for each parameter in the query string of a URL:
@@ -216,23 +216,23 @@ GraphQL will first look for each parameter in the query string of a URL:
216216
/graphql?query=query+getUser($id:ID){user(id:$id){name}}&variables={"id":"4"}
217217
```
218218

219-
If not found in the query-string, it will look in the POST request body.
219+
If not found in the query string, it will look in the POST request body.
220220

221221
If a previous middleware has already parsed the POST body, the `request.body`
222222
value will be used. Use [`multer`][] or a similar middleware to add support
223223
for `multipart/form-data` content, which may be useful for GraphQL mutations
224224
involving uploading files. See an [example using multer](https://github.com/graphql/express-graphql/blob/304b24b993c8f16fffff8d23b0fa4088e690874b/src/__tests__/http-test.js#L674-L741).
225225

226-
If the POST body has not yet been parsed, express-graphql will interpret it
226+
If the POST body has not yet been parsed, `express-graphql` will interpret it
227227
depending on the provided _Content-Type_ header.
228228

229229
- **`application/json`**: the POST body will be parsed as a JSON
230230
object of parameters.
231231

232-
- **`application/x-www-form-urlencoded`**: this POST body will be
232+
- **`application/x-www-form-urlencoded`**: the POST body will be
233233
parsed as a url-encoded string of key-value pairs.
234234

235-
- **`application/graphql`**: The POST body will be parsed as GraphQL
235+
- **`application/graphql`**: the POST body will be parsed as GraphQL
236236
query string, which provides the `query` parameter.
237237

238238
## Combining with Other Express Middleware
@@ -296,8 +296,6 @@ const { graphqlHTTP } = require('express-graphql');
296296

297297
const app = express();
298298

299-
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 } }));
300-
301299
const extensions = ({
302300
document,
303301
variables,
@@ -328,7 +326,7 @@ for example:
328326

329327
```js
330328
{
331-
"data": { ... }
329+
"data": { ... },
332330
"extensions": {
333331
"runTime": 135
334332
}
@@ -339,7 +337,7 @@ for example:
339337

340338
GraphQL's [validation phase](https://graphql.github.io/graphql-spec/#sec-Validation) checks the query to ensure that it can be successfully executed against the schema. The `validationRules` option allows for additional rules to be run during this phase. Rules are applied to each node in an AST representing the query using the Visitor pattern.
341339

342-
A validation rule is a function which returns a visitor for one or more node Types. Below is an example of a validation preventing the specific field name `metadata` from being queried. For more examples see the [`specifiedRules`](https://github.com/graphql/graphql-js/tree/master/src/validation/rules) in the [graphql-js](https://github.com/graphql/graphql-js) package.
340+
A validation rule is a function which returns a visitor for one or more node Types. Below is an example of a validation preventing the specific field name `metadata` from being queried. For more examples, see the [`specifiedRules`](https://github.com/graphql/graphql-js/tree/main/src/validation/rules) in the [graphql-js](https://github.com/graphql/graphql-js) package.
343341

344342
```js
345343
import { GraphQLError } from 'graphql';
@@ -424,14 +422,14 @@ Each release of `express-graphql` will be accompanied by an experimental release
424422
Community feedback on this experimental release is much appreciated and can be provided on the [PR for the defer-stream branch](https://github.com/graphql/express-graphql/pull/726) or the [GraphQL.js issue for feedback](https://github.com/graphql/graphql-js/issues/2848).
425423

426424
[`graphql.js`]: https://github.com/graphql/graphql-js
427-
[`formaterror`]: https://github.com/graphql/graphql-js/blob/master/src/error/formatError.js
425+
[`formaterror`]: https://github.com/graphql/graphql-js/blob/main/src/error/formatError.js
428426
[graphiql]: https://github.com/graphql/graphiql
429427
[`multer`]: https://github.com/expressjs/multer
430428
[`express-session`]: https://github.com/expressjs/session
431429

432430
# Contributing to this repo
433431

434-
This repository is managed by EasyCLA. Project participants must sign the free ([GraphQL Specification Membership agreement](https://preview-spec-membership.graphql.org) before making a contribution. You only need to do this one time, and it can be signed by [individual contributors](http://individual-spec-membership.graphql.org/) or their [employers](http://corporate-spec-membership.graphql.org/).
432+
This repository is managed by EasyCLA. Project participants must sign the free [GraphQL Specification Membership agreement](https://preview-spec-membership.graphql.org) before making a contribution. You only need to do this one time, and it can be signed by [individual contributors](http://individual-spec-membership.graphql.org/) or their [employers](http://corporate-spec-membership.graphql.org/).
435433

436434
To initiate the signature process please open a PR against this repo. The EasyCLA bot will block the merge if we still need a membership agreement from you.
437435

0 commit comments

Comments
 (0)