Skip to content

Commit 221c2d9

Browse files
committed
Various fixes to docs (#4256)
1 parent 10fd798 commit 221c2d9

16 files changed

+113
-111
lines changed

website/css/globals.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ footer {
4848

4949
&:hover {
5050
mask-position: 100%;
51-
transition: mask-position 1s ease, -webkit-mask-position 1s ease;
51+
transition:
52+
mask-position 1s ease,
53+
-webkit-mask-position 1s ease;
5254
}
5355
}
5456

website/pages/authentication-and-express-middleware.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ To use middleware with a GraphQL resolver, just use the middleware like you woul
1010
For example, let's say we wanted our server to log the IP address of every request, and we also want to write an API that returns the IP address of the caller. We can do the former with middleware, and the latter by accessing the `request` object in a resolver. Here's server code that implements this:
1111

1212
```js
13-
var express = require('express');
14-
var { createHandler } = require('graphql-http/lib/use/express');
15-
var { buildSchema } = require('graphql');
13+
const express = require('express');
14+
const { createHandler } = require('graphql-http/lib/use/express');
15+
const { buildSchema } = require('graphql');
1616

17-
var schema = buildSchema(`
17+
const schema = buildSchema(`
1818
type Query {
1919
ip: String
2020
}
@@ -25,13 +25,13 @@ function loggingMiddleware(req, res, next) {
2525
next();
2626
}
2727

28-
var root = {
28+
const root = {
2929
ip(args, context) {
3030
return context.ip;
3131
},
3232
};
3333

34-
var app = express();
34+
const app = express();
3535
app.use(loggingMiddleware);
3636
app.all(
3737
'/graphql',

website/pages/basic-types.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ To use a list type, surround the type in square brackets, so `[Int]` is a list o
1313
Each of these types maps straightforwardly to JavaScript, so you can just return plain old JavaScript objects in APIs that return these types. Here's an example that shows how to use some of these basic types:
1414

1515
```js
16-
var express = require('express');
17-
var { createHandler } = require('graphql-http/lib/use/express');
18-
var { buildSchema } = require('graphql');
16+
const express = require('express');
17+
const { createHandler } = require('graphql-http/lib/use/express');
18+
const { buildSchema } = require('graphql');
1919

2020
// Construct a schema, using GraphQL schema language
21-
var schema = buildSchema(`
21+
const schema = buildSchema(`
2222
type Query {
2323
quoteOfTheDay: String
2424
random: Float!
@@ -27,7 +27,7 @@ var schema = buildSchema(`
2727
`);
2828

2929
// The root provides a resolver function for each API endpoint
30-
var root = {
30+
const root = {
3131
quoteOfTheDay() {
3232
return Math.random() < 0.5 ? 'Take it easy' : 'Salvation lies within';
3333
},
@@ -39,7 +39,7 @@ var root = {
3939
},
4040
};
4141

42-
var app = express();
42+
const app = express();
4343
app.all(
4444
'/graphql',
4545
createHandler({

website/pages/constructing-types.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ When you are using the `GraphQLSchema` constructor to create a schema, instead o
99
For example, let's say we are building a simple API that lets you fetch user data for a few hardcoded users based on an id. Using `buildSchema` we could write a server with:
1010

1111
```js
12-
var express = require('express');
13-
var { createHandler } = require('graphql-http/lib/use/express');
14-
var { buildSchema } = require('graphql');
12+
const express = require('express');
13+
const { createHandler } = require('graphql-http/lib/use/express');
14+
const { buildSchema } = require('graphql');
1515

16-
var schema = buildSchema(`
16+
const schema = buildSchema(`
1717
type User {
1818
id: String
1919
name: String
@@ -25,7 +25,7 @@ var schema = buildSchema(`
2525
`);
2626

2727
// Maps id to User object
28-
var fakeDatabase = {
28+
const fakeDatabase = {
2929
a: {
3030
id: 'a',
3131
name: 'alice',
@@ -36,13 +36,13 @@ var fakeDatabase = {
3636
},
3737
};
3838

39-
var root = {
39+
const root = {
4040
user({ id }) {
4141
return fakeDatabase[id];
4242
},
4343
};
4444

45-
var app = express();
45+
const app = express();
4646
app.all(
4747
'/graphql',
4848
createHandler({
@@ -57,12 +57,12 @@ console.log('Running a GraphQL API server at localhost:4000/graphql');
5757
We can implement this same API without using GraphQL schema language:
5858

5959
```js
60-
var express = require('express');
61-
var { createHandler } = require('graphql-http/lib/use/express');
62-
var graphql = require('graphql');
60+
const express = require('express');
61+
const { createHandler } = require('graphql-http/lib/use/express');
62+
const graphql = require('graphql');
6363

6464
// Maps id to User object
65-
var fakeDatabase = {
65+
const fakeDatabase = {
6666
a: {
6767
id: 'a',
6868
name: 'alice',
@@ -74,7 +74,7 @@ var fakeDatabase = {
7474
};
7575

7676
// Define the User type
77-
var userType = new graphql.GraphQLObjectType({
77+
const userType = new graphql.GraphQLObjectType({
7878
name: 'User',
7979
fields: {
8080
id: { type: graphql.GraphQLString },
@@ -83,7 +83,7 @@ var userType = new graphql.GraphQLObjectType({
8383
});
8484

8585
// Define the Query type
86-
var queryType = new graphql.GraphQLObjectType({
86+
const queryType = new graphql.GraphQLObjectType({
8787
name: 'Query',
8888
fields: {
8989
user: {
@@ -99,9 +99,9 @@ var queryType = new graphql.GraphQLObjectType({
9999
},
100100
});
101101

102-
var schema = new graphql.GraphQLSchema({ query: queryType });
102+
const schema = new graphql.GraphQLSchema({ query: queryType });
103103

104-
var app = express();
104+
const app = express();
105105
app.all(
106106
'/graphql',
107107
createHandler({

website/pages/error.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GraphQL errors. You can import either from the `graphql/error` module, or from t
1111

1212
```js
1313
import { GraphQLError } from 'graphql'; // ES6
14-
var { GraphQLError } = require('graphql'); // CommonJS
14+
const { GraphQLError } = require('graphql'); // CommonJS
1515
```
1616

1717
## Overview

website/pages/execution.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fulfilling a GraphQL request. You can import either from the `graphql/execution`
1111

1212
```js
1313
import { execute } from 'graphql'; // ES6
14-
var { execute } = require('graphql'); // CommonJS
14+
const { execute } = require('graphql'); // CommonJS
1515
```
1616

1717
## Overview

website/pages/going-to-production.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Enabling Defer & Stream
2+
title: Going to Production
33
---
44

55
The `@defer` and `@stream` directives are not enabled by default. In order to use these directives, you must add them to your GraphQL Schema and use the `experimentalExecuteIncrementally` function instead of `execute`.

website/pages/graphql.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ of GraphQL type systems and servers.
1111

1212
```js
1313
import { graphql } from 'graphql'; // ES6
14-
var { graphql } = require('graphql'); // CommonJS
14+
const { graphql } = require('graphql'); // CommonJS
1515
```
1616

1717
## Overview
@@ -95,27 +95,27 @@ var { graphql } = require('graphql'); // CommonJS
9595
<ul className="apiIndex">
9696
<li>
9797
<a href="../type/#graphqlint">
98-
`var GraphQLInt` A scalar type representing integers.
98+
`const GraphQLInt` A scalar type representing integers.
9999
</a>
100100
</li>
101101
<li>
102102
<a href="../type/#graphqlfloat">
103-
`var GraphQLFloat` A scalar type representing floats.
103+
`const GraphQLFloat` A scalar type representing floats.
104104
</a>
105105
</li>
106106
<li>
107107
<a href="../type/#graphqlstring">
108-
`var GraphQLString` A scalar type representing strings.
108+
`const GraphQLString` A scalar type representing strings.
109109
</a>
110110
</li>
111111
<li>
112112
<a href="../type/#graphqlboolean">
113-
`var GraphQLBoolean` A scalar type representing booleans.
113+
`const GraphQLBoolean` A scalar type representing booleans.
114114
</a>
115115
</li>
116116
<li>
117117
<a href="../type/#graphqlid">
118-
`var GraphQLID` A scalar type representing IDs.
118+
`const GraphQLID` A scalar type representing IDs.
119119
</a>
120120
</li>
121121
</ul>

website/pages/language.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The `graphql/language` module is responsible for parsing and operating on the Gr
1010

1111
```js
1212
import { Source } from 'graphql'; // ES6
13-
var { Source } = require('graphql'); // CommonJS
13+
const { Source } = require('graphql'); // CommonJS
1414
```
1515

1616
## Overview
@@ -56,7 +56,7 @@ var { Source } = require('graphql'); // CommonJS
5656
</li>
5757
<li>
5858
<a href="#kind">
59-
`var Kind` Represents the various kinds of parsed AST nodes.
59+
`const Kind` Represents the various kinds of parsed AST nodes.
6060
</a>
6161
</li>
6262
</ul>
@@ -72,7 +72,7 @@ var { Source } = require('graphql'); // CommonJS
7272
</li>
7373
<li>
7474
<a href="#break">
75-
`var BREAK` A token to allow breaking out of the visitor.
75+
`const BREAK` A token to allow breaking out of the visitor.
7676
</a>
7777
</li>
7878
</ul>
@@ -198,7 +198,7 @@ a new version of the AST with the changes applied will be returned from the
198198
visit function.
199199

200200
```js
201-
var editedAST = visit(ast, {
201+
const editedAST = visit(ast, {
202202
enter(node, key, parent, path, ancestors) {
203203
// @return
204204
// undefined: no action

website/pages/mutations-and-input-types.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ It's often convenient to have a mutation that maps to a database create or updat
2121
Both mutations and queries can be handled by root resolvers, so the root that implements this schema can simply be:
2222

2323
```js
24-
var fakeDatabase = {};
25-
var root = {
24+
const fakeDatabase = {};
25+
const root = {
2626
setMessage({ message }) {
2727
fakeDatabase.message = message;
2828
return message;
@@ -68,12 +68,12 @@ Naming input types with `Input` on the end is a useful convention, because you w
6868
Here's some runnable code that implements this schema, keeping the data in memory:
6969

7070
```js
71-
var express = require('express');
72-
var { createHandler } = require('graphql-http/lib/use/express');
73-
var { buildSchema } = require('graphql');
71+
const express = require('express');
72+
const { createHandler } = require('graphql-http/lib/use/express');
73+
const { buildSchema } = require('graphql');
7474

7575
// Construct a schema, using GraphQL schema language
76-
var schema = buildSchema(/* GraphQL */ `
76+
const schema = buildSchema(/* GraphQL */ `
7777
input MessageInput {
7878
content: String
7979
author: String
@@ -105,9 +105,9 @@ class Message {
105105
}
106106

107107
// Maps username to content
108-
var fakeDatabase = {};
108+
const fakeDatabase = {};
109109

110-
var root = {
110+
const root = {
111111
getMessage({ id }) {
112112
if (!fakeDatabase[id]) {
113113
throw new Error('no message exists with id ' + id);
@@ -116,7 +116,7 @@ var root = {
116116
},
117117
createMessage({ input }) {
118118
// Create a random id for our "database".
119-
var id = require('crypto').randomBytes(10).toString('hex');
119+
const id = require('crypto').randomBytes(10).toString('hex');
120120

121121
fakeDatabase[id] = input;
122122
return new Message(id, input);
@@ -131,7 +131,7 @@ var root = {
131131
},
132132
};
133133

134-
var app = express();
134+
const app = express();
135135
app.all(
136136
'/graphql',
137137
createHandler({
@@ -157,9 +157,9 @@ mutation {
157157
You can use variables to simplify mutation client logic just like you can with queries. For example, some JavaScript code that calls the server to execute this mutation is:
158158

159159
```js
160-
var author = 'andy';
161-
var content = 'hope is a good thing';
162-
var query = /* GraphQL */ `
160+
const author = 'andy';
161+
const content = 'hope is a good thing';
162+
const query = /* GraphQL */ `
163163
mutation CreateMessage($input: MessageInput) {
164164
createMessage(input: $input) {
165165
id

0 commit comments

Comments
 (0)