This is a GraphQL Starter Pack for anyone looking to get a React/GraphQL/MongoDB proof of concept running quickly. In this example we will use books and authors.
Roadmap includes:
- Static type checking
- OAuth
- Redux
- Heroku and/or AWS integration with documentation
Based on iamshaunjp's graphql-playlist @ https://github.com/iamshaunjp/graphql-playlist
- React client side view for adding and viewing books
- Plug and play server set up for use with Mongo via mLab
- GraphQL query tool and queries to get started
http://localhost:4000/graphqlGraphQL Query Toolhttp://localhost:3000/Client Side Entry point
React, Express, GraphQL, MongoDB, Mongoose, Apollo, Lodash, Bootstrap, React-Router, dotenv, and CORS
git clone https://github.com/christopherrobin/GraphQL-Starter-Pack.gitcd GraphQL-Starter-Pack && cd client && npm install- Prepare your database
- Create a sandbox Mongo DB instance in mLab
- Insert database url/credentials into a
.envin the root of theserverfolder ex:DATABASEURL=mongodb://<dbuser>:<dbpassword>@ds233061.mlab.com:33061/<databasename> - Create an author: Customize the Add Author mutation from the Helpful Queries section and insert data into our database using the GraphQL Query Tool
- Continue to populate database with dummy data as you see fit
nodemon appfrom root of server foldernpm startfrom root of client folder
mutation {
addAuthor(name:"Author Name", age: 50){
name
age
}
}
mutation {
addBook(
name: "Book Title",
genre: "Genre",
authorId: "<authors id string from mongo db>"){
name
genre
}
}
{
author(id:2){
name
age
books{
name
genre
}
}
}