Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxpou/graphql-nodejs-mongodb
POC with GraphQL, NodeJS and MongoDB
https://github.com/maxpou/graphql-nodejs-mongodb
beer graphql mongodb nodejs
Last synced: 4 days ago
JSON representation
POC with GraphQL, NodeJS and MongoDB
- Host: GitHub
- URL: https://github.com/maxpou/graphql-nodejs-mongodb
- Owner: maxpou
- License: mit
- Created: 2016-10-22T19:23:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-27T14:06:51.000Z (about 8 years ago)
- Last Synced: 2024-04-14T04:48:34.533Z (7 months ago)
- Topics: beer, graphql, mongodb, nodejs
- Language: JavaScript
- Homepage:
- Size: 50.8 KB
- Stars: 5
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL, NodeJS and MongoDB
[![Build Status](https://travis-ci.org/maxpou/graphql-nodejs-mongodb.svg?branch=master)](https://travis-ci.org/maxpou/graphql-nodejs-mongodb)
[![Coverage Status](https://coveralls.io/repos/github/maxpou/graphql-nodejs-mongodb/badge.svg?branch=master)](https://coveralls.io/github/maxpou/graphql-nodejs-mongodb?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/maxpou/graphql-nodejs-mongodb/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maxpou/graphql-nodejs-mongodb/?branch=master)GraphQL server in Node.js using Express, MongoDB (and Mongoose).
Forked from: https://github.com/bruno12mota/graphql-nodejs. Many thanks to him :)## Installation&running
1. Install dependencies
```sh
npm install
```2. Populate MongoDB database
```sh
mongoimport --db graphql --collection beers --jsonArray data.json
```3. Running: `npm start`
4. Go to [http://localhost:4000/graphql](http://localhost:4000/graphql) with your browser## Requests sample
### Queries
* List all beers:
```
{
beers {
name
alcohol
description
}
}
```* List all beers + filtering/sorting
```
{
beers(brewery: "Duvel", orderBy: ALCOHOL) {
name
alcohol
}
}
```* List all beers + brewery subresource
```
{
beers {
name
brewery {
name
location
}
}
}
```* List one specific beer:
```
{
beer(id: "") {
name
}
}
```* List all breweries:
```
{
breweries {
name
location
}
}
```### Mutations
* Adding a new beer:
```
mutation {
addBeer(data: {name: "Delirium Tremens", brewery: "Huyghe Brewery", alcohol: 8.5})
}
```* Remove a specific beers
```
mutation {
removeBeer(_id: "") {
name
}
}
```* Remove all beers
```
mutation {
removeAllBeers
}
```## Tests
Run tests with: `npm test` and tests + code coverage with `npm run coverage`.
More informations about [Chai.js Assertion Library](http://chaijs.com/).