This is a very simple node demo for graphQL
based on a frequently used author/books example. Since authors are writing books this example shows a one to many relationship.
The demo contains three apps:
app.js
contains queries for authors, books, author by id, and book by idapp1.js
adding lazy resolver forAuthor.books
app2.js
adding mutation to create a new author and add a book to an author
- Copy all the files to your local machine.
- Open a terminal and
cd
into the target folder of your copy - Run
npm install
- Edit the file
package.json
and change the"main"
property toapp.js
,app1.js
orapp2.js
- Run
npm start
- Open browser at (http://localhost:4000/graphql)
- Enter query like
{
authors {
id
name
books {
title
}
}
}
- Martin Kühne - graphql-quick-start
This project is licensed under the MIT License - see the LICENSE file for details