Recent Posts


Don’t Make them Tell you Thrice


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Here’s an API design pattern that drives me a little nuts.

If you’re using the Apollo GraphQL client to make a data fetching query, your code looks like this.

    query: gql`query { ... your query here ...}`

However, if you’re using the apollo client to make a graphql mutation query, your code looks like this

// while I'm here can I gripe about the rise in popularity of the
// word "mutate" to mean "changes the value"
    mutation: gql`mutation { ... your query here ...}`

As a client developer who wants to make a graphql query, I end up needing to say whether I want to mutate or query three times.

First, in the query itself

mutation { ... your query here ...}
query { ... your query here ...}    

Second, in the object that’s passed to the API method

{query: ...}
{mutation: ...} 

and finally, in the method name itself.


This sort of triple redundancy makes learning how to use the API a bit more difficult (as seen in this stack overflow question/answer pair), and also adds a bit more contextual overhead to folks trying to use the API.

Easy enough to shrug off in this one case, but in aggregate this sort of thing is a big part of why systems are increasingly fragile and humans are increasingly unable to understand the systems we’ve built.

Copyright © Alan Storm 1975 – 2022 All Rights Reserved

Originally Posted: 13th April 2020