-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
If you are using mongodb version >= 3, then you need to tweak this section a little bit:
/index.js
MongoClient.connect(MONGO_URL, (err, client) => {
assert.equal(null, err)
console.log('Connection Approved')
const collection = client.db('test').collection('users')
const rli = readline.createInterface({
input: process.stdin,
output: process.stdout
})
rli.question('Client Request: ', inputQuery => {
graphql(schema, inputQuery, {}, { collection })
.then(result => {
console.log('Server Response: ', result.data)
client.close(() => rli.close())
})
})
})
/schema/main.js
usersCount: {
type: GraphQLInt,
resolve: (_, args, { collection }) => collection.count()
}
Reference this: https://stackoverflow.com/a/47694265/8876839
gerpollo2000
Metadata
Metadata
Assignees
Labels
No labels