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: website/pages/authentication-and-express-middleware.mdx
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,37 +11,37 @@ To use middleware with a GraphQL resolver, just use the middleware like you woul
11
11
12
12
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:
Copy file name to clipboardExpand all lines: website/pages/basic-types.mdx
+22-16Lines changed: 22 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,36 +14,42 @@ To use a list type, surround the type in square brackets, so `[Int]` is a list o
14
14
15
15
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:
Copy file name to clipboardExpand all lines: website/pages/constructing-types.mdx
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ When you are using the `GraphQLSchema` constructor to create a schema, instead o
10
10
11
11
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:
Copy file name to clipboardExpand all lines: website/pages/getting-started.mdx
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ npm install graphql --save
30
30
31
31
To handle GraphQL queries, we need a schema that defines the `Query` type, and we need an API root with a function called a “resolver” for each API endpoint. For an API that just returns “Hello world!”, we can put this code in a file named `server.js`:
Copy file name to clipboardExpand all lines: website/pages/mutations-and-input-types.mdx
+47-49Lines changed: 47 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,17 +8,16 @@ If you have an API endpoint that alters data, like inserting data into a databas
8
8
9
9
Let's say we have a “message of the day” server, where anyone can update the message of the day, and anyone can read the current one. The GraphQL schema for this is simply:
10
10
11
-
<Tabsitems={['Template', 'Classes']}>
11
+
<Tabsitems={['SDL', 'Code']}>
12
12
<Tabs.Tab>
13
13
```graphql
14
14
typeMutation {
15
15
setMessage(message: String): String
16
16
}
17
17
18
18
typeQuery {
19
-
getMessage: String
19
+
getMessage: String
20
20
}
21
-
22
21
````
23
22
</Tabs.Tab>
24
23
<Tabs.Tab>
@@ -69,7 +68,7 @@ You don't need anything more than this to implement mutations. But in many cases
69
68
70
69
For example, instead of a single message of the day, let's say we have many messages, indexed in a database by the `id` field, and each message has both a `content` string and an `author` string. We want a mutation API both for creating a new message and for updating an old message. We could use the schema:
0 commit comments