<?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 Igor Kasianov on Medium]]></title>
        <description><![CDATA[Stories by Igor Kasianov on Medium]]></description>
        <link>https://medium.com/@super.hang.glider?source=rss-8d52f93c7875------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*eZiDCQnUXmpZl6-STIoq0g.jpeg</url>
            <title>Stories by Igor Kasianov on Medium</title>
            <link>https://medium.com/@super.hang.glider?source=rss-8d52f93c7875------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 19:38:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@super.hang.glider/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[Apollo Federation support in Graphene]]></title>
            <link>https://medium.com/preply-engineering/apollo-federation-support-in-graphene-761a0512456d?source=rss-8d52f93c7875------2</link>
            <guid isPermaLink="false">https://medium.com/p/761a0512456d</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[graphene]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Igor Kasianov]]></dc:creator>
            <pubDate>Wed, 11 Dec 2019 12:23:59 GMT</pubDate>
            <atom:updated>2019-12-11T12:23:59.299Z</atom:updated>
            <content:encoded><![CDATA[<p>My name is Igor Kasianov and I’m a lead on the backend team @Preply. In this article, I’ll share our experience connecting Python-based GQL graphs in Federated Graph with @apollo/gateway</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*th5Vg80v2yXHKA1UY3_E2w.png" /></figure><h3>Background</h3><p>Preply’s backend was originally built as a monolith application in Python, we’ve adopted GQL API since 2017. In late 2018, we decided to migrate to a microservices architecture.</p><p>During the migration, we faced a challenge: how could we keep one single GQL endpoint for frontend after we transitioned to independent graphs for each backend microservice?</p><h3>GQL schema stitcher: our first try</h3><p>At the time, Apollo had just released their <a href="https://www.apollographql.com/docs/graphql-tools/schema-stitching/">GQL schema stitcher</a>. It looked like a promising way to combine graphs.</p><p>As we played with it, we discovered that all stitching logic was located in the API gateway services. This meant that we would need to update the GQL stitcher service code every time we updated or added a service. Even if we only had 2 nodes, MessageNode and FileNode, the API gateway would become too big.</p><blockquote><em>The API gateway code was bulky and ruined the most important benefits of a microservices architecture — clear code ownership and a loosely coupled codebase.</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e315613cf24d96e053aa228d1e1a3af6/href">https://medium.com/media/e315613cf24d96e053aa228d1e1a3af6/href</a></iframe><p>You can check whole stitcher code example <a href="https://gist.github.com/erebus1/6bf67ad04d34d449de706b8fc74dd18b">here</a></p><h3>Apollo Federation: a perfect solution?</h3><p>When <a href="https://www.apollographql.com/docs/apollo-server/federation/introduction/">Apollo Federation</a> was released, it looked like the perfect solution. There was only one problem: libraries for JS, Java, Ruby &amp; .NET existed, but there was no library for Python. <a href="https://github.com/graphql-python/graphene">Graphene</a> library, which we’re using for GQL implementation in Python, didn’t support Federation.</p><p>Undeterred, we decided to create our own implementation of Graphene-Federation integration. It was quite straightforward based on Apollo Federation <a href="https://www.apollographql.com/docs/apollo-server/federation/federation-spec/">specification</a></p><p><a href="https://github.com/preply/graphene-federation">preply/graphene-federation</a></p><p>Our implementation supports most of Federation <a href="https://www.apollographql.com/docs/apollo-server/federation/federation-spec/">spec</a>, except 1 decorator:<br>@provides</p><p>You can install it via pip: pip install graphene-federation</p><h3>See an example</h3><p>With Apollo Federation, it’s easy to split a big monolithic graph into a set of small graphs.</p><p>Let’s assume we have a graph in the monolith, where root querymessage can have multiple files</p><p><em>monolith.py:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bc512c59557af16f0a2d28e86b616f3/href">https://medium.com/media/4bc512c59557af16f0a2d28e86b616f3/href</a></iframe><p>Now we decided to move files in separate microservice</p><p><em>monolith.py</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e71ff1223ac2b53f60b45d0a344e554/href">https://medium.com/media/9e71ff1223ac2b53f60b45d0a344e554/href</a></iframe><p><em>file_microservice.py</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5df2bfc4b86ab863598faa44aa09fa04/href">https://medium.com/media/5df2bfc4b86ab863598faa44aa09fa04/href</a></iframe><ul><li>@key(fields=&#39;id&#39;) Determines that FileNode can be referenced from other services.</li><li>@extend(fields=&#39;id&#39;) Marks FileNode as external. We can add more fields to it if needed.</li><li>id=external(graphene.Int(required=True)) Marks<em> id</em> as an external field.</li><li>build_schema does all magic<br>it adds _service and _entities fields and resolvers in the schema<br>it has the same signature as graphene.Schema</li></ul><p>You can find more info in the <a href="https://www.apollographql.com/docs/apollo-server/federation/core-concepts/#referencing-external-types">Core concepts</a> of Apollo Federation docs.</p><blockquote><em>In Federation, the API gateway code looks very simple and doesn’t require any updates when we make changes to underlying microservices.</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8106e21e0c9c0167e63c09bd9061dc64/href">https://medium.com/media/8106e21e0c9c0167e63c09bd9061dc64/href</a></iframe><h3>Could you use graphene-federation?</h3><p>If you use a SOA with GQL and need to connect your python-backed graphs in one endpoint, feel free to use <a href="https://www.apollographql.com/docs/apollo-server/federation/introduction/">Federation</a> with <a href="https://pypi.org/project/graphene-federation/">graphene-federation</a>.</p><p>You can open issues or contribute to <a href="https://github.com/preply/graphene-federation">graphene-federation</a>.</p><p>See another open source project from Preply here: <a href="https://github.com/preply/dj_anonymizer">database-anonymizer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=761a0512456d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/preply-engineering/apollo-federation-support-in-graphene-761a0512456d">Apollo Federation support in Graphene</a> was originally published in <a href="https://medium.com/preply-engineering">Preply Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>