项目作者: pt-br

项目描述 :
A GraphQL boilerplate. Compatible with fake data and MongoDB.
高级语言: JavaScript
项目地址: git://github.com/pt-br/GraphQL-Server.git
创建时间: 2016-09-08T03:09:15Z
项目社区:https://github.com/pt-br/GraphQL-Server

开源协议:MIT License

下载


GraphQL-Server

This is a GraphQL server built with Apollo Server and a MongoDB database for reference.

You can combine this boilerplate with my apollo boilerplate.

MongoDB schema

In case you want to run this right after cloning, make sure to config your database credentials under /mongoose/ and replicate the following DB configs:

  • Database name: graphql
  • Collection name: phones
  • Collection structure:
  1. {
  2. "_id" : ObjectId("5a80bd36d5a72461d1b1bf1b"),
  3. "image" : "https://goo.gl/uanrHM",
  4. "model" : "Galaxy S7"
  5. }

Playground queries/mutations examples:

Fetch Phones

  1. {
  2. phones {
  3. id
  4. model
  5. image
  6. }
  7. }

Fetch Phones by ID

  1. {
  2. phones(id: "5a80bd36d5a72461d1b1bf1b") {
  3. id
  4. model
  5. image
  6. }
  7. }

Add a new Phone

  1. mutation {
  2. addPhone(model: "iPhone 6", image: "https://goo.gl/ndJdW9") {
  3. model
  4. id
  5. image
  6. }
  7. }

Update an existing Phone

  1. mutation {
  2. updatePhone(id: "5b691e72981cb265298a4ed2", model: "iPhone X", image: "https://img.ibxk.com.br/2017/09/12/12174513097144.jpg") {
  3. id
  4. image
  5. model
  6. }
  7. }

Remove a Phone

  1. mutation {
  2. removePhone(id: "5b691e72981cb265298a4ed2") {
  3. id
  4. image
  5. model
  6. }
  7. }