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: docs/source/tutorial/schema.md
+104Lines changed: 104 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,3 +124,107 @@ module.exports = typeDefs;
124
124
```
125
125
126
126
<h2id="apollo-server-run">Run your server</h2>
127
+
128
+
Now that we have scoped out our app's schema, let's run the server. Before running the server, make sure you have the following installed:
129
+
130
+
***Node.js and npm**: At least [Node.js v8.0 and npm v5](https://nodejs.org/en/download).
131
+
***nodemon**: Ensure that you have [nodemon](https://www.npmjs.com/package/nodemon) installed globally.
132
+
133
+
After that, create a directory and run `npm init --y` to create a `package.json` file. Within this directory, go ahead and create an `index.js` file. Now, add the code below to the file.
**Line 182 - 186** indicates the portion of the code that runs the GraphQL server. The `typeDefs` is passed to the `ApolloServer` constructor, then `ApolloServer`'s `listen()` method is invoked to run the server.
191
+
192
+
On your terminal, run:
193
+
194
+
```bash
195
+
nodemon index.js
196
+
```
197
+
198
+
Apollo Server will now be available on port 4000. By default, it supports [GraphQL Playground](https://www.apollographql.com/docs/apollo-server/features/graphql-playground.html). The Playground is an interactive, in-browser GraphQL IDE for testing your queries. Apollo Server automatically serves the GraphQL Playground GUI to web browsers in development. When `NODE_ENV` is set to production, GraphQL Playground is disabled as a production best-practice.
199
+
200
+
**Note:** By default, Apollo Server runs on port 4000. See the [API reference](https://www.apollographql.com/docs/apollo-server/v2/api/apollo-server.html) for additional listen options, including how to configure the port.
201
+
202
+
<divstyle="text-align:center">
203
+

204
+
<br></br>
205
+
</div>
206
+
207
+
Run a simple query like the one above. It will return null because the queries are not connected to any resolvers just yet.
208
+
209
+
The GraphQL Playground provides the ability to introspect your schemas. Check out the right hand side of the playground and click on the `schema` button.
210
+
211
+
<divstyle="text-align:center">
212
+

213
+
<br></br>
214
+
</div>
215
+
216
+
The schema types are shown like you have below:
217
+
218
+
<divstyle="text-align:center">
219
+

220
+
<br></br>
221
+
</div>
222
+
223
+
You can quickly have access to the documentation of a GraphQL API via the `schema` button.
224
+
225
+
<divstyle="text-align:center">
226
+

227
+
<br></br>
228
+
</div>
229
+
230
+
That's all for running Apollo Server for now. Let's move on to the next part of our tutorial.
0 commit comments