<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bogdan Nedelcu on Medium]]></title>
        <description><![CDATA[Stories by Bogdan Nedelcu on Medium]]></description>
        <link>https://medium.com/@bogdanned?source=rss-940d77dc706a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hudW2TXZNTvQNAp1p_Gogg.jpeg</url>
            <title>Stories by Bogdan Nedelcu on Medium</title>
            <link>https://medium.com/@bogdanned?source=rss-940d77dc706a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 01:55:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bogdanned/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Behind GraphQL: A first-principles approach]]></title>
            <link>https://medium.com/@bogdanned/system-design-with-graphql-601655a0c21f?source=rss-940d77dc706a------2</link>
            <guid isPermaLink="false">https://medium.com/p/601655a0c21f</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Bogdan Nedelcu]]></dc:creator>
            <pubDate>Mon, 21 Oct 2019 07:51:06 GMT</pubDate>
            <atom:updated>2019-11-05T12:29:34.424Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AOOZbygdhS3WrNkphUcKrw.png" /></figure><p>Replacing the traditional REST APIs, Graphql claims to <strong>reduce the number of trips</strong> to the server helping developers building <strong>applications that run faster</strong> on different devices and <strong>consume fewer data</strong>.</p><p>On the developer side, GraphQL introduces with a static query language for the data layer, server query validation, and <strong>an exceptional set of tooling</strong> that<strong> makes development smoother</strong>, <strong>reducing bottlenecks</strong> related to the backend and front-end integration.</p><p>However, when adopting a new technology knowing what it implies for our systems is crucial. <strong>How will the system look like?</strong> What are the strong points that we can leverage? What are the boundaries and limitations? How will the CI/CD pipeline look like?<strong> What will be really easy? Where will the challenges lay?</strong></p><p>Since GraphQL was open sourced <strong>only four years ago</strong>, <strong>experience in production is limited </strong>mostly to grey literature (blog posts, conferences). And so, the question arises: is there any way in which the new paradigm can be understood and the questions above answered?</p><h3>The Usual Suspects</h3><p>Although GraphQL influences our <strong>architecture uniquely</strong>, it builds on well-known<strong> design patterns. </strong>The patterns have been already used and analyzed extensively in production environments, and the experience can be used when designing GraphQL systems. As Newton once said:</p><blockquote>“If I have seen further it is by standing <strong>on the shoulders of Giants</strong>.” — Isaac Newton</blockquote><p>In the next section, we take a look at the most significant patterns GraphQL introduces:</p><p><strong>1) The API Gateway Pattern</strong></p><p><strong>2) The Integration Database Pattern</strong></p><p><strong>3) The Data Federation Pattern</strong></p><p>The advantages and limitations that GraphQL inevitably inherits from these patterns are discussed and an architecture that scales is proposed.</p><h3><strong>1) The API Gateway Pattern</strong></h3><p>The architectural choice that allows GraphQL to reduce the number of trips to the server and to unify different data sources under <strong>one unique interface</strong> is the API Gateway Pattern.</p><p>An evolution of the<strong> Facade Pattern</strong> from the Object-Oriented Design world, this paradigm enables <strong>hiding implementation details under a uniform interface offered to consumers</strong>.</p><p>Building on this pattern, GraphQL uses request routing(at resolver level) and unifies edge functions(caching, authentication) speeding up development in a world of microservices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/0*ulyWEmEV8VpohLqP" /><figcaption>GraphQL as an API Gateway</figcaption></figure><p>Aside from the benefits presented above, this pattern also comes with certain limitations. The first and most important is that it introduces <strong>a single point of failure</strong> in the architecture, increasing system risk.</p><p>To ensure availability and reliability, we must prepare our GraphQL servers for scale: using<strong> container technologies</strong>, setting up <strong>autoscaling strategies</strong> and <strong>distributed logging</strong> are just a few of the many tasks that become important when setting up an API Gateway.</p><p>An API Gateway containing the client interface also introduces an <strong>asymmetry in the development cycle</strong>. Developing several <strong>clients in parallel</strong> around a unique GraphQL service requires an extra effort in <strong>release planning</strong>.</p><p>Schema releases must be <strong>syncronized</strong> and <strong>negotiated</strong> with <strong>more than one client team</strong> and with the schema owners. Without special attention to this aspect, the development of the API Gateway <strong>can quickly become a development bottleneck</strong>.</p><h3><strong>2) The Integration Database Pattern</strong></h3><p>One of the biggest promises of GraphQL is that it allows the development of <strong>a single backend endpoint</strong> while being able to serve data to <strong>different clients</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/0*_6ZGykFawXl-Ei4U" /><figcaption>The Integration Database Pattern</figcaption></figure><p>Although mostly applied to database architectures, this idea is also nothing new. Also known as the <strong>Integration Database Pattern</strong> or the <strong>Shared Database Pattern</strong> in the world of <em>Enterprise Integration Patterns</em>, it promises faster synchronization for applications that share the same data (ex. different clients).</p><p>However satisfying requirements from <strong>different clients</strong>, with <strong>different users</strong> and even <strong>different development</strong> teams under the same interface at the same time, is something not easy to achieve.</p><p>Modern web application development advocates for pushing as much as possible<strong> business logic to the backend</strong>, beeing the front end only responsible for the presentation(view layer).</p><p>This often includes formatting in the case of numbers, abbreviations for longer text, locale information and so on, so forth. Attempts to c<strong>onciliate and accommodate</strong> all these <strong>different requirements</strong> in the <strong>same schema</strong> and sometimes under the same data structures end up in bloated <strong>GraphQL</strong> types like the one below, and of course, <strong>code duplication</strong> at resolver level:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XJRivkEe5isvIR4Ez12T_A.png" /><figcaption>A bloated type example</figcaption></figure><p>Of course, in this case, we can delegate the amount fetching to a completely new type(e.g. ItemAmount) and build a more generic Item type.</p><p>Although, <strong>generic types</strong> help satisfying divergent requirements they <strong>decrease transparency</strong>(lack of context) and<strong> increase development time</strong>.</p><p>Having many client applications relying on one single type converges into a schema of <strong>“monolithic” types</strong> that satisfy <strong>all the client requirements</strong> but <strong>few can understand</strong> and even more important resolve. As Fowler mentions:</p><blockquote>“The resulting <strong>links between applications</strong> and databases end up being <strong>brittle</strong> and thus<strong> difficult to change</strong>.”</blockquote><blockquote>— Martin Fowler, Database Styles 2004</blockquote><p>Although the <strong>Integration Database Pattern</strong> enables relatively fast development in the <strong>short and middle term</strong>, in the long run, the deep coupling of the different clients will <strong>slow backend development</strong> as the <strong>requirements </strong>on the<strong> same data structure</strong> will <strong>diverge</strong>.</p><h3><strong>3) The Data Federation Pattern</strong></h3><p>Last but not least, one of the most acclaimed features of GraphQL is that it allows engineering teams to <strong>“map”</strong> the<strong> business domain</strong> to <strong>a single schema</strong>, <strong>a central dictionary </strong>for the enterprise.<strong> Increasing transparency</strong> and <strong>decreasing communication overload</strong> are just one of the few advantages that this pattern brings to the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*U5clwzkx3XQ8bV-rdV6Dbg.png" /><figcaption>A simplified Federated Schema Pattern implementation</figcaption></figure><p>The idea of unifying knowledge in an organization under <strong>a single (distributed) dictionary</strong> and present it to client developers as a uniform interface was already introduced by the <strong>Data Federation Pattern</strong>.</p><p>Although subsets of the Federated Schema(Export Schemas) are developed <strong>separately</strong> and <strong>individually</strong>, they are merged into a <strong>uniform</strong> and <strong>unique </strong>schema also used as <strong>“live documentation”</strong> for client applications.</p><p>The pattern, used by IBM back in the 2000s as core to some of their stellar products(InfoSphere Federation Server) tried to bring <strong>uniformity</strong> to the <strong>enterprise internals</strong>. Federated Database servers often come with out of the box <strong>schema merging tools</strong> and <strong>query delegation and aggregation</strong> systems.</p><h3><strong>On Apollo Federation</strong></h3><p>As GraphQL adoption grows in the enterprise, Apollo, the main vendor of GraphQL tooling and solutions, released the <strong>Apollo Federation</strong>.</p><p>Shortly said, Apollo provides us this time with the tooling need in order to maintain an orchestrate a distributed graph. Utilities for merging different schemas and <strong>directives for cross schema reference</strong> are just some of the elements included in the recently open-source project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*9OI7TVxgYbGmwktntC_1QQ.png" /><figcaption>Apollo Federation Distributed Graph(Federated Schema)</figcaption></figure><p>Although the work of the Apollo team is brilliant, the concepts introduced are not trivial at all. The wonderful tooling does not eliminate the need for the so-called “schema board” where changes in the schema are being negotiated between clients and the schema owners. As Phill Calcado mentioned earlier this year:</p><blockquote>“.. it is hard for me to believe that you can combine the needs of many <strong>different</strong> <strong>applications</strong>, owned by <strong>different teams</strong>, with <strong>different</strong> <strong>users</strong> and use cases, in a <strong>single schema</strong>”</blockquote><blockquote>—<em>Phil Calcado, Some thoughts on GraphQL vs. BFF 2019</em></blockquote><p>The effort of synchronizing and unifying requirements coming from different contexts and owned by different teams<strong> grows faster </strong>than <strong>the benefits of a unique dictionary </strong>after certain scale.</p><p>Although Federated Schema Models are a natural step for certain organizations there are <strong>alternatives</strong> where instead of managing the complexity of a distributed unique schema the situation is avoided altogether.</p><h3><strong>The Backend for Frontend Pattern</strong></h3><p>So how can we use GraphQL at scale and survive? One of the most promising solutions is the <strong>Backend For Front End Pattern</strong>.</p><p>The pattern, introduced by the team at Sound Cloud back in 2012 when they were trying to scale the product to emerging mobile devices, implies building an <strong>intermediate backend service</strong> explicitly <strong>designed for a frontend domain</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*lBvY9zeNO-EO0YtPJJ5j5w.png" /><figcaption>Backend For Front End setup with GraphQL</figcaption></figure><p>The GraphQL service is <strong>owned by the client team</strong> and developed against a <strong>common backend interface</strong>. In this way, the individual requirements of the client remain constrained to the BFFE instances and the “indirect” coupling between clients is highly decreased.</p><p>The unique<strong> schema is divided by client needs</strong>, and although this will generate certain code duplication(types, resolvers, edge functions) <strong>the overall cost of change of the system</strong> is much, much <strong>lower than a single distributed schema</strong>.</p><p>Using this pattern in combination with <strong>GraphQL</strong> allows architects to take advantage of the <strong>strong point of GraphQL</strong> and push the boundaries of scale and development speed. At the same time, resolver and schema development are faster as<strong> types are less generic</strong> and <strong>less ambiguous</strong>.</p><p>In conclusion, <strong>the tradeoff of code repetition and duplication of edge functions is much easier to manage successfully than the constrains of a single schema served by a single API Gateway with deep client coupling.</strong></p><h3><strong>Closing Notes:</strong></h3><p>Building and using <strong>new technologies</strong> is one of the most exciting parts of working in engineering, yet we should not forget that <strong>new paradigms</strong> are usually the result of using <strong>“old ideas”</strong> applied<strong> differently </strong>or in a <strong>new context</strong>.</p><h4><strong>Taking the time to understand the lesson of the past, and learn from our own effort increases our success and helps us manage our frustration while building the future.</strong></h4><p>This article is the written version of the talk I gave at the Berlin GraphQL Meetup organized by Prisma. You can find the full version on Youtube:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FS22rYsesrQc%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DS22rYsesrQc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FS22rYsesrQc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bfeedad19bbce2e7e1f2ec069f3b3cb/href">https://medium.com/media/6bfeedad19bbce2e7e1f2ec069f3b3cb/href</a></iframe><p><strong><em>About the author</em></strong><em>: Bogdan Nedelcu is Software Engineer passionate about building high-performance systems prepared for change. He lives in Berlin, and in his free time, he loves dining, traveling and running early in the morning.</em></p><p>Enjoying the content? Feel free to share and let&#39;s connect on<strong> </strong><a href="https://www.linkedin.com/in/bogdan-nedelcu/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=601655a0c21f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>