Skip to content

Commit 00d1968

Browse files
authored
Update GraphQL server setup instructions
Added instructions for setting 'type' in package.json and using the ruru module for GraphiQL.
1 parent fecef8b commit 00d1968

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/pages/graphql-js/running-an-express-graphql-server.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ app.listen(4000, () => {
4747
});
4848
```
4949

50+
Also, check your `package.json` file and ensure that `type` is set to `module`:
51+
52+
```json
53+
{
54+
"type": "module",
55+
}
56+
```
57+
5058
You can run this GraphQL server with:
5159

5260
```sh
@@ -59,7 +67,7 @@ At this point you will have a running GraphQL API; but you can't just visit it i
5967

6068
[GraphiQL](https://github.com/graphql/graphiql) is GraphQL's IDE; a great way of querying and exploring your GraphQL API.
6169
One easy way to add it to your server is via the MIT-licensed [ruru](https://github.com/graphile/crystal/blob/main/grafast/ruru/README.md) package which bundles a prebuilt GraphiQL with some popular enhancements.
62-
To do so, install the `ruru` module with `npm install --save ruru` and then add the following to your `server.js` file, then restart the `node server.js` command:
70+
To do so, install the `ruru` module with `npm install --save ruru` and then add the following to your `server.js` file:
6371

6472
```js
6573
import { ruruHTML } from "ruru/server";
@@ -71,6 +79,8 @@ app.get("/", (_req, res) => {
7179
});
7280
```
7381

82+
Now restart the `node server.js` command.
83+
7484
If you navigate to [http://localhost:4000](http://localhost:4000), you should see an interface that lets you enter queries;
7585
now you can use the GraphiQL IDE tool to issue GraphQL queries directly in the browser.
7686

0 commit comments

Comments
 (0)