A graphql fields parser to use as mongo select()
npm install graphql-mongo-fields
Convert a GraphlQL fields in a MongoDB select string.

``js`
query {
foo {
bar {
foo
}
}
}
This module transforms the GraphQL fields into a string to select fields in MongoDB. The output will be:
``
'foo.bar.foo = 1'
`js
const parseFields = require('graphql-mongo-fields')
// my awesome handler
const handler = async (_, args, context, info) => {
users = await models.User.find({}, parseFields(info))
return users
}
`
You can use docker to develop in this project. If you run the bin/run_dev command you'll enter in a Docker container with the node:wheezy image and volumes mounted in /opt/app. Then is just start to coding :)
Don't forget to put the tests in the test/ folder and run typing npm run test`.
_Feel free to contribute_ ❤