2

I'm working with Meteor, and I want to start using Apollo to connect to multiple databases in my application. Unfortunately, almost all the documentation I can find involves connecting to outside servers like remote MySQL servers.

So how can I get Apollo to sit "on top" of Meteor's native mongo DB? I can get a GRAPHQL server running in my Meteor application no problem, but not connect it to the DB.

I've seen a non meteor example that creates collections like this, and that seems to be what binds things to the database, but I've never had to define the database connection in a meteor app, only the collection, and then call insert on the collection.

import {MongoClient, ObjectId} from 'mongodb'
const MONGO_URL = 'mongodb://localhost:27017/blog'
const db = await MongoClient.connect(MONGO_URL)
const Posts = db.collection('posts')
const Comments = db.collection('comments')
mstorkson
  • 1,130
  • 1
  • 10
  • 26

1 Answers1

2

Checkout this Apollo and MongoDB example.

jordanwillis
  • 10,449
  • 1
  • 37
  • 42