https://github.com/nattatorn-dev/graphql-mongodb-advance
This is a basic backend boilerplate for setting up a graphql server with mongodb and express.
https://github.com/nattatorn-dev/graphql-mongodb-advance
backend es7 express graphql mongodb mongoose node seeding
Last synced: about 2 months ago
JSON representation
This is a basic backend boilerplate for setting up a graphql server with mongodb and express.
- Host: GitHub
- URL: https://github.com/nattatorn-dev/graphql-mongodb-advance
- Owner: nattatorn-dev
- Created: 2017-05-23T09:13:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-23T15:24:41.000Z (almost 8 years ago)
- Last Synced: 2025-03-29T05:38:06.215Z (about 2 months ago)
- Topics: backend, es7, express, graphql, mongodb, mongoose, node, seeding
- Language: JavaScript
- Size: 69.3 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-mongodb-backend-example
This is a basic backend boilerplate for setting up a graphql server with mongodb and express.
## installation
```
npm install
``````
npm start
```## GraphQL
go to http://localhost:8080/graphql to work with the graphqil to make queries
from schema.js
root query is:```Javascript
export var Schema = new GraphQLSchema({
query: QueryType,
});
```
QueryType has these fields that can be queried on: in types/query.js
- node
- users : retrieves all users
- user(id) : retrieves user by id
- posts : retrieves all posts
- post(id) : retrieves post by id
- comments : retrieves all comments
- comment(id) : retrieves all comments by idgraphiql queries look like this:

## Database
### Models
- user
- post
- commentExample schema in [model].js
```Javascript
import mongoose from 'mongoose';let newModelSchema = new mongoose.Schema({
_id: {
type: String,
required: true,
default: mongoose.Types.ObjectId,
content: {
type: String,
},
createdAt: {
type: Date,
default: Date.now,
},
//add in field for graphql type
type: {
type: String,
}
})export default mongoose.model('User', UserSchema);