22 ms·
I liked this article, but after trying many different approaches in the past, I've found that GraphQL's "evolvable" approach is by far the best. And while the a
by hn_throwaway_99 6y ago
I liked this article, but after trying many different approaches in the past, I've found that GraphQL's "evolvable" approach is by far the best. And while the author correctly points out that some REST APIs have used this approach for a while, there are a couple important things that make this approach really easy to use in GraphQL:
1. When you deprecate fields, they disappear from the "default" documentation in the Graphiql browser. Which means it's always easy to see the latest "version" of the API.
2. Since clients request fields, you don't feel like you're unnecessarily returning an object that's twice as big as it needs to be with all the new and deprecated fields in the same response.
3. Corollary to #2, but since clients request fields it's easy to detect who hasn't migrated and who is using deprecated fields, which makes it easier to notify these clients or at least make an informed decision about when you can remove deprecated fields.
- slver 6y agoGraphQL's evolvable approach will likely not work that well on the "mutation" (i.e. command) side, because while you can map read-only data and remap and remap until it's beaten into submission, commands tend to have semantic meaning. When the backend changes, many commands may need to change at once. Just something to consider. Otherwise I find GraphQL's approach indeed great.