Recently I had a singular mission to build a GraphQL API against a Mongo database where the idea is, one could query the underlying collections, documents, and fields with the assumption that users would be adding or possibly removing said collections, documents, and fields as they needed.
That sounds somewhat straight forward enough, but before even getting started with the GraphQL API I really needed some type of environment that would mimic this process. That is what this article is about, creating a test bed for this criteria.
The Mongo Database & Environment
First thing I did was setup a new Python environment using
virtualenv. I wrote about that a bit in the past if you want to dig into that deeper, the post is available here.
Next up I created a git repo with
git init then added a README.md, LICENSE (MIT), and .gitignore file. The next obvious thing was the need for a Mongo database! I went to cracking on a docker-compose file, which formed up to look like this.
version: '3.1' services: mongo: image: mongo:latest container_name: mongodb_container ports: - "27017:27017" environment: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: examplepass volumes: - mongo-data:/data/db volumes: mongo-data:
With that server running, I went ahead and created a database called test manually. I’d just do all the work from here on out with that particular database.Continue reading “Fruit and Snakes: Frequent Mutative Mongo User Database with Python”