How do most SPAs handle breaking API schema changes?
31–39 of 39 posts
Re: How do most SPAs handle breaking API schema changes?
#32This doesn’t magically cure everything, but switching from REST to GraphQL can help make a lot of versioning-type issues disappear.
Re: How do most SPAs handle breaking API schema changes?
#33I use grpc-web and protocol buffers. Renaming fields doesn't matter -- if the client and server disagree about the name of a key, it doesn't matter, because the transport layer uses the tag number, not the name. (Compare this to JSON, where changing the name does break clients.) Adding fields also doesn't matter, but this is where it starts to get tricky. If a client sends a request without a field that the server ex…
Re: How do most SPAs handle breaking API schema changes?
#34Earlier quoted context omitted.
Even Facebook does this when you have left it open in a tab for too long. [edit]: spellcheck failed.
> Even Facebook Like they're the example we should look to. They do all sorts of hacky stuff.
Re: How do most SPAs handle breaking API schema changes?
#35Earlier quoted context omitted.
Not sure if this is standard, but what I usually do is bump the version only on a breaking change. So if I add a field, nothing new happens. Remove a field, or fundumentally change the output, then I bump it up.
Would you care how often you make breaking changes on your API if you control the client and it's your only consumer?
Re: How do most SPAs handle breaking API schema changes?
#36How do you even handle SPA updates themselves? Apps may reference static resources (JavaScript, CSS, images) which get updated with a new version. Those resources could be clobbered by a deploy, or be uglified, or be versioned. Do you keep the old static resources in place forever, or for a period of time? Or force a reload? Or do you just let clients break and make users reload?
Yeah, the tooling around this is pretty bad. For example, you might release a container that has index.html and main.abc1234.js. index.html has to be parsed before the JS bundle is requested. If you do a release in that intermediate time, the javascript will 404 and your site won't load because in the new container, the only bundle that exists is main.def2345.js. I think people additionally assume this never happens,…
Re: How do most SPAs handle breaking API schema changes?
#37How do you even handle SPA updates themselves? Apps may reference static resources (JavaScript, CSS, images) which get updated with a new version. Those resources could be clobbered by a deploy, or be uglified, or be versioned. Do you keep the old static resources in place forever, or for a period of time? Or force a reload? Or do you just let clients break and make users reload?
Yeah, the tooling around this is pretty bad. For example, you might release a container that has index.html and main.abc1234.js. index.html has to be parsed before the JS bundle is requested. If you do a release in that intermediate time, the javascript will 404 and your site won't load because in the new container, the only bundle that exists is main.def2345.js. I think people additionally assume this never happens,…
Re: How do most SPAs handle breaking API schema changes?
#38Earlier quoted context omitted.
Yeah, the tooling around this is pretty bad. For example, you might release a container that has index.html and main.abc1234.js. index.html has to be parsed before the JS bundle is requested. If you do a release in that intermediate time, the javascript will 404 and your site won't load because in the new container, the only bundle that exists is main.def2345.js. I think people additionally assume this never happens,…
Edge caching is a solution.
Re: How do most SPAs handle breaking API schema changes?
#39We use API versioning. Works like a charm! If you don't currently have API versioning, just put the breaking changes behind /v2/ and start versioning.
I guess the hard thing is that you lose versioning granularity at that level. If you made a mistake with your v2 rollout and the fix is breaking, do you bump to v3 or append the correct field? Do you leave the bug in the response still so that users can decide to depend on it? You can’t delete. What would the user thing about bumping from v3 to v12 in a really short amount of time as the API is in flux? Stripe’s date…