<?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 Ronualdo Maciel on Medium]]></title>
        <description><![CDATA[Stories by Ronualdo Maciel on Medium]]></description>
        <link>https://medium.com/@ronualdo?source=rss-d0b920eee98e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-4DEuLWnI_sHiErTVFc32Q.jpeg</url>
            <title>Stories by Ronualdo Maciel on Medium</title>
            <link>https://medium.com/@ronualdo?source=rss-d0b920eee98e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:42:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ronualdo/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[Elixir, GraphQL, and End-to-End Tests]]></title>
            <link>https://medium.com/pipefy/elixir-graphql-and-end-to-end-tests-cefe70b89c1?source=rss-d0b920eee98e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cefe70b89c1</guid>
            <category><![CDATA[end-to-end-testing]]></category>
            <category><![CDATA[absinthe]]></category>
            <category><![CDATA[elixirlang]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Ronualdo Maciel]]></dc:creator>
            <pubDate>Fri, 24 May 2019 13:31:15 GMT</pubDate>
            <atom:updated>2019-05-24T13:31:15.064Z</atom:updated>
            <content:encoded><![CDATA[<p>&quot;How do I test that?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_kllPfcLHeN8bLXukS3_g.jpeg" /></figure><p>Usually, this is one of the first questions that comes to my mind when I’m starting to learn a new technology. And considering the type of systems that we have to handle modern day, It’s not hard to understand why.</p><p>These days, It’s very unusual to find any project where a big part of the effort isn’t centered around creating and maintaining a suite of tests that not only serves as documentation of the expected behavior of the application, but also helps to mitigate some of the risks of its constant evolution.</p><p>This is not different in the APIs development, but while for REST endpoints tests are an already established subject, there is still some discussion around its implementation for GraphQL APIs.</p><p>In this post, we’ll bring up a couple of approaches and considerations regarding test implementations for those APIs. In this case, we’ll focus in Elixir, but the discussion is extensible to other stacks as well.</p><h4>GraphQL In The Elixir World</h4><p>Even though the extensive documentation of GraphQL and its many implementations, the fact that it is a relatively new technology means that some aspects are not totally covered yet: tests implementation are one example.</p><p>For Elixir, we have Absinthe project that provides an implementation of the GraphQL specification together with a series of packages that brings an extensive set of tools with the goal of making the developer’s work easier.</p><p>The project is well documented, even going above and beyond by providing different examples for more advanced subjects such as authentication and file upload, but the implementation of tests is an area that is completely left in the developer’s account.</p><h4>Running Queries/Mutations with Absinthe</h4><p>When you combine this missing point with the different forms of executing a GraphQL query/mutation, we find a very fertile ground of questions for the developer that is implementing his first API.</p><p>Essentially we have three main ways of performing a query/mutation using Absinthe, and with that, three ways of testing your GraphQL API:</p><ol><li><strong>Triggering a HTTP Post to your endpoint</strong></li></ol><p>This is maybe the approach closest to the ones usually used with traditional APIs. The idea here is to simulate a POST request to the endpoint and validate the results the same way that we would with a Rest API.</p><p>The difference here is only the details around the request and the fact that instead of a set of URIs representing the system resources, we have only one single endpoint that receives the POST request, and depending on the query provided, returns of the respective result.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b530adf043e6d6ef4212740a2f951d9f/href">https://medium.com/media/b530adf043e6d6ef4212740a2f951d9f/href</a></iframe><p>Code wise, there is nothing surprising here in this test. As we need to build a Connection, we must include MyWebApp.ConnCase and use post and json_response functions to trigger the request and check the result.</p><p><strong>2. Using Absinthe.run/3 to execute the query/mutation</strong></p><p>Another way of running a query is through Absinthe.run/3 function. With it, we can specify a query and the parameters to be executed in a specific Schema and we receive a tuple with the result.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/616594e91c53e273ac0d1f353d2c7388/href">https://medium.com/media/616594e91c53e273ac0d1f353d2c7388/href</a></iframe><p>In this version, the first change to be noted is the absence of the need to include ConnCase module functions. We don’t need to trigger an HTTP request considering that the test focus is to verify the return of the run function. All the code related to the POST request and the json response verification gives place to a call to Absinthe.run with the expected parameters to the test case.</p><p><strong>3. Running the resolver</strong></p><p>Another alternative would be go down an extra level and test only the resolver of que query/mutation under question. Considering that a resolver is nothing more than a function with a specific signature that transforms a GraphQL operation in data, a test like that don’t differentiate in any way from a test around a “normal” function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c8190e02a1db2178d79d294fa2eadf4/href">https://medium.com/media/0c8190e02a1db2178d79d294fa2eadf4/href</a></iframe><h4>And now? Which one to choose?</h4><p>Among the different ways of implementing our tests, we have to make the call on which approach to follow. After researching a little bit, it is possible to find suggestions to avoid tests that run the Schema, and to move all the behavior to be tested into its own function, which would lead the third approach to be preferable.</p><p>Under a certain point of view, this suggestion makes sense. While testing only the resolver, we get rid of all the boilerplate related to the query execution that simplifies the test. What might go unnoticed with this is that the “simplification” has its own repercusion.</p><p>Different types of tests have different goals, which makes each of them work best for specific granularities. Unit and Integration tests strive to exercise isolated components or specific integrations, and that allows a higher granularity to be used for this type of tests..</p><p>In an end-to-end test, the goal is to exercise the interaction among all the components that works together in a specific scenario, and that means those tests have to be less granular.</p><p>In these cases, a test where we execute the HTTP request allows us to verify a series of interactions among the components of the API (Router, Middlewares, Resolvers, etc.) which is not possible in the other approaches.</p><p>In a nutshell, each approach has its own implications and must be selected based on its unique situation.</p><h4>Summarizing…</h4><p>Although existing recommendations to use less granular tests that only exercise on the resolver of your GraphQL API is not the more adequate form of implementing an end-to-end test, they bypass the integration among a series of different components that exist in the application.</p><p>For these cases, it is interesting to have a test that exercises all the components of the application as a way of verifying the system functionality when all the components are integrated. This justifies the cost of a test that handles HTTP requests and json responses.</p><p>The best way to handle the cost that comes from this type of test is to make sure that they represent just a small part of your test suite, focusing on checking only the happy path for all the flows, and maybe a few exceptional cases without, however, eliminating them from your test database.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cefe70b89c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pipefy/elixir-graphql-and-end-to-end-tests-cefe70b89c1">Elixir, GraphQL, and End-to-End Tests</a> was originally published in <a href="https://medium.com/pipefy">Pipefy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices é massa né? Depende…]]></title>
            <link>https://medium.com/@ronualdo/microservices-%C3%A9-massa-n%C3%A9-depende-a845ff1ea2ae?source=rss-d0b920eee98e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a845ff1ea2ae</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Ronualdo Maciel]]></dc:creator>
            <pubDate>Thu, 25 Aug 2016 13:27:20 GMT</pubDate>
            <atom:updated>2016-08-30T12:45:14.137Z</atom:updated>
            <content:encoded><![CDATA[<h4>A hype</h4><p>Muitas das coisas que tem aparecido nas redes sociais em que eu participo, tem alguma coisa a ver com Microservices. Isso talvez se deva em parte pelo tipo de projetos que eu tenho me envolvido nos últimos dois anos, mas com certeza não é o único motivo pra isso.</p><p>Para quem conseguiu se manter alheio o“hype”, Microservices é um tipo de arquitetura onde a aplicação é composta por um conjunto de serviços pequenos e autônomos. Dentre os diversos benefícios da adoção desse tipo de arquitetura, talvez um dos mais cobiçados é a modularização que conseguimos quando dividimos uma aplicação em um conjunto de pequenos serviços.</p><h4>A armadilha</h4><p>Em um mundo com aplicações cada vez maiores e mais complexas, não é de surpreender que isso atraia a atenção de quem está procurando uma solução para seus problemas de manutenção. A grande questão é que nem todos levam em consideração o “alto custo” de implementação desse tipo de arquitetura.</p><p>No artigo <a href="http://martinfowler.com/bliki/MicroservicePrerequisites.html">Microservice Prerequisites</a> Martin Fowler fala um pouco desse custo do ponto de vista de operações. Nele ele levanta três requisitos básicos para organizações que planejam adotar esse tipo de arquitetura e sugere que talvez exista um modelo de maturidade para organizações que queiram trilhar esse caminho.</p><p>Apesar de Microservices ser muitas vezes citado em discussões em oposição ao termo “sistemas monolíticos” ela não é uma solução que visa primariamente lidar com aplicações grandes, mas sim permitir que a composição dos times replique a estrutura organizacional da empresa, fazendo com que a arquitetura tenha um papel muito mais organizacional do que técnico.</p><p>Em um outro <a href="http://philcalcado.com/2015/09/08/how_we_ended_up_with_microservices.html">artigo</a> muito interessante sobre Microservices, Phil Calçado fala um pouco sobre todo o processo que levou a SoundCloud a adotar a arquitetura que eles utilizam hoje em dia. Nele Phil deixa bem claro que os motivos para essa mudança foram muito mais relacionados com a produtividade dos times do que com motivos puramente técnicos.</p><h4>Microservices are bad?</h4><p>Isso significa que Microservices não podem ser utilizados para gerenciar o crescimento de nossas aplicações? Não necessariamente. O grande problema é achar que essa é a única solução existente.</p><p>Modularização de aplicações não é um nem de longe um problema novo. Todas as principais linguagens utilizadas hoje já possuíam algum tipo de solução para isso muito antes de começamos a discutir o que seriam Microservices. E muitas dessas soluções tem um “custo de implementação” mais baixo do que a alternativa.</p><p>Java conta com a ideia de packages, jars e wars já algum tempo, e uma das principais mudanças para a versão 9 da linguagem vai tratar exatamente de adicionar <a href="http://openjdk.java.net/projects/jigsaw/spec/">módulos de forma nativa a linguagem</a>. No mundo Ruby nós temos as <a href="http://guides.rubygems.org/what-is-a-gem/">Gems</a> e os Rails Engines e em Python quem trabalha com o framework Django já está familiarizado com o conceito de <a href="https://docs.djangoproject.com/en/1.10/intro/reusable-apps/">Apps</a> há algum tempo. Isso só para citar alguns.</p><h4>Concluindo…</h4><p>Opções existem, o grande ponto é tentar entender qual é o problema a ser resolvido e com base no contexto, tentar achar a solução com melhor custo-benefício. Por mais “cool’ que seja, se seu único problema é como gerenciar o tamanho de sua aplicação, talvez Microservices não seja a melhor escolha.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a845ff1ea2ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>