1.0.6 • Published 8 years ago

graphql-mongo-fields v1.0.6

Weekly downloads
17
License
ISC
Repository
github
Last release
8 years ago

GraphQL Mongo Fields

npm.io

Convert a GraphlQL fields in a MongoDB select string.

https://nodei.co/npm/graphql-mongo-fields.png?downloads=true&downloadRank=true&stars=true

Example

Consider the following query:

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'

Usage

const parseFields = require('graphql-mongo-fields')

// my awesome handler
const handler = async (_, args, context, info) => {

    users = await models.User.find({}, parseFields(info))

    return users
}

Development

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

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago