Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/radiegtya/graphql-server-mongoose
https://github.com/radiegtya/graphql-server-mongoose
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/radiegtya/graphql-server-mongoose
- Owner: radiegtya
- License: mit
- Created: 2016-12-25T06:32:03.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-25T15:38:49.000Z (about 8 years ago)
- Last Synced: 2024-11-02T20:42:06.802Z (about 2 months ago)
- Language: JavaScript
- Size: 43 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-tools Mongoose Server
The server that is updated from the examples on dev.apollodata.com.
In this server we aren't using dev.apollodata.com client anymore, because
this server only for example when using mongoose as connector.This server are using graphql-tools (https://github.com/apollostack/graphql-tools) to serve a simple schema.
## Installation
Clone the repository and run `npm install`
```
git clone https://github.com/radiegtya/graphql-server-mongoose
cd graphql-server-mongoose
npm installstart your own Mongodb server
change connection on server.js toconst MONGO_URL = "mongodb://your-mongodb-server:port/db";
```## Starting the server
```
npm start
```The server will run on port 8080. You can change this by editing `server.js`.
To test graphiql, you can use http://localhost:8080/graphiql.## Quick Start
This server created to be as similar as possible with METEOR API.
1. Query
Examples:
get all book without parameter
```
query {
books{
title
}
}
```get all books with parameter
```
#queryquery ($query: QueryInput){
books (query: $query){
title
author {
name
}
}
}#variables
{
"query": {
"selector": {
"title": {"$regex": "the", "$options": "i"}
},
"options": {
"sort": {"title": -1},
"limit": 2,
"skip": 0
}
}
}```
you can fill selector and options using standard mongoDB criteria or refer to this page http://docs.meteor.com/api/collections.html#selectorscreate book
```
#querymutation ($doc: BookDocInput!){
createBook (doc: $doc){
title
}
}#variables
{
"doc": {
"title": "The Legend of Om telolet Om"
}
}
```update book
```
#querymutation ($query: QueryInput!, $doc: BookDocInput!){
updateBook(query: $query, doc: $doc){
title
}
}#variables
{
"query": {
"selector": {
"_id": "585fe5883529cc2df224c1c5"
}
},
"doc": {
"title": "The Legend of Om Telolet Om Chapter 2"
}
}
```