Skip to content
This repository was archived by the owner on Aug 24, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
[
"@babel/preset-env",
{
"targets": { "node": "current" },
"modules": "commonjs",
"useBuiltIns": "usage",
"debug": true
"targets": {
"node": "current"
},
"modules": "commonjs"
}
]
]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ To get the app up and running (and really see if it worked), run:

```
$ npm start
$ open http://localhost:4000
$ open http://localhost:4000/graphql
```

`npm start` will start the API server. Your browser should open up automatically to `http://localhost:4000` (if it doesn't, just open that yourself) and you should be able to start messing around with the app.
`npm start` will start the API server. Your browser should open up automatically to `http://localhost:4000/graphql` (if it doesn't, just open that yourself) and you should be able to start messing around with the app.

Here's what you should be looking at:

<img width="800" alt="screen shot 2018-05-09 at 23 12 38" src="https://user-images.githubusercontent.com/742884/46708817-7aa72300-cbf5-11e8-8851-159d991cd537.png">

GraphQL Playground is a great tool for writing and testing out queries. GraphQL Playground has some docs to explore on the right panel and offers an auto-complete-as-you-type experience. This is what GraphQL is all about, the developer experience! :-)
GraphiQL is a great tool for writing and testing out queries. GraphiQL has some docs to explore on the right panel and offers an auto-complete-as-you-type experience. This is what GraphQL is all about, the developer experience! :-)

[npm]: https://www.npmjs.com/
[node]: https://nodejs.org
Expand Down
21 changes: 15 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// "graphql-yoga" is a pretty neat package 📦 for getting started w/ GraphQL quickly.
// It's built on top of apollo-server (or Express) w/ some nice defaults.
// It will include an IDE called GraphQL Playground for testing queries.
// To read more about it, see https://github.com/prisma/graphql-yoga
// It's a spec-compliant GraphQL server w/ some nice defaults.
// It includes an IDE called GraphiQL for testing queries.
// To read more about it, see https://the-guild.dev/graphql/yoga-server
// ⚡
const { GraphQLServer } = require('graphql-yoga');
const { createYoga, createSchema } = require('graphql-yoga');
const { createServer } = require('node:http');

// "typeDefs" is your GraphQL schema.
//
Expand Down Expand Up @@ -53,7 +54,15 @@ const resolvers = {
// resolver functions. This gets interesting when you can fetch schemas
// remotely, mutate them, and pass them off to your server.
// Google "GraphQL schema stitching" if you're interested.
const server = new GraphQLServer({ typeDefs, resolvers });
//
// `createSchema` combines the typeDefs and resolvers into an executable
// schema, and `createYoga` wraps it in a request handler.
const yoga = createYoga({ schema: createSchema({ typeDefs, resolvers }) });

// Yoga is just a plain Node request handler, so any HTTP server can serve it.
const server = createServer(yoga);

// Hello world!
server.start(() => console.log('Server is running on localhost:4000'));
server.listen(4000, () =>
console.log('Server is running on http://localhost:4000/graphql')
);