Skip to content

Commit a8f73db

Browse files
Update prettier (#2499)
1 parent c155ae0 commit a8f73db

File tree

90 files changed

+11147
-3929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+11147
-3929
lines changed

.prettierrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"singleQuote": true,
3-
"trailingComma": "all",
4-
"endOfLine": "lf"
3+
"trailingComma": "all"
54
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Then, serve the result of a query against that type schema.
7474
```js
7575
var query = '{ hello }';
7676

77-
graphql(schema, query).then(result => {
77+
graphql(schema, query).then((result) => {
7878
// Prints
7979
// {
8080
// data: { hello: "world" }
@@ -90,7 +90,7 @@ it, reporting errors otherwise.
9090
```js
9191
var query = '{ BoyHowdy }';
9292

93-
graphql(schema, query).then(result => {
93+
graphql(schema, query).then((result) => {
9494
// Prints
9595
// {
9696
// errors: [

docs/Guides-ConstructingTypes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var fakeDatabase = {
4141
};
4242

4343
var root = {
44-
user: function({ id }) {
44+
user: function ({ id }) {
4545
return fakeDatabase[id];
4646
},
4747
};
@@ -98,7 +98,7 @@ var queryType = new graphql.GraphQLObjectType({
9898
args: {
9999
id: { type: graphql.GraphQLString },
100100
},
101-
resolve: function(_, { id }) {
101+
resolve: function (_, { id }) {
102102
return fakeDatabase[id];
103103
},
104104
},

docs/Tutorial-Authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function loggingMiddleware(req, res, next) {
3030
}
3131

3232
var root = {
33-
ip: function(args, request) {
33+
ip: function (args, request) {
3434
return request.ip;
3535
},
3636
};

docs/Tutorial-BasicTypes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var root = {
3939
return Math.random();
4040
},
4141
rollThreeDice: () => {
42-
return [1, 2, 3].map(_ => 1 + Math.floor(Math.random() * 6));
42+
return [1, 2, 3].map((_) => 1 + Math.floor(Math.random() * 6));
4343
},
4444
};
4545

docs/Tutorial-GettingStarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var root = {
4040
};
4141

4242
// Run the GraphQL query '{ hello }' and print out the response
43-
graphql(schema, '{ hello }', root).then(response => {
43+
graphql(schema, '{ hello }', root).then((response) => {
4444
console.log(response);
4545
});
4646
```

docs/Tutorial-GraphQLClients.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ fetch('/graphql', {
3636
},
3737
body: JSON.stringify({ query: '{ hello }' }),
3838
})
39-
.then(r => r.json())
40-
.then(data => console.log('data returned:', data));
39+
.then((r) => r.json())
40+
.then((data) => console.log('data returned:', data));
4141
```
4242

4343
You should see the data returned, logged in the console:
@@ -76,8 +76,8 @@ fetch('/graphql', {
7676
variables: { dice, sides },
7777
}),
7878
})
79-
.then(r => r.json())
80-
.then(data => console.log('data returned:', data));
79+
.then((r) => r.json())
80+
.then((data) => console.log('data returned:', data));
8181
```
8282

8383
Using this syntax for variables is a good idea because it automatically prevents bugs due to escaping, and it makes it easier to monitor your server.

docs/Tutorial-Mutations.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Both mutations and queries can be handled by root resolvers, so the root that im
2727
```js
2828
var fakeDatabase = {};
2929
var root = {
30-
setMessage: function({ message }) {
30+
setMessage: function ({ message }) {
3131
fakeDatabase.message = message;
3232
return message;
3333
},
34-
getMessage: function() {
34+
getMessage: function () {
3535
return fakeDatabase.message;
3636
},
3737
};
@@ -112,22 +112,20 @@ class Message {
112112
var fakeDatabase = {};
113113

114114
var root = {
115-
getMessage: function({ id }) {
115+
getMessage: function ({ id }) {
116116
if (!fakeDatabase[id]) {
117117
throw new Error('no message exists with id ' + id);
118118
}
119119
return new Message(id, fakeDatabase[id]);
120120
},
121-
createMessage: function({ input }) {
121+
createMessage: function ({ input }) {
122122
// Create a random id for our "database".
123-
var id = require('crypto')
124-
.randomBytes(10)
125-
.toString('hex');
123+
var id = require('crypto').randomBytes(10).toString('hex');
126124

127125
fakeDatabase[id] = input;
128126
return new Message(id, input);
129127
},
130-
updateMessage: function({ id, input }) {
128+
updateMessage: function ({ id, input }) {
131129
if (!fakeDatabase[id]) {
132130
throw new Error('no message exists with id ' + id);
133131
}
@@ -188,8 +186,8 @@ fetch('/graphql', {
188186
},
189187
}),
190188
})
191-
.then(r => r.json())
192-
.then(data => console.log('data returned:', data));
189+
.then((r) => r.json())
190+
.then((data) => console.log('data returned:', data));
193191
```
194192

195193
One particular type of mutation is operations that change users, like signing up a new user. While you can implement this using GraphQL mutations, you can reuse many existing libraries if you learn about [GraphQL with authentication and Express middleware](/graphql-js/authentication-and-express-middleware/).

docs/Tutorial-ObjectTypes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class RandomDie {
5050
}
5151

5252
var root = {
53-
getDie: function({ numSides }) {
53+
getDie: function ({ numSides }) {
5454
return new RandomDie(numSides || 6);
5555
},
5656
};
@@ -111,7 +111,7 @@ class RandomDie {
111111

112112
// The root provides the top-level API endpoints
113113
var root = {
114-
getDie: function({ numSides }) {
114+
getDie: function ({ numSides }) {
115115
return new RandomDie(numSides || 6);
116116
},
117117
};

docs/Tutorial-PassingArguments.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ So far, our resolver functions took no arguments. When a resolver takes argument
2828

2929
```js
3030
var root = {
31-
rollDice: function(args) {
31+
rollDice: function (args) {
3232
var output = [];
3333
for (var i = 0; i < args.numDice; i++) {
3434
output.push(1 + Math.floor(Math.random() * (args.numSides || 6)));
@@ -42,7 +42,7 @@ It's convenient to use [ES6 destructuring assignment](https://developer.mozilla.
4242

4343
```js
4444
var root = {
45-
rollDice: function({ numDice, numSides }) {
45+
rollDice: function ({ numDice, numSides }) {
4646
var output = [];
4747
for (var i = 0; i < numDice; i++) {
4848
output.push(1 + Math.floor(Math.random() * (numSides || 6)));
@@ -70,7 +70,7 @@ var schema = buildSchema(`
7070

7171
// The root provides a resolver function for each API endpoint
7272
var root = {
73-
rollDice: function({ numDice, numSides }) {
73+
rollDice: function ({ numDice, numSides }) {
7474
var output = [];
7575
for (var i = 0; i < numDice; i++) {
7676
output.push(1 + Math.floor(Math.random() * (numSides || 6)));
@@ -125,8 +125,8 @@ fetch('/graphql', {
125125
variables: { dice, sides },
126126
}),
127127
})
128-
.then(r => r.json())
129-
.then(data => console.log('data returned:', data));
128+
.then((r) => r.json())
129+
.then((data) => console.log('data returned:', data));
130130
```
131131

132132
Using `$dice` and `$sides` as variables in GraphQL means we don't have to worry about escaping on the client side.

0 commit comments

Comments
 (0)