The last thing I want to talk about is the idea of GraphQL as a backend for frontend. So if you're not familiar with the backend for frontend pattern, it's a pattern where teams define their own API for their own experience. So here you can see that team A owned an iOS app, and they also own a BFF, so an API server that is tailored exactly to their needs. Same thing with the Android app.
So at first sight, this looks exactly like a thing that GraphQL could be great at. It offers flexibility for the iOS app to consume a different set of data than the Android app, kind of decoupling the server from having to define maybe an iOS endpoint and an Android endpoint. The reality is that, BFFs, the back end for front end pattern, is not only about representation, so not only about the response or the resources we're creating, but it's also about complete autonomy of teams. And it's very good to realize that while GraphQL can offer us that benefit in terms of representation, it doesn't offer a full autonomy between teams. Types are still shared. Fields are still shared. And if you take a look at this query, for example, excuse the capital F on friends here, if we really wanted things to be different, you'd maybe have to do something like that where you maybe have a name, but you have a name for Android and you have an age and you have age for this one other client. That would be kind of truly decoupling these fields, but we can't necessarily ensure that. So that can be something that's annoying about GraphQL. Something can be amazing because we do share that graph, which can offer consistency. But it's good to realize it's not a replacement, an exact replacement for BFF, which is also a cultural pattern and a full autonomy pattern. And GraphQL we're kind of in between zone where clients can select a representation, but they still select it from a common base.
That complete separation has other meanings as well in the sense that with BFFs, you can write one in Go, write one in Ruby, write one in Java. With GraphQL, we're often striving for that one GraphQL server. So it might share the same rate limits, the same set of middlewares. Whereas with BFFs, you've got complete separation and you can choose any technologies you want. So I think it's good to realize that, not to mean that BFFs are better than GraphQL and the opposite, but that they imply very different things. And the idea of having one graph, which is very popular, and which makes a lot of sense, there's a lot of benefits to having one graph that all clients can integrate with and having that one source of truth for our domain has one schema. But it also comes with the responsibility to not go back to the one-size fits all we were fearing with REST, and define one schema that's the same for all clients. So we can't hesitate here. And really, adding client-specific fields should be a concern with GraphQL, to try and avoid reusing the same things. And another danger with the one graph idea is that while BFFs could have their complete different representation of a user, for example, here, we're still, if we're not careful, we're still sharing the same user type, and maybe a user in the Android world is different, or on Xbox, a user's completely different. So we have to keep that in mind.
So as you can see, a lot of things depends with GraphQL. And what do I want to say with all this? And why do I think this is even important to think about? I think we all want GraphQL to succeed. We're at a GraphQL conference.
Comments