Skip to content

Commit 39ac537

Browse files
committed
Thanks prettier
1 parent 4af2c5d commit 39ac537

8 files changed

+199
-201
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ const { buildSchema } = require('graphql');
2121
const schema = buildSchema(` type Query { ip: String }`);
2222

2323
function loggingMiddleware(req, res, next) {
24-
console.log('ip:', req.ip);
25-
next();
24+
console.log('ip:', req.ip);
25+
next();
2626
}
2727

2828
const root = {
29-
ip(args, context) {
30-
return context.ip;
31-
},
29+
ip(args, context) {
30+
return context.ip;
31+
},
3232
};
3333

3434
const app = express();
3535
app.use(loggingMiddleware);
3636
app.all(
37-
'/graphql',
38-
createHandler({
39-
schema: schema,
40-
rootValue: root,
41-
context: (req) => ({
42-
ip: req.raw.ip,
43-
}),
44-
}),
37+
'/graphql',
38+
createHandler({
39+
schema: schema,
40+
rootValue: root,
41+
context: (req) => ({
42+
ip: req.raw.ip,
43+
}),
44+
}),
4545
);
4646
app.listen(4000);
4747
console.log('Running a GraphQL API server at localhost:4000/graphql');

website/pages/basic-types.mdx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ const schema = buildSchema(` type Query { quoteOfTheDay: String random: Float! r
2626

2727
// The root provides a resolver function for each API endpoint
2828
const root = {
29-
quoteOfTheDay() {
30-
return Math.random() < 0.5 ? 'Take it easy' : 'Salvation lies within';
31-
},
32-
random() {
33-
return Math.random();
34-
},
35-
rollThreeDice() {
36-
return [1, 2, 3].map((\_) => 1 + Math.floor(Math.random() \* 6));
37-
},
29+
quoteOfTheDay() {
30+
return Math.random() < 0.5 ? 'Take it easy' : 'Salvation lies within';
31+
},
32+
random() {
33+
return Math.random();
34+
},
35+
rollThreeDice() {
36+
return [1, 2, 3].map((\_) => 1 + Math.floor(Math.random() \* 6));
37+
},
3838
};
3939

4040
const app = express();
4141
app.all(
42-
'/graphql',
43-
createHandler({
44-
schema: schema,
45-
rootValue: root,
46-
}),
42+
'/graphql',
43+
createHandler({
44+
schema: schema,
45+
rootValue: root,
46+
}),
4747
);
4848
app.listen(4000);
4949
console.log('Running a GraphQL API server at localhost:4000/graphql');

website/pages/constructing-types.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,40 @@ const { buildSchema } = require('graphql');
1919

2020
const schema = buildSchema(`
2121
type User {
22-
id: String
23-
name: String
22+
id: String
23+
name: String
2424
}
2525
2626
type Query {
27-
user(id: String): User
27+
user(id: String): User
2828
}
2929
`);
3030

3131
// Maps id to User object
3232
const fakeDatabase = {
33-
a: {
34-
id: 'a',
35-
name: 'alice',
36-
},
37-
b: {
38-
id: 'b',
39-
name: 'bob',
40-
},
33+
a: {
34+
id: 'a',
35+
name: 'alice',
36+
},
37+
b: {
38+
id: 'b',
39+
name: 'bob',
40+
},
4141
};
4242

4343
const root = {
44-
user({ id }) {
45-
return fakeDatabase[id];
46-
},
44+
user({ id }) {
45+
return fakeDatabase[id];
46+
},
4747
};
4848

4949
const app = express();
5050
app.all(
51-
'/graphql',
52-
createHandler({
53-
schema: schema,
54-
rootValue: root,
55-
}),
51+
'/graphql',
52+
createHandler({
53+
schema: schema,
54+
rootValue: root,
55+
}),
5656
);
5757
app.listen(4000);
5858
console.log('Running a GraphQL API server at localhost:4000/graphql');

website/pages/getting-started.mdx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ const schema = buildSchema(`type Query { hello: String } `);
4040

4141
// The rootValue provides a resolver function for each API endpoint
4242
const rootValue = {
43-
hello() {
44-
return 'Hello world!';
45-
},
43+
hello() {
44+
return 'Hello world!';
45+
},
4646
};
4747

4848
// Run the GraphQL query '{ hello }' and print out the response
4949
graphql({
50-
schema,
51-
source: '{ hello }',
52-
rootValue,
53-
}).then((response) => {
54-
console.log(response);
50+
schema,
51+
source: '{ hello }',
52+
rootValue,
53+
}).then((response) => {
54+
console.log(response);
55+
});
5556
});
5657

5758
````

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

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ type Mutation {
1616
}
1717

1818
type Query {
19-
getMessage: String
19+
getMessage: String
2020
}
21-
2221
````
2322
</Tabs.Tab>
2423
<Tabs.Tab>
@@ -78,18 +77,18 @@ input MessageInput {
7877
}
7978

8079
type Message {
81-
id: ID!
82-
content: String
83-
author: String
80+
id: ID!
81+
content: String
82+
author: String
8483
}
8584

8685
type Query {
87-
getMessage(id: ID!): Message
86+
getMessage(id: ID!): Message
8887
}
8988

9089
type Mutation {
91-
createMessage(input: MessageInput): Message
92-
updateMessage(id: ID!, input: MessageInput): Message
90+
createMessage(input: MessageInput): Message
91+
updateMessage(id: ID!, input: MessageInput): Message
9392
}
9493

9594
````
@@ -174,72 +173,71 @@ const { createHandler } = require('graphql-http/lib/use/express');
174173
const { buildSchema } = require('graphql');
175174

176175
// Construct a schema, using GraphQL schema language
177-
const schema = buildSchema(/_ GraphQL _/ `
176+
const schema = buildSchema(`
178177
input MessageInput {
179-
content: String
180-
author: String
178+
content: String
179+
author: String
181180
}
182181

183182
type Message {
184-
id: ID!
185-
content: String
186-
author: String
183+
id: ID!
184+
content: String
185+
author: String
187186
}
188187

189188
type Query {
190-
getMessage(id: ID!): Message
189+
getMessage(id: ID!): Message
191190
}
192191

193192
type Mutation {
194-
createMessage(input: MessageInput): Message
195-
updateMessage(id: ID!, input: MessageInput): Message
193+
createMessage(input: MessageInput): Message
194+
updateMessage(id: ID!, input: MessageInput): Message
196195
}
197196
`);
198197

199198
// If Message had any complex fields, we'd put them on this object.
200199
class Message {
201-
constructor(id, { content, author }) {
202-
this.id = id;
203-
this.content = content;
204-
this.author = author;
205-
}
200+
constructor(id, { content, author }) {
201+
this.id = id;
202+
this.content = content;
203+
this.author = author;
204+
}
206205
}
207206

208207
// Maps username to content
209208
const fakeDatabase = {};
210209

211210
const root = {
212-
getMessage({ id }) {
213-
if (!fakeDatabase[id]) {
214-
throw new Error('no message exists with id ' + id);
215-
}
216-
return new Message(id, fakeDatabase[id]);
217-
},
218-
createMessage({ input }) {
219-
// Create a random id for our "database".
220-
const id = require('crypto').randomBytes(10).toString('hex');
211+
getMessage({ id }) {
212+
if (!fakeDatabase[id]) {
213+
throw new Error('no message exists with id ' + id);
214+
}
215+
return new Message(id, fakeDatabase[id]);
216+
},
217+
createMessage({ input }) {
218+
// Create a random id for our "database".
219+
const id = require('crypto').randomBytes(10).toString('hex');
221220

222221
fakeDatabase[id] = input;
223222
return new Message(id, input);
224-
225-
},
226-
updateMessage({ id, input }) {
227-
if (!fakeDatabase[id]) {
228-
throw new Error('no message exists with id ' + id);
229-
}
230-
// This replaces all old data, but some apps might want partial update.
231-
fakeDatabase[id] = input;
232-
return new Message(id, input);
233-
},
223+
},
224+
updateMessage({ id, input }) {
225+
if (!fakeDatabase[id]) {
226+
throw new Error('no message exists with id ' + id);
227+
}
228+
// This replaces all old data, but some apps might want partial update.
229+
fakeDatabase[id] = input;
230+
return new Message(id, input);
231+
},
234232
};
235233

236234
const app = express();
237235
app.all(
238-
'/graphql',
239-
createHandler({
240-
schema: schema,
241-
rootValue: root,
242-
}),
236+
'/graphql',
237+
createHandler({
238+
schema: schema,
239+
rootValue: root,
240+
}),
243241
);
244242
app.listen(4000, () => {
245243
console.log('Running a GraphQL API server at localhost:4000/graphql');

0 commit comments

Comments
 (0)