README
Mongo GraphQL
Mongo GraphQL is a package to very quickly start a GraphQL with Mongodb app. It directly uses mongoose as an ODM.
Example
const { App } = require("mongo-graphql")
new App({
architecture: {
[__dirname]: {
schemas: ["schemas"],
resolvers: {
"*.resolvers": ["resolvers"],
},
},
},
})
All your resolvers file must be named like this pattern
<type>.<name>.<extension>
examples:
query.users.js
query.user.js
mutation.newUser.js
mutation.newEvent.js
author.book
this will be set as a field resolver
Your architecture would look like this
with app.js
looking this this:
const { App } = require("mongo-graphql")
new App({
architecture: {
[__dirname]: {
schema: ["schemas"],
routes: {
"*.resolvers": ["resolvers"],
},
},
},
})
It's all you need to start a project!
You can still add configurations to it, but that is the minimal for it to start working!
You can make some quite complex architecture!
const { App } = require("mongo-graphql")
new App({
mongodb: "mongodb://localhost:27017/playground", // defaults to "mongodb://localhost:27017/app"
port: 5600, // defaults to 4500
debug: true, // defaults to false, it logs the found resolvers
architecture: {
[__dirname]: {
folders: {
what: {
schemas: ["schemas"],
},
},
controllers: {
"controller-*": ["resolvers"],
},
},
},
})
Try it out! 😎
npm install mongo-graphql