Closed forabi closed 6 years ago
The way this is handled with Node packages is through immutable versions. Obviously, we can't make a new immutable version of our API every time we deploy...but I wonder if something similar can be achieved...
The way this is handled with Node packages is through immutable versions. Obviously, we can't make a new immutable version of our API every time we deploy...but I wonder if something similar can be achieved...
Yeah, we can't do that. Even if we expose two endpoints (e.g. /v1/
and /v2/
), making the database schema compatible with both versions is probably going to be very hard.
Currently when a new version of the web app is deployed, the API queries are checked against the deployed production API and the build fails if the queries are not compatible.
While this prevents deploying a broken version of the web app, it does not prevent deploying a new API version that breaks an already-deployed web app. So it only works one way.
To be able to prevent breaking API changes, we need to validate the client queries against the API schema at the time of building the new API version.
So when building the API, the deploy script could fetch the source code of the master branch of the web app (and possibly
beta
as well), extract the queries from the code (these are currently template string literals tagged with thegql
tag in TypeScript files), and validate these queries against the updated API schema (just like we already validate the examples in the API repo usinggraphql-validator
).