, free & fully virtual. June 9th - 10th. Register Now

Do we need RemoteMongoClient, when working with GraphQL?

The MongoDB Stitch Documentation is showing an example where we use also the RemoteMongoClient, but do we really need this client when working only with GrapohQL for querying and mutating data?

Here the example:

const {
} = require('mongodb-stitch-browser-sdk');

const client = Stitch.initializeDefaultAppClient('weblocu-axibm');

const db = client.getServiceClient(RemoteMongoClient.factory, 'mongodb-atlas').db('<DATABASE>');

client.auth.loginWithCredential(new AnonymousCredential()).then(user =>
  db.collection('<COLLECTION>').updateOne({owner_id:}, {$set:{number:42}}, {upsert:true})
).then(() =>
  db.collection('<COLLECTION>').find({owner_id:}, { limit: 100}).asArray()
).then(docs => {
    console.log("Found docs", docs)
    console.log("[MongoDB Stitch] Connected to Stitch")
}).catch(err => {

Hi Ivan – You are correct, you do not need the RemoteMongoClient if you are just working with GraphQL/Authentication.

1 Like