hollowverse-archive / hollowverse

The new Hollowverse.com
The Unlicense
9 stars 4 forks source link

Look into how to prevent breaking API changes #227

Closed forabi closed 6 years ago

forabi commented 6 years ago

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 the gql tag in TypeScript files), and validate these queries against the updated API schema (just like we already validate the examples in the API repo using graphql-validator).

wholesomedev commented 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...

forabi commented 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...

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.