I am struggling with finding a solution for managing my databases. One of the problems I am having is that I have to dive into the dashboard everytime I change my graphql schema. Working with mutliple databases exacerbates this problem. If I change 1 field in a mutation the dev process goes something like:
Update test database graphql schema
Update test database mutation resolver
Deploy app to test environment
Propagate updates to acceptance database
Deploy app to acc environment
Propagate updates to prod database
Deploy app to prd environment
Ideally I would like to manage all these things automatically, so in this case:
I would like my database to mirror the schema I have in a git repository based on the branch that it resides in.
I would like to define my resolvers as code and store them in my git repository.
Is there some best-practice method for realizing this?
I don’t have a ready response for this and would love to write out an example but that’ll be the cause that other things don’t get done :).
I wonder, can’t you use a continuous deployment framework such as CircleCI (I’m pretty sure Zeit/Netlify also have the possibility to have custom logic like that) in combination with the update graphql endpoint? (maybe you are not aware that there is such an endpoint: https://docs.fauna.com/fauna/current/api/graphql/endpoints)
Hey, thanks! I was definitely not aware of this endpoint and it does solve 1 part of the problem, specifically schema management. I don’t think something similar exists for FQL resolvers though? It creates functions for the defined resolvers, but it doesn’t seem like the resolvers can be managed through an API endpoint as well. Am I maybe overlooking this?
Look at the Fwitter code, resolvers are just User Defines Functions (UDFs) which can be managed via the Fauna Query Language.
In that file you see how to create these.
You can imagine that you could have a folder named: “UDFs” in your project which contains
All that is left to do is import this index in your continuous deployment script and create or update each function. This is also on my I-would-really-like-to-write-an-example-of-this list. At this point Fwitter just runs a Setup script which calls all these function updates manually.
For example, this is the main function that sets up my database: