Skip to content
Example GraphQL server with Mongoose (MongoDB) and Node.js
Branch: master
Clone or download
Pull request Compare This branch is even with uniiverse:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.jshintrc
.nvmrc
AUTHORS
README.md
package.json

README.md

graphql-server

GraphQL server with Mongoose (MongoDB) and Node.js

For use with Universe's MongoDB as a read-only database.

Models available:

  • Listing
  • TODO: Event
  • TODO: Rate
  • TODO: Capacity
  • TODO: Category
  • TODO: Event Photos / Images

Installation

You need iojs or >= Node.js v0.12.x

Tested with NodeJS 4.2 (it's what we use internally at Universe for other projects).

npm install

Usage

Starting the server

npm start
PORT=2323 npm start

Starting the client to test the server

npm run client
PORT=2323 npm run client

Examples

Example GraphQL query

user(id: "1") {
  name
  friends {
    name
  }
}

Example response

{
  "data": {
    "user": {
      "name": "John Doe",
      "friends": [
        {
          "name": "Friend One"
        },
        {
          "name": "Friend Two"
        }]
      }
    }
  }

Example GraphQL mutation

mutation updateUser($userId: String! $name: String!) {
  updateUser(id: $userId name: $name) {
    name
  }
}

References

You can’t perform that action at this time.