CI / CD Process

I’m about to open up a can of worms but here goes.

I have built a POC of something cool using Fauna. Hosting is via Vercel and I’m using the integration provided to store keys in three separate db’s that I have as children of a master one (namely dev, test, prod)

I have helper scripts to upload the graphql schema with a flag to merge or override the database. Also created are helper functions to upload my UDF’s that I use as custom resolvers in my graphql endpoints as well as roles pertaining to these and general roles for users, admins etc.

I have started writing a script which will automatically do this between my environments based on the key defined per child database which is defined as an env in Vercel. All good.

Now the tricky part: When running locally and in the cloud, functions are not overwritten with new versions if they exist already. In addition to this the merge schema flag always seems fail and leave trace data. I could use override but then when this hits my prod db it will wipe that out.

I then thought of backing up the db before running the override command to recreate the schema and encountered my next big issue (and only one really concerning me) - there does not seem to be a modern flow to backup and restore databases manually. I know there is a tool (not maintained and would cost more to run in the cloud) but what mechanism besides temporality does Fauna provide to enable this?

Maybe I am missing something here but how can Fauna be integrated into a production DevOps workflow, one that allows quick iterations and failsafes?

There currently is no other mechanism and we realize this is top priority.

For GraphQL you might find some inspiration here? GitHub - Plazide/fauna-gql-upload: A simple CLI for uploading a GraphQL schema, resolver functions, and more to a FaunaDB database.

For FQL it’s probably much simpler since everything can be defined in pure FQL. I’ve recently released a tool that makes it much easier for FQL and will write about an approach to migration/testing/CI for FQL soon using this tool. I know it doesn’t help you for GraphQL currently but if there are enough requests I could add GraphQL to it later on. GitHub - fauna-brecht/fauna-schema-migrate

This part probably requires more explanation though. You are writing your functions via resolvers I assume? It’s definitely possible to write an Upsert to either create or update your functions.