feathers-graphql-mongoose v1.2.1
feathers-graphql-mongoose
⚡️ A Feathers, GraphQL and Mongoose Integration. Usage Example: https://github.com/hookcompany/feathers-graphql-boilerplate

Installation
Install with npm
$ npm install --save feathers-graphql-mongooseInstall with Yarn
$ yarn add feathers-graphql-mongooseUsage Example Project
https://github.com/hookcompany/feathers-graphql-boilerplate
Playground
PATH: /<basePath>/playground

GraphiQL
PATH: /<basePath>/graphiql

Voyager
PATH: /<basePath>/schema/[queries|mutations|subscriptions]

Querying
Support
Filter
eqgt && gtelt && lteinne && nenexists && notmodregexoptionssize
Sort
sort: ["name:desc", "createdAt:asc"]sort: "name:desc createdAt:asc"sort: { name: "desc", createdAt: "asc" }
Limit: Int
Skip: Int
Example

Example - Populate

Subscriptions
Default
create[Service]update[Service]remove[Service]
Example

Usage
# services/app1/users/types.gql
input UserFilter {
id: Any
name: Any
birth: Any
tags: Any
createdAt: Any
updatedAt: Any
}
input NewUserData {
name: String!
birth: Date!
tags: [String]
}
input EditUserData {
name: String
birth: Date
tags: [String]
}
input UserUpdateData {
set: EditUserData
push: [Any!]
pull: [Any!]
}
type UserQuery @query {
users(query: UserFilter, sort: Any, limit: Int, skip: Int): [User] @find
user(id: ID, query: UserFilter): User @get
}
type UserMutation @mutation {
createUser(data: NewUserData!): User @create
createUsers(data: [NewUserData!]!, sort: Any): [User] @create
updateUser(id: ID, query: UserFilter, data: UserUpdateData!): User @update
updateUsers(id: ID, query: UserFilter, data: UserUpdateData!, sort: Any): [User] @update
patchUser(id: ID, query: UserFilter, data: EditUserData!): User @patch
patchUsers(id: ID, query: UserFilter, data: EditUserData!, sort: Any): [User] @patch
removeUser(id: ID, query: UserFilter): User @remove
removeUsers(id: ID, query: UserFilter, sort: Any): [User] @remove
}
type UserSubscription @subscription {
createUser: [User] @create
updateUser: [User] @update
patchUser: [User] @patch
removeUser: [User] @remove
}// services/app1/users/index.js
import types from './types.gql';
import hooks from './hooks';
const User = {
types,
hooks,
modelName: 'User',
path: '/users',
filters: {
CREATED: (payload, args, context) => {
console.log('users created');
return true;
},
UPDATED: (payload, args, context) => {
console.log('users updated');
return true;
},
REMOVED: (payload, args, context) => {
console.log('users removed');
return true;
}
}
};
export default User;// services/app1/index.js
import Category from './categories';
import Product from './products';
import User from './users';
export default {
basePath: '/app1',
services: [User, Category, Product]
};// services/index.js
import feathersGraphQL from 'feathers-graphql-mongoose';
import models from 'models';
import app1 from './app1';
import app2 from './app2';
export default context => {
feathersGraphQL(models)(context)
.platform(app1)
.platform(app2)
.configure();
};Configuration
import mongoose from 'mongoose';
export default context => {
mongoose.connect(context.get('mongodb'));
mongoose.Promise = global.Promise;
context.set('mongooseClient', mongoose); // This line is mandatory.
};TODO
Queries
- Mongo Operators
- Sort
- Limit && Skip
- Populate && DeepPopulate
Mutations
Subscriptions
Mapping Types to Schema
Mapping Service
Playground
Graphiql
Voyager
Query Adapter Feathers
Memory
Nedb
Mongodb
Mongoose
Knex
Sequelize
Elasticsearch
Rethinkdb
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago

