<?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 Ramon Morcillo on Medium]]></title>
        <description><![CDATA[Stories by Ramon Morcillo on Medium]]></description>
        <link>https://medium.com/@reymon359?source=rss-65e62cb0015b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Tw_Yh2FuRHr_kYHuIowaEg.jpeg</url>
            <title>Stories by Ramon Morcillo on Medium</title>
            <link>https://medium.com/@reymon359?source=rss-65e62cb0015b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 08:21:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@reymon359/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[Developing a reusable ecommerce platform.]]></title>
            <link>https://medium.com/guidesmiths-dev/developing-a-reusable-ecommerce-platform-f6563573c121?source=rss-65e62cb0015b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6563573c121</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Ramon Morcillo]]></dc:creator>
            <pubDate>Thu, 22 Oct 2020 12:31:18 GMT</pubDate>
            <atom:updated>2020-10-23T20:31:41.836Z</atom:updated>
            <content:encoded><![CDATA[<h3>Developing a reusable ecommerce platform</h3><p>Process and lessons learned from the development of a reusable ecommerce platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ePNl3XAkEzB7WB_Ru_ZK8Q.jpeg" /><figcaption><a href="https://unsplash.com/photos/WlhzJkBvNDo">Image source</a></figcaption></figure><p>This is a story about my team’s hard work developing not a single ecommerce platform, but a reusable one for different owners, keeping the same codebase, look and feel, but being highly customizable. I will conclude with what we learned from it which I believe can be a useful learning resource for other software developers out there and to ourselves in future projects.</p><p>I will try to focus on the relevant parts as much as possible to make it easier to understand. Having said this, a bit of domain is needed to go through this lecture.</p><h3>Table of Contents</h3><p><strong>– Context<br>– The first MVP<br>– Implementing GraphQL<br>– Architecture and Tech Stack<br>– The second MVP<br>– Conclusion and lessons learned<br>– Greetings</strong></p><h3>Context</h3><p>The client we were developing the platform for was an eLearning company which was composed of 3 main sub-companies.</p><p>For the past few years, the sub-companies had been operating mostly independently but now they were trying to create a standardized way of doing things, and grow together in the best way.</p><p>The project was an ambitious one. Creating an ecommerce platform that would work for all the sub-companies wasn’t easy to design, neither to implement given a large number of unsolved doubts it had, which made it very hard to estimate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*6RIM7r_342APNvYTxma5jQ.gif" /></figure><h3><strong>The first MVP</strong></h3><p>To tackle this difficult challenge, we started from the bottom, with one of the 3 sub-companies, let’s call it sub-company H, in fact, it wasn’t one of the main sub-companies, it was a sub-company from a sub-company. To explain it better, if we name the 3 main sub-companies L, N, and P, then H was a sub-company of N.</p><p>Being a sub-sub-company didn’t mean the platform would be simpler to develop, quite the opposite actually given all the features proposed for the MVP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AZANdiKHMY2vnzViLNf25A.jpeg" /><figcaption>Main company structure</figcaption></figure><p>While the main goal for it was the user being able to purchase a product, quite obvious indeed, there were too many dependencies with other services to accomplish this simple, at first sight, MVP.</p><p>Part of the product and orders information came from another team’s domain, the Integrations team, I will call it team <em>In</em>, I would have called it team I (capital i) but it could be misunderstood with an l (non-capital L) or a 1 (number one). They communicated with <a href="https://www.swell.is/">Swell</a> and Klopotek, an ecommerce system where we stored the product’s information along with the order’s status.</p><p>The discounts were also provided by team <em>In’s</em>, to which we had to subscribe and then calculate the final product price according to the user info and privileges before displaying it.</p><p>To make product content like images or descriptions accessible and customizable for the client we retrieved it through <a href="https://www.contentful.com/">Contentful</a>, a content platform where clients were able to manage it in an easy way.</p><p>We managed the payment with <a href="https://stripe.com/">Stripe</a>, a payments service, and then we communicated with team <em>In</em> to update the order status on Swell.</p><p>The service available for the user to authenticate should be agnostic to the owner and reusable on all sub-companies. It had to be provided by another team, yet in the end, we actually developed it ourselves.</p><p>And to put the icing on the cake we had to implement the user tracking with <a href="https://segment.com/">Segment</a>, a popular service to collect user events from web &amp; mobile apps.</p><p>Here is a simple diagram of what I have been describing which might make it easier to understand. I have grouped the microservices architecture in just <em>Backend</em> and <em>Frontend</em> to keep it simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9oE0VLtNJsI6afWnFKl_A.jpeg" /><figcaption>MVP architecture overview</figcaption></figure><h3><strong>Implementing GraphQL</strong></h3><p>To accomplish the project we had to <em>provide the frontend with a unique source of truth</em> of the product’s core information from the backend. Therefore the only thing that we aimed to have different from one store’s frontend to another would be the designs and the content from Contentful. Regarding these designs and their implementations on React, we planned to use a shared-components-library.</p><p>Therefore, what is GraphQL doing here and why did we decide to go for it? Well, in case you don’t know how GraphQL works, essentially it lets us define a Schema with all the properties and queries that could be made to our product, and then serve it to the frontend to let it decide what to request without the backend having to create an endpoint for each of those requests like in REST services. To learn more about it <a href="https://www.ramonmorcillo.com/getting-started-with-graphql-and-nodejs/">I wrote a tutorial to explain it</a> which teaches how to use it with Node.js, moreover, <a href="https://graphql.org/learn/">their docs</a> are worth checking out.</p><p>This meant that each of the shops would request the data they would need from the product just looking at the Schema, the source of truth. Thanks to this fact we would not have to implement in the backend different sources of data for each shop, giving the frontend the power and responsibility (the first involves the second 🕷) to request the product data needed to display at each interface.</p><blockquote><strong><em>“</em>With great power comes great responsibility</strong><em>”</em></blockquote><blockquote><em>— Stan Lee</em></blockquote><p>Just to be clear, if we had decided to go with REST we would have needed to create different endpoints for each of the shops or make the frontend retrieve all the product data in each shop and then decide which properties to display, storing unnecessary data in the frontend that would only add noise. Or even worse, we would have had all the shops’ backend services deployed for each one of the frontend shops which would mean to use unnecessary resources and increase the cost considerably. Here is why we took this initial approach. The worst fact, in my opinion, would be the waste of time needed to maintain and hardly refactor all the mess that we would have created.</p><p>Furthermore, by making a single request on-demand, the payload is lighter, and therefore, the performance over the network is improved.</p><p>Anyway, as with every problem, there were other approaches on the way to develop this project and its architecture, however at that moment this one seemed to us the best one.</p><h3><strong>Architecture and Tech Stack</strong></h3><p>The microservices architecture were mainly Node.js services hosted on Azure K8s clusters which, depending on their needs and the data they worked with, had or not a MongoDB, PostgreSQL, or Redis database associated.</p><p>The asynchronous communication between them was handled mainly with <a href="https://azure.microsoft.com/en-us/services/service-bus/">Azure Service Bus</a> topics and subscriptions through a publish/subscribe messaging communication model. The main difference with common messaging queues is that you can have more than one receiver, so you do not have multiple queues to receive messages in more than one service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*erHUZg8SXMSb2G6i9tQyyg.png" /><figcaption>Azure Service Bus messaging Queues. <a href="https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview#queues">Source</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*qDdiPtCZmqvHPVD_quCrHg.png" /><figcaption>Azure Service Bus messaging Topics. <a href="https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview#topics">Source</a></figcaption></figure><p>On the frontend part, the sites were developed with React; sometimes using <a href="https://github.com/vercel/next.js/">Next</a>, and other ones from scratch with <a href="https://github.com/facebook/create-react-app">Create React App</a> depending on the complexity and the requirements of each. We moved from Redux, used in previous projects, to the official <a href="https://reactjs.org/docs/context.html">Context API</a> to manage most of the state.</p><p>Here are the main services and their functionalities for the first MVP architecture:</p><ul><li><strong>shop-web-app:</strong> The client shop application.</li><li><strong>gateway-api-service:</strong> Proxy service to receive requests from the client and redirect them to the corresponding services.</li><li><strong>cms-api-service:</strong> Service to retrieve and serve the content from Contentful</li><li><strong>catalog-api-service:</strong> Service that subscribes to team In messages and persists the product core data to serve it later through GraphQL.</li><li><strong>orders-api-service.</strong> Service that handles all the payment business logic</li><li><strong>auth-api-service:</strong> Provisional service to implement the user authentication to be able to buy products.</li><li><strong>auth-web-app:</strong> The client for the auth service.</li><li><strong>integrations-ecommerce-api-service:</strong> service from the integrations domain that handles the payments. Although this service was not in our domain we developed it together to increase the delivery speed and free them from extra work.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEp0_bT29ZD4knQ42HGT3Q.jpeg" /><figcaption>First MVP architecture</figcaption></figure><p>To deploy and update the resources needed on Azure we used <a href="https://www.terraform.io/">Terraform</a>, which let us define infrastructure as code and manage their life cycles on the K8s clusters. We also worked with Azure DevOps as our CI &amp; CD system.</p><p>On the services, we used <a href="https://github.com/guidesmiths/systemic">Systemic</a>, a Node.js framework for minimal dependency injection that lets you create components and their dependencies in a system, where each component handles a separate object from the domain such as the routing, controller, services, database, … in an agnostic way from the others.</p><p><a href="https://www.apollographql.com/">Apollo</a> was our choice to implement GraphQL providing us with a data graph layer to easily connect both, frontend and backend. Again, to learn more about it check <a href="https://www.apollographql.com/docs/">their docs</a> or <a href="https://www.ramonmorcillo.com/getting-started-with-graphql-and-nodejs/">this tutorial.</a> Finally, we hosted the code on <a href="https://github.com/">GitHub</a> to make use of features like Pull Requests to review code properly before implementing it.</p><h3><strong>The second MVP</strong></h3><p>An MVP (Minimum Viable Product) is the first prototype you create and deliver in a project, therefore there is usually just one and when you achieve it you start implementing new features on it. So, why did we focus on a second MVP for the same project? Well, When we reached a “stable” version of the first one, the client realized that we needed to start with the main sub-companies stores, and took the decision to stop the sub-sub-company H store development to focus on the development of the new ones. The reason behind this was mainly due to some services ending their support for the sub-companies in the coming months, meaning that their stores had to be developed first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KdQnhYSmIT2D3EDO7Cftsw.jpeg" /><figcaption>Graphical representation of how we felt with the second MVP</figcaption></figure><p>Although we tried to make a proper estimation of the first one we surpassed its deadline since some unplanned issues appeared along. Thus, when we were told that the new deadline would be even closer we decided to take a different approach to reach it on time. We concluded to develop more than one store at the same time which was a double-edged sword approach; on one hand, we would see on the go how well the reusability aspect of our platform worked while refactoring it and we would also end up with more than one store in the end. On the other hand, we would have to set up and maintain the environments and resources of multiple shops plus implement the designs of them which would slow us down, therefore we may not reach the deadline on time, again.</p><p>We saw this MVP as an opportunity to start over and improve our codebase and so we added TypesScript and Styled-Components to our React application. I have to admit that I was very happy when we made these choices because I had been working with that stack on <a href="https://github.com/reymon359?tab=repositories&amp;q=&amp;type=source&amp;language=typescript">my own projects</a> and now I was able to learn more and get even better at it.</p><p>A good thing was that we were able to reuse most of the code from the previous MVP for the React apps and the backend services, however, not everything was a bed of roses; not all of us were used to working with this new stack and it slowed us at the beginning. Furthermore, with the same stack, we started developing a React components library for all the platforms, which, even though was planned for the first MVP, never saw the light.</p><p>By that time, the team in charge of the user authentication service started working on it so we stopped its development and just implemented it on the site. In addition, we started the development of a products search service (<strong>search-api-service</strong>) with <a href="https://azure.microsoft.com/en-us/services/search/">Azure Cognitive Search</a>.</p><p>After all the changes mentioned above the architecture evolved this way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7OUyITtI4QzYPAo3EHxQEg.jpeg" /><figcaption>Second MVP architecture</figcaption></figure><h3><strong>Conclusion and lessons learned</strong></h3><p>As I am writing this, the platform isn’t finished yet, however it has been a great challenge to get where we are. We have learned some valuable lessons that can be useful to others, not just about the stack and architecture described above but the way we worked as a team.</p><p><strong>Innovate the stack. </strong>Working with new technologies can be risky and less comfortable than sticking with old and well-known ones, <em>but innovation and adapting is the right way to not be left behind in Software Development.</em> One of the most important points when you upgrade the stack or adopt a new one, apart from checking the proper way to do so following standards, is <em>being sure the team is comfortable working with it,</em> not just at the beginning but during the whole process to make the transition easier.</p><p><strong>Don’t underestimate, promise less, deliver more. </strong>We happily estimated the first MVP and agreed to deliver a great number of features. We ended up needing more time because of all the issues that appeared on the way and <em>had to learn to say “no” </em>sometimes. On the second MVP, we didn’t estimate that far in time and didn’t commit ourselves to features we weren’t sure to deliver on the time expected. <em>We achieved to work less stressed, have a better mood, deliver better code, and improve the client’s feelings</em> about the project since they weren’t disappointed with the progress.</p><p><strong>Teamwork inside the team</strong>. We realized the best way to progress and develop was to feel comfortable with not just the technologies but, most importantly the teammates. Some of the measures that improved our relationship and teamwork were:</p><ul><li><strong>Team democracy.</strong> No matter the work we were doing at the moment, <em>all of us had the same voice and our opinion counted the same</em> when making a choice. This was key when discussed the adoption of the new stack and the practices we would follow.</li><li><strong>Reviewing code</strong>. Feedback is one of the best ways to improve not only the code itself but the way you write it too. That’s why we decided to work with GitHub Pull Requests to implement most of the features. <em>Working with them not only improved our code base but also made us aware of how the features were being implemented in other areas, avoiding catchup meetings and helping to keep track of the full project scope</em>. We refined this system little by little with features like a <a href="https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/about-required-reviews-for-pull-requests">minimum number of reviewers to merge them</a> or <a href="https://github.com/integrations/slack">subscribing to them through slack.</a></li><li><strong>Helping and asking for help.</strong> In my opinion, this one is a must. <em>The team must lose the fear to ask for help if they get stuck and, at the same time be willing to help others when they ask for it.</em> I am happy to say that we were able to reach this situation and our work got improved in many ways. The next point, pairing, was key in losing the fear to ask for help and get to know each other better.</li><li><strong>Pairing as much as possible. </strong>At this point in software development, the advantages of doing pair programming are more than well known, we paired not just to deliver the features in a faster and better way but to learn from each other’s way to code. We weekly decided the pairing tasks and teammates to implement them, however, if someone needed or wanted to pair, we just asked for it and moments after a teammate offered it.</li><li><strong>Pay attention to feedback.</strong> The sprint retrospectives were the perfect moment to review all the things that went well, wrong, propose changes, and look forward to improvement. Therefore the more we shared our opinions the more issues we could approach and solve.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*9lygicAR_GeE_F4j8QWajg.gif" /></figure><p><strong>Teamwork with other partners.</strong> We were dependent on other teams’ work therefore having a good relationship with them was also an important point in the development. <em>Communication was the key point, the more we communicated the more we improved,</em> thanks to it, the feeling we had was to be one whole team. Here are some actions we followed in order to enhance this communication:</p><ul><li><strong>Have a private place just for us.</strong> We created a separate channel to talk about the progress and solve the doubts as soon as possible without extra meetings.</li><li><strong>Quick meetings. </strong>A meeting once a week worked great to check the progress on the main issues, however, we did not wait for it and had a quick call whenever an issue needed to be discussed.</li><li><strong>Stay updated on the overall progress.</strong> We had a teammate from our team attending their daily standups and one of them at ours who updated the rest of the team if needed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/202/1*47gYSukJ7FEMcyqGp94w4A.gif" /><figcaption>Actual footage of us and the Integrations Team</figcaption></figure><p><strong>Make the client feel like part of the team. </strong>At the beginning of the first MVP, there were too many clues and too little communication to clarify them so we were blocked sometimes or had to set up wasting-time meetings for them. The core of the problem, like most life ones, was a lack of communication therefore we solved it by increasing it, asking questions directly to the client, inviting them to retrospectives, daily standups, and other meetings even when they were not required, to keep them updated as much as possible. In the end, the more we communicated the more we made them feel part of the team, and the better we worked together.</p><h3><strong>Greetings</strong></h3><p>I want to first thank my teammates. It has been a pleasure to work with them, starting each day eager to have fun together developing the project.</p><p>On the same level the teammates from other teams who always gave a helping hand when requested.</p><p>Then I want to thank the opportunity of having been able to participate in the full end-to-end implementation of the project from which I learned so much. I solved issues on Front, Back, and DevOps such as setting up environments, pipelines, messaging between services, persisting and retrieving data, serving it to the frontend, and implementing the interfaces to display it.</p><p>Finally, I am thankful for having the chance to work and get better at technologies that I was using on side-projects like GraphQL or TypeScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*jEQGehlGXw55bCSWrIG_nQ.gif" /></figure><p>You can also read <a href="https://www.ramonmorcillo.com/developing-a-reusable-ecommerce-platform/">this post on my site</a> along with others!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6563573c121" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidesmiths-dev/developing-a-reusable-ecommerce-platform-f6563573c121">Developing a reusable ecommerce platform.</a> was originally published in <a href="https://medium.com/guidesmiths-dev">guidesmiths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using GitHub Actions and Renovate App to safely update dependencies automatically]]></title>
            <link>https://medium.com/guidesmiths-dev/using-github-actions-and-renovate-app-to-safely-update-dependencies-automatically-b95a16e0a56a?source=rss-65e62cb0015b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b95a16e0a56a</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[maintainability]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[github-app]]></category>
            <dc:creator><![CDATA[Ramon Morcillo]]></dc:creator>
            <pubDate>Fri, 24 Jul 2020 07:52:52 GMT</pubDate>
            <atom:updated>2020-09-12T23:04:00.079Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*D25Fe_DyizTHBZcg3k3FxA.png" /></figure><p>In Software Development <strong>keeping up to date with technology updates</strong> is crucial not only for developers who have to be always learning and renewing their set of skills but also for the projects they work on and have to be maintained.</p><p>When you start a project from the ground you normally set it up with the libraries’ latest stable versions. Then time goes by, and the size of the project grows, new features are added, new libraries too, and <strong>the version of the libraries and packages usually remains the same and almost never gets updated</strong>. And yes, why would you update them if the project works perfectly with the current ones?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*d43yyDp8rPQUqElUiZrXgg.jpeg" /></figure><p>Here are some reasons why you should keep your dependencies updated:</p><ul><li>Solving problems from old versions.</li><li>Adding vulnerability fixes.</li><li>Increase the overall performance.</li><li>Add new features from them.</li><li>…</li></ul><p>When you keep the dependencies updated you are solving problems from older versions, improving the performance with new optimizations, and you are also able to use new features that other developers added to them. All of these contribute to increasing the <em>maintainability of the code</em>, and the overall project.</p><p>We all have worked on projects where the dependencies have never (or rarely) been updated.</p><p>So how do we do it?</p><p>Well, first you can run npm outdated to <a href="https://docs.npmjs.com/cli/outdated">see the latest releases</a> of the packages you are currently using.</p><p>You can then run npm update to update them (it will not update them to the major versions) but how do you know which ones will make the project break and which ones won’t?</p><p>Then there is the <em>when</em>, when should you update them? When should you check for updates? every day? every week? …month?</p><p>This is why I made this project, to learn about GitHub Actions and use it to have a <strong>safe way to automatically update the dependencies without making the project fail</strong>.</p><p>The short explanation of this tutorial is about adding the <a href="https://github.com/renovatebot/renovate">Renovate app</a> to check for dependencies updates and then submit Pull Requests to update them, this way we will <em>abstract</em> ourselves on checking for updates, so we can focus on more important things.</p><p>The point of using <a href="https://github.com/features/actions">GitHub Actions</a> is to set up a workflow and trigger it with every Pull Request to check that the build and tests pass with the updated dependencies before adding them to the project.</p><h3>Table of Contents</h3><p><strong>– Getting started<br>– Set up Github Actions Workflow<br>– Add Renovate<br>– Conclusion<br>– Useful resources</strong></p><h3>Getting Started</h3><p>Although <strong>this approach can be applied to any project</strong> we will use a <a href="https://reactjs.org/">React</a> project made with <a href="https://github.com/facebook/create-react-app">Create React App</a> as it will give us a basic project with everything ready to work on. By the way, if you do not have Node.js installed <a href="https://nodejs.org/en/download/">here</a> is the link to do so.</p><p>Also, <a href="https://github.com/reymon359/github-actions-and-renovate">in this repository is the resulting project</a> you will obtain after following all the steps below in case you want to have a look before starting.</p><p>So let’s begin running</p><pre>npx create-react-app my-app</pre><pre>cd my-app</pre><pre>npm start</pre><p>If you use npm 5.1 or earlier, you can’t use npx. Instead, install create-react-app globally:</p><p>npm install -g create-react-app</p><p>And then run:</p><p>create-react-app my-app</p><h3>Set up Github Actions Workflow</h3><p>Now we will proceed to define a GitHub Actions Workflow in our repository to automate the process.</p><p><a href="https://github.com/features/actions"><em>GitHub Actions</em></a><em> is a Github Feature that helps your software development workflows automating from simple tasks to custom end-to-end continuous integration (CI) and continuous deployment (CD) capabilities in your repository.</em></p><p>In our root folder, we will create a new folder and name it .github and inside of it a workflows one. This is how your project should look after these steps:</p><pre>📁 my-app<br>├── 📁 .github<br>│   └── 📁 workflows<br>├── ...<br>...</pre><p>Here is where we will create and add our Workflows. Github Actions Workflows are the Continuous Integration automated processes we want to run in our project.</p><p>Workflows are composed of jobs that contain a set of steps and to explain them in a clearer way let’s create our own workflow explaining it step by step.</p><p>In the .github/workflows directory, add a .yml or yaml file and name it main.yml. I chose that name to keep things simple, but you can give it any other name like build-test.ymlor continuous-integration-workflow.yml.</p><pre>📁 my-app<br>├── 📁 .github<br>│   └── 📁 workflows<br>│       └── 📄 main.yml<br>├── ...<br>...</pre><p><a href="https://gist.github.com/reymon359/514cf378456457f1798293fe0ed99f3a">Here</a> is how the workflow will look in the end in case you just want to copy it and add it directly before the explanation.</p><p>The first param of our workflow will be its <strong>name</strong>.</p><pre>name: Build and Test</pre><p>The second param is the <strong>trigger</strong>.</p><p>We can choose if the workflow is <strong>triggered by an event like a push or pull request to a specific branch</strong>, or we can even schedule a <a href="https://en.wikipedia.org/wiki/Cron">cron</a> to <strong>automatically trigger it every defined amount of time!</strong>.</p><p>In our project we will want to trigger it when pushing to the master branch and when the Renovate app submits a Pull Request to update a dependence:</p><pre>on:<br>  push:<br>    branches: [master]<br>  pull_request:<br>    branches: [master]</pre><p>Next, we define the <strong>jobs</strong>.</p><p>In this example, there will only be one job which will be the one to <strong>build and test</strong> the project, and chose the virtual machine where the job will be run on.</p><pre>jobs:<br>  build_and_test:<br>    runs-on: ubuntu-latest</pre><p>Then it comes to the matrix where we will configure the combination of versions and systems we want to run out Workflow. In our case, we will run it on Node.js 10 and 12.</p><pre>strategy:<br>      matrix:<br>        node-version: [10, 12]</pre><p>Finally, the Workflow’s steps. The first one is the <a href="https://github.com/actions/checkout">checkout action</a> which is a standard action that you must include in your workflow when you need a copy of your repository to run the workflow.</p><p>Then you can run other actions and processes, in our app, we will use the <strong>setup-node</strong> action with the matrix we defined before. Then we will add steps to install the project, build it, and run the tests.</p><pre>steps:<br>      - name: Checkout<br>        uses: actions/checkout@v2<br>      - name: Use Node.js ${{ matrix.node-version }}<br>        uses: actions/setup-node@v1<br>        with:<br>          node-version: ${{ matrix.node-version }}<br>      - name: Install project<br>        run: npm install<br>      - name: Build the project<br>        run: npm run build --if-present<br>      - name: Run tests<br>        run: npm test</pre><p>Now Create a GitHub Repository for the project, commit the local changes made, and push them to it.</p><p>Quick tip, If you want to create it faster go to <a href="https://repo.new/">repo.new</a> or <a href="https://github.new/">github.new</a>. You can use <a href="https://gist.new/">gist.new</a> for gists too!</p><p>Once you push your changes the Workflow will run, and you will be able to see how it went in the Actions <a href="https://github.com/reymon359/github-actions-and-renovate/actions">tab from the GitHub Project</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*Py7b3rfmArDxBaEFs_PBOA.png" /></figure><h3>Add Renovate</h3><p><a href="https://github.com/marketplace/renovate">Renovate</a> is a free, open-source, customizable app to automate the update of our dependencies in software projects by receiving pull requests. It is used by software companies like Google, Mozilla, or Uber and you can use it on GitHub, Gitlab, Bitbucket, Azure DevOps, and Gitea.</p><p>Going to the point what we will do is add a bot that will submit pull requests to our repository when there are updates in our project dependencies.</p><p>The cool thing, and the whole point of our project, is that we have previously defined in our workflow to run the tests with the pull requests so when renovate submits one <strong>we will automatically check if the updates proposed will break the project or not before merging them to the master branch</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*gGe28UdTAmHHNrtuhXfRAw.gif" /></figure><p>To add Renovate to our project we have to install <a href="https://github.com/apps/renovate">its app</a> into the project’s repository. Be careful when selecting the repository you want to add Renovate to and choose the one created before. If by mistake you want to reconfigure it you can do it in the <a href="https://github.com/settings/installations">Personal Settings’ Applications tab</a> from your account.</p><p>After some minutes we will have to accept and merge the onboarding Pull Request that we will receive.</p><p>Once we have it integrated we will configure it updating the renovate.json file on the project root. Remember to pull the changes after merging the Pull Request for it to appear.</p><p>We can use the default configuration where renovate will submit the pull requests whenever it finds out about updates and wait for us to merge them:</p><pre>{<br>  &quot;extends&quot;: [&quot;config:base&quot;]<br>}</pre><p>Or we can adapt it to the requirements of our project like <a href="https://github.com/renovatebot/renovate/blob/master/renovate.json">the one used by Renovate itself</a>. To avoid falling short and to learn a little more about the tool, we will use a configuration with some of its most useful features. If you want to learn more about its configuration <a href="https://docs.renovatebot.com/">here</a> are the docs for it.</p><p><a href="https://gist.github.com/reymon359/4c4417522cd0922cfbc63ad75ca2c945">This</a> will be our renovate.json file. Have a look at it and I will explain it after.</p><p>In the first part, we are telling renovate that our configuration will be an extension from the default one.</p><pre>{<br>  &quot;extends&quot;: [<br>    &quot;config:base&quot;<br>  ],</pre><p>Then we have the packageRules. After some months using it I realized that going (from time to time) through the pull requests checking and accepting them if the tests passed was a major waste of time. This is why the automerge is set to true, so Renovate automatically merges the pull request if the workflow passed successfully.</p><p>To restrict Renovate’s freedom a bit, we define that he only can perform the automerge when it is a minor or patch update. This way, if it is a major or another kind of update, we will be the ones to check whether that update should be added or not.</p><p><a href="https://docs.renovatebot.com/configuration-options/#updatetypes">Here</a> you can find more information about the update types available.</p><pre>&quot;packageRules&quot;: [<br>    {<br>      &quot;updateTypes&quot;: [<br>        &quot;minor&quot;,<br>        &quot;patch&quot;<br>      ],<br>      &quot;automerge&quot;: true<br>    }<br>  ],</pre><p>Lastly, we have the time schedule. If you work alone or in a team at certain hours it is nice to have the updates done at times when you are not working to avoid unnecessary distractions.</p><p>We select our timezone and add a custom <a href="https://docs.renovatebot.com/presets-schedule/">schedule</a> for it. You can find the valid timezone names <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">here</a>.</p><pre>&quot;timezone&quot;: &quot;Europe/Madrid&quot;,<br>  &quot;schedule&quot;: [<br>    &quot;after 10pm every weekday&quot;,<br>    &quot;before 5am every weekday&quot;,<br>    &quot;every weekend&quot;<br>  ],</pre><p>Anyway, if you do not care about the time the pull requests will be submitted, or the people that contribute to the code are in different timezones then you can remove this part.</p><p>Once we have updated the configuration we push the changes to GitHub to have the Renovate app adapted to the new configuration.</p><p>Now you finally have the project dependencies safely up-to-date without you having to check for them. <a href="https://github.com/reymon359/github-actions-and-renovate">Here is the resulting project</a> after following all the steps mentioned above.</p><p>Remember that if you added the time schedule part you will not get the pull request merged automatically until it complies with that configuration.</p><h3>Conclusion</h3><p>Although there are other ways to keep the dependencies updated in an automated way if you use GitHub to host your code you should take advantage and make the most of its awesome free features.</p><p>If you are wondering what else you are able to do and automate with the GitHub apps and actions just have a look at its <a href="https://github.com/marketplace">Marketplace</a>.</p><p>In addition, you can have a look at <a href="https://github.com/reymon359/up-to-date-react-template">a project I made</a> where I am working on from time to time and on which I based myself for this tutorial. It is a bit more complex and has more features than the one from this tutorial.</p><p>I hope you enjoyed the tutorial and learned about GitHub Actions and its Apps. If you’ve got any questions, suggestions, or feedback in general, don’t hesitate to reach out on any of the social networks from <a href="https://ramonmorcillo.com/">my site</a> or by mail.</p><h3>Useful Resources</h3><p>Here is a collection of links and resources which I think can be useful to improve and learn more about GitHub Actions and Apps.</p><ul><li><a href="https://github.com/reymon359/github-actions-and-renovate">Tutorial project</a>. — The resulting project from this tutorial.</li><li><a href="https://github.com/marketplace">GitHub Marketplace</a>. — The place to find all GitHub Actions and Apps.</li><li><a href="https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow">GitHub Actions Workflow Configuration</a> — The full documentation on how to set up a workflow on Github Actions.</li><li><a href="https://github.com/marketplace/renovate">Renovate GitHub app</a> — The Renovate App main page on the GitHub Marketplace.</li><li><a href="https://gist.github.com/reymon359/514cf378456457f1798293fe0ed99f3a">GitHub Actions project Workflow</a>. — The Workflow used in this tutorial.</li><li><a href="https://gist.github.com/reymon359/4c4417522cd0922cfbc63ad75ca2c945">Renovate App’s configuration file</a>. — Renovate App’s custom configuration file from the tutorial.</li><li><a href="https://github.com/reymon359/up-to-date-react-template">Up to Date React Template</a>. — A Personal project that uses the approach described in this tutorial.</li></ul><p>You can also read <a href="https://www.ramonmorcillo.com/auto-update-dependencies-safely-github-actions/">this post on my site</a> along with others!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b95a16e0a56a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidesmiths-dev/using-github-actions-and-renovate-app-to-safely-update-dependencies-automatically-b95a16e0a56a">Using GitHub Actions and Renovate App to safely update dependencies automatically</a> was originally published in <a href="https://medium.com/guidesmiths-dev">guidesmiths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphQL Hello World Server]]></title>
            <link>https://medium.com/guidesmiths-dev/graphql-hello-world-server-852b14537790?source=rss-65e62cb0015b------2</link>
            <guid isPermaLink="false">https://medium.com/p/852b14537790</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[apollo]]></category>
            <category><![CDATA[hello-world]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Ramon Morcillo]]></dc:creator>
            <pubDate>Thu, 07 May 2020 18:00:36 GMT</pubDate>
            <atom:updated>2021-01-29T16:55:46.939Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting started with GraphQL and Node.js</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfonmsCUx1kFBzJJr6Fu9g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@giabyte?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Gia Oris</a> on <a href="https://unsplash.com/@giabyte?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The main purpose of this server-client <a href="https://nodejs.org/en/">Node.js</a> project is to help other people <strong>understand how GraphQL exposes the data from the Server and the Client fetches it</strong>. I have tried to make it as simple as possible if you want to dive into the code of the project you can find it <a href="https://github.com/reymon359/graphql-hello-world-server">here</a>.</p><p>Now, straight to the point: <a href="https://graphql.org/">GraphQL</a> is a <strong>query language for </strong><a href="https://en.wikipedia.org/wiki/Application_programming_interface"><strong>APIs</strong></a> developed and <a href="https://engineering.fb.com/core-data/graphql-a-data-query-language/">open-sourced by Facebook</a> to speed up the request process.</p><p>While <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST</a> has been a popular way to expose data from a server, instead of having <strong>multiple endpoints</strong> that return fixed data structures, GraphQL just has <strong>a single endpoint</strong> and it is the client’s job to specify what data it needs from it.</p><h3>Table of Contents</h3><p><strong>– Getting started<br>– Define the Schema<br>– Add Resolver function<br>– Set up the Server<br>– Set up the Client<br>– Fetching data from the server<br>– Displaying the data<br>– Conclusion<br>– Useful resources</strong></p><h3>Getting started</h3><p>The first step is to <a href="https://nodejs.org/en/download/">download and install Node.js</a> in case you haven’t already. Once you have it installed let’s begin with the directory structure. The project will be composed of <strong>two directories</strong>, one for the Client and another for the Server. I have chosen to keep both inside the project root directory but then you can split it into two separate projects or any way you want.</p><pre>📁project <br>├── 📁client<br>└── 📁server</pre><p>Now we will initialize the project in the server directory. Change the location to the server folder in your terminal and run npm init to fill the project info and generate the <strong>package.json</strong> file. Or npm init -y which tells the generator to use the defaults (instead of asking questions and simply generate an empty npm project without going through an interactive process).</p><p>The next step will be to install <a href="https://github.com/graphql/graphql-js">GraphQL.js</a> and <a href="https://github.com/apollographql/apollo-server">Apollo Server</a> to our server. GraphQL.js will provide two important capabilities:</p><ul><li>Building a type schema, which we will do in the <a href="https://gist.github.com/reymon359/c1939cea6a8ccd729951a2c1c07a6821#define-the-schema">next step</a>.</li><li>Serving queries against that type schema.</li></ul><p>To install it just run npm install graphql. I am assuming you are using a version of NPM equal or higher than <strong>5.0.0</strong> so you <a href="https://blog.npmjs.org/post/161081169345/v500">do not need</a> to add --save when installing a dependency to be saved in the package.json</p><p>Apollo Server, on the other hand, will help us to implement the GraphQL functionalities. It is part of the <a href="https://www.apollographql.com/">Apollo Data Graph Platform</a>.</p><blockquote>Apollo is a platform for building a data graph, a communication layer that seamlessly connects your application clients (such as React and iOS apps) to your back-end services. Is an implementation of GraphQL designed for the needs of product engineering teams building modern, data-driven applications.</blockquote><blockquote>— <a href="https://www.apollographql.com/docs/">Apollo Documentation</a></blockquote><p>What you need to know about Apollo, at least for now, is it’s a community that builds on top of GraphQL, and provides different <strong>tools to help you build your projects</strong>. The tools provided by Apollo are mainly 2: Client and Server.</p><ul><li><strong>Apollo Client</strong> helps your Frontend communicate with a GraphQL API. It has support for the most popular frameworks such as React, Vue, or Angular and native development on iOS and Android.</li><li><strong>Apollo Server</strong> is the GraphQL server layer in your backend that delivers the responses back to the client requests.</li></ul><p>Now that you understand Apollo better and why we will use it, let’s continue setting up GraphQL.</p><h3>Define the Schema</h3><p>A GraphQL Schema is at the core of any GraphQL server implementation. It <strong>describes the shape of your data,</strong> defining it with a hierarchy of <strong>types</strong> with fields that are populated from your data source and also specifies which <strong>queries</strong> and <strong>mutations</strong> are available so the client knows about the information that can be requested or sent.</p><p>For example, if we wanted to build a music application, our simplest schema, usually defined in a schema.graphql file, would contain two <strong>Object types</strong>: Song and Author like this</p><pre>type Song { <br>  title: String <br>  author: Author <br>} </pre><pre>type Author { <br>  name: String <br>  song: [Song] <br>}</pre><p>Then we would have a <strong>Query type</strong> to define the available queries: getSongs and getAuthors, each returning a list of the corresponding type.</p><pre>type Query { <br>  getSongs: [Song] <br>  getAuthors: [Author] <br>}</pre><p>To keep it as simple as possible our schema will have just <strong>a single Query</strong> type which will return a String</p><pre>type Query {   <br>  greeting: String <br>}</pre><p>We can use <strong>any programming language</strong> to create a GraphQL schema and <strong>build an interface around it</strong> but as I explained before we will use Apollo server to execute GraphQL queries. So we create a new server.js file in the server directory to define the Schema on it.</p><pre>📁project <br>├── 📁client <br>└── 📁server     <br>    └── 📄server.js</pre><p>Now we install apollo-server running npm install apollo-server</p><p>We have to import the <strong>tag function</strong> gql from <strong>apollo-server</strong> to parse the schema this way: const {gql} = require(&#39;apollo-server&#39;); and then declare a typeDefs constant which is an <a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree">abstract syntax tree</a> of the Graphql code.</p><blockquote>When a GraphQL server receives a query to process it generally comes in as a String. This string must be tokenized and parsed into a representation that the machine understands. This representation is called an abstract syntax tree.</blockquote><p>If you want to learn more about abstract syntax trees <a href="https://astexplorer.net/">AST Explorer</a> is an online tool that lets you explore the syntax tree created by a chosen language as a parser.</p><p>The server.js file would look like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d76383e35b61fbf8245471f59d58272b/href">https://medium.com/media/d76383e35b61fbf8245471f59d58272b/href</a></iframe><h3>Add Resolver function</h3><p>Now we have defined our Schema we need a way to answer the client requests for that data; the <strong>resolvers</strong>. <strong>A resolver is a function that handles the data for each one of the fields of your schema</strong>. You can send that data to the client by <strong>fetching a back-end database</strong> or a third-party <strong>API</strong> among others.</p><p>They have to <strong>match the type definitions of the Schema</strong>, in our case, we just have one type definition Query which returns a greeting of type String so we will define a resolver for the greeting field, like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06a3d857337851dd35c2fe35f6219b0f/href">https://medium.com/media/06a3d857337851dd35c2fe35f6219b0f/href</a></iframe><p>As I explained at the beginning we will keep this example as simple as possible but keep in mind that in a real case <strong>here is where you have to make the queries</strong> to the database, external API, or from wherever you intend to extract the query data.</p><h3>Set up the Server</h3><p>In the same server.js, we define and create a new ApolloServer object passing the Schema (typeDefs) and resolvers as parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/871dcfb7d001d5e18f123bf27d959905/href">https://medium.com/media/871dcfb7d001d5e18f123bf27d959905/href</a></iframe><p>Then calling the listen method we start the server on the port that we specify in the params.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4a6882c75ac61daaf769668e08daca5/href">https://medium.com/media/c4a6882c75ac61daaf769668e08daca5/href</a></iframe><p>We can also <strong>destructure</strong> the ServerInfo url when logging it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3253429c649e8a3d8e2845a0abfb2cb/href">https://medium.com/media/f3253429c649e8a3d8e2845a0abfb2cb/href</a></iframe><p>The server.js file should look like this right now.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/860f4d9cfb5344c5081dbb2f671871f4/href">https://medium.com/media/860f4d9cfb5344c5081dbb2f671871f4/href</a></iframe><p>Now if we run node server/server.js we will finally have our GrapqhQL server up and running 🎉!</p><p>You can go and check it on <a href="http://localhost:9000/">http://localhost:9000/</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58523694e8cfcf950df4e7fad87adc0c/href">https://medium.com/media/58523694e8cfcf950df4e7fad87adc0c/href</a></iframe><p>For the first time using GraphQL, you may be thinking <strong>what is this application I am seeing in front of me if we have not written a single line of client code?</strong>.</p><p>The answer to that question is the <strong>GraphQL Playground</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4d8jjEMXsinaTTQWNUR5A.png" /><figcaption>GraphQL Playground. Source: <a href="https://github.com/prisma-labs/graphql-playground">https://github.com/prisma-labs/graphql-playground</a></figcaption></figure><blockquote><a href="https://github.com/prisma-labs/graphql-playground">GraphQL Playground</a> is a graphical, interactive, in-browser GraphQL IDE, created by <a href="https://www.prisma.io/">Prisma</a> and based on <a href="https://github.com/graphql/graphiql">GraphiQL</a>.</blockquote><blockquote>— <a href="https://www.apollographql.com/docs/apollo-server/testing/graphql-playground/">Apollo docs</a></blockquote><p>But what does that mean? It means that this is an environment where we can perform Queries, Mutations, or Subscriptions to our schema and interact with its data.</p><p>If you have worked with <strong>RESTful</strong> requests before this would be some kind of equivalent to <a href="https://www.postman.com/">Postman</a>, just that here you <strong>do not have to download and configure anything</strong>, it just <strong>comes by default</strong> with Apollo!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*9WDBlKblNlLEIjc5HM6Zww.gif" /></figure><p>So let’s try it!</p><ol><li>On the left panel write the greeting query we defined in our schema.</li><li>Then press the ▶ button that is in the middle.</li><li>And <em>Voila!</em> On the right panel appears the data we defined in our resolver to return.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*dpUqp55LiEX-6Mz0XBgp4w.gif" /><figcaption>Writing query on GraphQL Playground</figcaption></figure><h3>Set up the Client</h3><p>Now that we have our server up and running let’s focus on the client part. We will start creating a client.html file inside our client folder.</p><pre>📁project<br>├── 📁client <br>|   └── 📄client.html <br>└── 📁server<br>    └── 📄server.js</pre><p>The index.html file will have the basics of any HTML file and a loading header &lt;h1&gt;Loading...&lt;/h1&gt; to show the user something while we request the data from the server.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/908e6661cd3fb74b460eac318626b18d/href">https://medium.com/media/908e6661cd3fb74b460eac318626b18d/href</a></iframe><h3>Fetching data from the server</h3><p>First off, in the same client folder, we create an app.js file where we will write the client logic to fetch the data from the server.</p><pre>📁project <br>├── 📁client <br>|   └── 📄client.html <br>|   └── 📄app.js <br>└── 📁server     <br>    └── 📄server.js</pre><p>Inside it, we set the server url to which we will make the request.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2eeee927424f00dd154332fa141720dd/href">https://medium.com/media/2eeee927424f00dd154332fa141720dd/href</a></iframe><p>Next, we define our async function fetchGreeting() to, fetch the greeting from the server. We will use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch">fetch API</a> to perform the HTTP request which by default returns a promise to which we can subscribe and get the answer in an asynchronous way.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b49b13dc4d1ec7bc67cce807b7a07954/href">https://medium.com/media/b49b13dc4d1ec7bc67cce807b7a07954/href</a></iframe><p>A detail to take into account is that the method of the request is POST, which can confuse us if we are used to working with RESTful because this same request made in RESTful, where we just want to read information from the server, would be usually done using the method GET.</p><p>The thing is that with GraphQL we always make POST requests where we pass <strong>the query in the payload</strong> (body).</p><p>Finally, we just call our method fetchGreeting();</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec8adf457f5aa53ca48e5ff7383c0b99/href">https://medium.com/media/ec8adf457f5aa53ca48e5ff7383c0b99/href</a></iframe><p>If you open the file in your browser and see the <strong>console on the developer tools</strong> you can see that we actually got the greeting data from the query 🙌!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*hPBvlRkZpn1UD_umJ3nT-g.png" /><figcaption>Fetching data from the server</figcaption></figure><h3>Displaying the data</h3><p>Now that we have successfully got the data from the server let’s <strong>update the loading title</strong>. The first thing we will do is destructure the response and return just the data from it.</p><p>Just replace this part of the code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb8c2340a5d9162d7f5d79f21e0d88f9/href">https://medium.com/media/fb8c2340a5d9162d7f5d79f21e0d88f9/href</a></iframe><p>With this one</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a81fff3393626f9649051d5c892a4b51/href">https://medium.com/media/a81fff3393626f9649051d5c892a4b51/href</a></iframe><p>And then we will update the title with the greeting returned <strong>inside the data from the response</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85e538340e09580836c1b426210e127c/href">https://medium.com/media/85e538340e09580836c1b426210e127c/href</a></iframe><p>So our app.js file will end up having this look</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4f28ecdb06ecb39833b7f419a632dae/href">https://medium.com/media/e4f28ecdb06ecb39833b7f419a632dae/href</a></iframe><p>And our index.html will have the loading title updated with the data fetched from our server! 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*lDwLqG9rWjbqYl5tbBZ60g.png" /><figcaption>Displaying the data</figcaption></figure><h3>Conclusion</h3><p>I hope you enjoyed the post and that this project has fulfilled the objective of showing <strong>how graphql works under the hood</strong>, at least in a very simple way. I know there are a lot of things that I have not explained or that I could have gone deeper but like any hello world project, it is intended for people who are beginners with it, so I wanted to keep it as simple as possible.</p><p>I’m looking forward to learning more about GrapqhQL and using it in future projects. If you’ve got any questions, suggestions, or feedback in general, don’t hesitate to reach out on any of the social networks from <a href="https://ramonmorcillo.com/">my site</a> or by mail.</p><h3>Useful resources</h3><p>Here is a collection of links and resources which have been useful for me to improve and learn more about GraphQL</p><h4><strong>Docs 📚</strong></h4><ul><li><a href="https://github.com/reymon359/graphql-hello-world-server">Project source code</a> — The Github repository with all the code from the project.</li><li><a href="https://graphql.org/">GraphQL main site</a> — GraphQL main site.</li><li><a href="https://graphql.org/">Apollo documentation</a> — The Apollo platform docs.</li></ul><h4><strong>Learn 📝</strong></h4><ul><li><a href="https://www.howtographql.com/">How to GraphQL</a> — Free and open-source tutorials to learn all around GraphQL to go from zero to production.</li><li><a href="https://www.udemy.com/course/graphql-by-example/">GraphQL by Example</a> — Great course where you learn GraphQL by writing full-stack JavaScript applications with Node.js, Express, Apollo Server, React, Apollo Client.</li><li><a href="https://graphql.org/learn/">Introduction to GraphQL</a> — A series of articles to learn about GraphQL, how it works, and how to use it.</li></ul><h4>Tools 🔧</h4><ul><li><a href="https://www.apollographql.com/">Apollo GraphQL</a> — Main site of the Apollo GraphQL implementation.</li><li><a href="https://github.com/prisma-labs/graphql-playground">GraphQL Playground</a> — Repository of the GraphQL Playground IDE we used on the project.</li></ul><h4>IDEs 💻</h4><ul><li><a href="https://plugins.jetbrains.com/plugin/8097-js-graphql">JS GraphQL</a> — WebStorm and other IntelliJ-based IDEs plugin to support GraphQL language including tagged template literals in JavaScript and TypeScript.</li><li><a href="https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql">GraphQL</a> — GraphQL extension for VSCode adds syntax highlighting, validation, and language features like go to definition, hover information, and autocompletion for GraphQL projects. This extension also works with queries annotated with gql tag.</li><li><a href="https://marketplace.visualstudio.com/items?itemName=kumar-harsh.graphql-for-vscode">GraphQL for VSCode</a> — VSCode GraphQL syntax highlighting, linting, auto-complete, and more!</li></ul><h4>Extras 🍍</h4><ul><li><a href="https://github.com/APIs-guru/graphql-apis">GraphQL APIs</a> — A list of public GraphQL APIs to test your skills or to build something with them.</li><li><a href="https://www.youtube.com/watch?v=783ccP__No8">GraphQL: The Documentary</a> — A 30 min video that explores the story of why and how GraphQL came to be and the impact it’s having on big #tech companies worldwide, including Facebook, Twitter, Airbnb, and Github.</li></ul><p>You can read <a href="https://www.ramonmorcillo.com/getting-started-with-graphql-and-nodejs/">this post on my site</a> along with others!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=852b14537790" width="1" height="1" alt=""><hr><p><a href="https://medium.com/guidesmiths-dev/graphql-hello-world-server-852b14537790">GraphQL Hello World Server</a> was originally published in <a href="https://medium.com/guidesmiths-dev">guidesmiths</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>