<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Oriol Gual</title>
    <description>The latest articles on Forem by Oriol Gual (@oriolgual).</description>
    <link>https://forem.com/oriolgual</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F214858%2F5b056af8-cadf-4a9f-a178-1a2e4ac1e1fe.jpeg</url>
      <title>Forem: Oriol Gual</title>
      <link>https://forem.com/oriolgual</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/oriolgual"/>
    <language>en</language>
    <item>
      <title>Talk Club Sessions: #1 Dark patterns</title>
      <dc:creator>Oriol Gual</dc:creator>
      <pubDate>Mon, 23 Sep 2019 09:28:23 +0000</pubDate>
      <link>https://forem.com/codegram/talk-club-sessions-1-dark-patterns-2a1d</link>
      <guid>https://forem.com/codegram/talk-club-sessions-1-dark-patterns-2a1d</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://www.codegram.com/blog/talk-club-sessions-1-dark-patterns"&gt;Codegram's blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  From Lunch talks to The Talk Club™
&lt;/h2&gt;

&lt;p&gt;During this year we had a &lt;a href="https://www.codegram.com/blog/tag/lunch-talks"&gt;few posts&lt;/a&gt; on the lunch talks series: every two weeks one of us would prepare a video playlist around a topic and then we watched the videos during our lunchtime. &lt;/p&gt;

&lt;p&gt;It was a nice experience but it had some issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only the people that were at the office could watch the talks at the same time&lt;/li&gt;
&lt;li&gt;We were forcing everyone to do the same at the same time, not having much flexibility&lt;/li&gt;
&lt;li&gt;Not a lot of discussions sparked since we didn't have a lot of time after watching the videos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For these many reasons, we decided to try a new approach: The Talk Club! It's like a book club but not limited to books: anything we can learn from can be discussed. &lt;/p&gt;

&lt;p&gt;Instead of forcing everyone to do the same altogether, we propose a date to talk about an interesting video, article or piece of technology. People consume the content at their own preferred time and pace, take some notes, prepare some questions or topics to talk about, and then we have a nice chat in a remote-friendly meeting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dark patterns
&lt;/h2&gt;

&lt;p&gt;In this first session we talked about &lt;em&gt;&lt;strong&gt;Dark Patterns: User Interfaces Designed to Trick People&lt;/strong&gt;&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/1KVyFio8gw4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Dark Patterns are tricks used in websites and apps that make you do things that you didn't mean to, like buying or signing up for something&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This video by Harry Brignull from 2014 introduces the concept of Dark Patterns, it's just 30 minutes long and a highly recommended watch. If you are in a hurry or just want a a compact and short version you can try &lt;a href="https://www.youtube.com/watch?v=kxkrdLI6e6M"&gt;How Dark Patterns Trick You Online&lt;/a&gt; from &lt;a href="https://twitter.com/TheeNerdwriter"&gt;Nerdwriter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This isn't a new topic, but it was nonetheless interesting. We spent over an hour discussing the various patterns and discovered we've also resorted to them in some occasions.&lt;/p&gt;

&lt;p&gt;The conversation triggered some interesting topics and questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Should there be an ethics code for the industry? If so, how could it be even implemented?&lt;/li&gt;
&lt;li&gt;How can we persuade our own clients not to  use this kind of practices? Especially when they are so effective&lt;/li&gt;
&lt;li&gt;As software developers, how should we deal when a manager tells us to implement a dark pattern? Could I lose my job if I object to do it?&lt;/li&gt;
&lt;li&gt;When working in &lt;a href="https://www.codegram.com/our-work/decidim"&gt;Decidim&lt;/a&gt;, we were able to say no to some features since we were backed by its &lt;a href="https://docs.decidim.org/social-contract/en/social-contract/"&gt;social contract&lt;/a&gt;. Having such contracts empowers developers into taking responsibility and prevents discussions about whether something should make into the product or not&lt;/li&gt;
&lt;li&gt;In other industries, such as food or ads, there are laws against what could be considered dark patterns, would it be possible to create similar laws for the digital world?&lt;/li&gt;
&lt;li&gt;We (as an industry) seem to be obsessed by metrics, and making every decision based on how well are we performing on said metrics. This seems to push people into using more doubtful techniques to keep the numbers growing, even at the cost of the user experience (see &lt;a href="https://en.wikipedia.org/wiki/Goodhart%27s_law"&gt;Goodhart's law&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see, we didn't change the world or even get some answers, but I couldn't be happier with this first edition. We had a very nice chat and it made us think and reflect on our work. I'm sure these conversations will have an impact in our future work and I'm eager to share more experiences like this in the upcoming months, I highly recommend trying this with your team!&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.darkpatterns.org/"&gt;The Dark Patterns website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://darkpatterns.uxp2.com/"&gt;Dark Patterns Hall of Shame&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://webtransparency.cs.princeton.edu/dark-patterns/"&gt;Dark Patterns at Scale: Findings from a Crawl of 11K Shopping Websites&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gimletmedia.com/shows/reply-all/6nhgol"&gt;Dark Patterns episode at Reply All podcast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://firstdonoharm.dev"&gt;The Hippocratic License for Open Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>darkpatterns</category>
    </item>
    <item>
      <title>Building a Ruby Serverless CI &amp; CD pipeline</title>
      <dc:creator>Oriol Gual</dc:creator>
      <pubDate>Thu, 29 Aug 2019 09:14:02 +0000</pubDate>
      <link>https://forem.com/codegram/building-a-ruby-serverless-ci-cd-pipeline-35m5</link>
      <guid>https://forem.com/codegram/building-a-ruby-serverless-ci-cd-pipeline-35m5</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://www.codegram.com/blog/serverless-ruby-ci-cd"&gt;Codegram's blog&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;When facing a serverless project, the last thing we probably want to worry about as developers is infrastructure or deployment. We just want to make sure that as soon as we are certain our app is working OK, it is deployed as easily as possible. This could also be applied to any kind of project of course, but I think it fits specially well in a serverless one.&lt;/p&gt;

&lt;p&gt;In this example, we're going to use the &lt;a href="https://serverless.com"&gt;Serverless framework&lt;/a&gt;, which already does a lot of the work, but I still found myself repeating the same tasks and code between different projects each time I had to create the continuous integration &amp;amp; deployment pipeline.&lt;/p&gt;

&lt;h3&gt;
  
  
  The pipeline
&lt;/h3&gt;

&lt;p&gt;So, how should this pipeline look? Which steps do we want to have to make sure everything works OK? To me, it should look something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The developer works on a new feature on a new Git branch.&lt;/li&gt;
&lt;li&gt;They create a new Pull Request to keep pushing the changes.&lt;/li&gt;
&lt;li&gt;A Continuous Integration system runs the test suite and maybe some linters.&lt;/li&gt;
&lt;li&gt;When the Pull Request is approved and reviewed by their peers, it gets merged to the main branch.&lt;/li&gt;
&lt;li&gt;The Continuous Deployment system kicks in (which can be the same as the CI) and deploys the new features.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After repeating this process in different projects, I thought it was time to abstract some of the common code and best practices like dealing with dependencies, CI cache, building, deployment and so on.&lt;/p&gt;

&lt;h3&gt;
  
  
  A real world example
&lt;/h3&gt;

&lt;p&gt;Continuing from a previous post on &lt;a href="https://www.codegram.com/blog/ruby-lambda-bff/"&gt;how to create a Serverless GraphQL API with Ruby&lt;/a&gt;, I updated the project to add some tests and auto-deployment with CircleCI. Check out this &lt;a href="https://github.com/oriolgual/serverless-ruby-graphql/pull/1/files"&gt;pull request&lt;/a&gt; to see how easy it was!&lt;/p&gt;

&lt;p&gt;To start, we'll need a CircleCI account and &lt;a href="https://www.circleci.com/docs/2.0/language-ruby"&gt;setup the project with it&lt;/a&gt;. Then add the AWS credentials to Circle so it can be automatically deployed. I recommend following &lt;a href="https://serverless.com/framework/docs/providers/aws/guide/credentials/"&gt;these instructions&lt;/a&gt; to create an IAM user for your project.&lt;/p&gt;

&lt;p&gt;To add the AWS credentials go to the project's settings page, and add the &lt;code&gt;AWS_ACCESS_KEY_ID&lt;/code&gt; and &lt;code&gt;AWS_SECRET_ACCESS_KEY&lt;/code&gt; variables with the values you goot from the AWS console. Since this are the default environment variable names, Serverless will use them when deploying.&lt;/p&gt;

&lt;p&gt;After that, we need to add CircleCI's configuration to the project:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;.circleci/config.yml&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.1&lt;/span&gt;

  &lt;span class="na"&gt;orbs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="na"&gt;serverless-ruby&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;codegram/serverless-ruby@0.0.3&lt;/span&gt;

  &lt;span class="na"&gt;workflows&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="na"&gt;main&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;serverless-ruby/test&lt;/span&gt;
       &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;serverless-ruby/deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
           &lt;span class="na"&gt;requires&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
             &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;serverless-ruby/test&lt;/span&gt;
           &lt;span class="na"&gt;filters&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
             &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
               &lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file uses our &lt;a href="https://circleci.com/orbs/registry/orb/codegram/serverless-ruby"&gt;Circle CI Serverless Ruby orb&lt;/a&gt; (more on this later) and then sets a workflow with two jobs: one to run the test suite and one to deploy the code when it's merged to the &lt;code&gt;master&lt;/code&gt; branch.&lt;/p&gt;

&lt;p&gt;Finally, we need to tune the &lt;code&gt;serverless.yml&lt;/code&gt; file in order to get smaller builds with just these lines:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;serverless.yml&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;package&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;**'&lt;/span&gt;
  &lt;span class="na"&gt;include&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app/**&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;vendor/**&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*.rb'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These lines tell the Serverless framework to exclude all the files in the root directory and only include our application code at &lt;code&gt;app&lt;/code&gt;, the packaged gems at &lt;code&gt;vendor&lt;/code&gt; and all Ruby files at the root, since there's where &lt;a href="https://github.com/oriolgual/serverless-ruby-graphql/blob/master/app.rb"&gt;app.rb&lt;/a&gt; is located (the project's entrypoint; the file AWS Lambda calls to process each request).&lt;/p&gt;

&lt;p&gt;That's it, we now have a fully CI &amp;amp; CD serverless pipeline 🎉.&lt;/p&gt;

&lt;h3&gt;
  
  
  CI &amp;amp; CD process explained
&lt;/h3&gt;

&lt;p&gt;Early on I mentioned that we were using a CircleCI orb. For those who don't know: orbs are a way to share common configuration, jobs, commands, etc. in a CircleCI configuration file. This way you don't have to repeat the same code and setup between projects and you can benefit when an orb is updated. We created it not only to avoid repeating code but also to share some best practices and solve common issues in this kind of projects.&lt;/p&gt;

&lt;p&gt;In the example project, previously to using the orb, the deploy process was far from ideal. Lambda needs to package all your code and dependencies into a single ZIP file and since we're in the Ruby land this means packaging also our gems. Usually when using Bundler all your gem sources are stored in your home directory, but this doesn't work when you need to include them in the ZIP file. So what I needed a Serverless plugin to hook into the package step, run &lt;code&gt;bundle install --deployment&lt;/code&gt; to include all the gems content at the project folder, then deploy and then cleanup the &lt;em&gt;mess&lt;/em&gt; by removing the &lt;code&gt;vendor&lt;/code&gt; and &lt;code&gt;.bundle&lt;/code&gt; directories from the project root.&lt;/p&gt;

&lt;p&gt;This approach was quite prone to errors since I was deploying from my own computer and the gem dependencies weren't built in the same environment they would run.&lt;/p&gt;

&lt;p&gt;So, what does the orb do?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Builds the gem dependencies using Docker, this allows having gems with native extensions since they'll be compiled with the same environment as AWS Lambda.&lt;/li&gt;
&lt;li&gt;Efficiently manages all the caches so the builds are fast between runs and you don't lose time waiting on them.&lt;/li&gt;
&lt;li&gt;If your project uses DynamoDB, it will install the dependencies and start a database before the test suite runs.&lt;/li&gt;
&lt;li&gt;Runs the test suite with &lt;code&gt;rspec&lt;/code&gt; and uploads the test results using &lt;code&gt;RspecJunitFormatter&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Deploys the project with &lt;code&gt;serverless&lt;/code&gt; and excludes all test and development dependencies with each commit to master.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;All these steps could be migrated to your favourite CI system, as they don't depend on CircleCI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I'm very happy with the end result, now our Serverless Ruby projects are deployed blazingly fast and with the certainty that everything is working OK. An improvement could be creating different deployments for each Pull Request so we don't have to deploy development environments from our computer, but this is a story for another time!&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Ruby &amp; AWS Lambda, 💖 BFF 💖</title>
      <dc:creator>Oriol Gual</dc:creator>
      <pubDate>Wed, 02 Jan 2019 10:00:00 +0000</pubDate>
      <link>https://forem.com/codegram/ruby-aws-lambda-bff-6mf</link>
      <guid>https://forem.com/codegram/ruby-aws-lambda-bff-6mf</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://www.codegram.com/blog/ruby-lambda-bff"&gt;Codegram's blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As a Serverless enthusiast at Codegram it was about time I published a new blog post since AWS Lambda has introduced official support for Ruby 🎉.&lt;/p&gt;

&lt;p&gt;You can read more at the &lt;a href="https://aws.amazon.com/blogs/compute/announcing-ruby-support-for-aws-lambda/"&gt;official release blog post&lt;/a&gt; which also has an &lt;a href="https://github.com/aws-samples/serverless-sinatra-sample"&gt;example Sinatra app&lt;/a&gt; to get started. If you want an in-depth review of the example and release, I recommend &lt;a href="https://blog.eq8.eu/article/sinatra-on-aws-lambda.html"&gt;this nice review&lt;/a&gt; from EquiValent.&lt;/p&gt;

&lt;p&gt;I was thrilled to learn that I can finally use Ruby with Lambda, but using Sinatra as an example feels wrong. If you want to build an API with it, you would want to have API Gateway do all the routing and request handling. Adding an extra layer to do the same at the application level is unnecessary and seems like an anti-pattern (I understand it’s used as an example of migrating microservices, but it’s still confusing).&lt;/p&gt;




&lt;p&gt;After talking about it with my fellow Codegrammers I decided to build a small &lt;a href="https://github.com/oriolgual/serverless-ruby-graphql"&gt;proof-of-concept GraphQL API with Ruby and Lambda&lt;/a&gt;, using &lt;a href="https://serverless.com"&gt;Serverless&lt;/a&gt; to simplify the deployment and infrastructure, without Sinatra, Rack or any boilerplate.&lt;/p&gt;

&lt;p&gt;The objective was to demonstrate that you can build an API and almost forget that you’re actually dealing with web requests, just focus on the GraphQL schema and the business logic. How does it look like? There are three key elements: &lt;em&gt;&lt;strong&gt;serverless.yml&lt;/strong&gt;&lt;/em&gt; exposes our function through an HTTP POST:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;serverless-ruby-graphql&lt;/span&gt;

&lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws&lt;/span&gt;
  &lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby2.5&lt;/span&gt;
  &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eu-west-1&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dev&lt;/span&gt;

&lt;span class="na"&gt;functions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app.request&lt;/span&gt;
    &lt;span class="na"&gt;events&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;api&lt;/span&gt;
          &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;post&lt;/span&gt;

&lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;serverless-hooks-plugin&lt;/span&gt;

&lt;span class="na"&gt;custom&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;package:initialize:&lt;/span&gt;
      &lt;span class="s"&gt;- bundle install --deployment&lt;/span&gt;
    &lt;span class="s"&gt;deploy:finalize:&lt;/span&gt;
      &lt;span class="s"&gt;- rm -fr .bundle&lt;/span&gt;
      &lt;span class="s"&gt;- rm -fr vendor&lt;/span&gt;
      &lt;span class="s"&gt;- bundle install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;app.rb&lt;/strong&gt;&lt;/em&gt; handles the incoming requests and delegates all the work to GraphQL Ruby:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'json'&lt;/span&gt;
&lt;span class="nb"&gt;require_relative&lt;/span&gt; &lt;span class="s2"&gt;"app/graphql/schema"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:)&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"Received Request: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

  &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nf"&gt;to_json&lt;/span&gt;

  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="ss"&gt;statusCode: &lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;body: &lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;rescue&lt;/span&gt; &lt;span class="no"&gt;StandardError&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;message&lt;/span&gt;
  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;backtrace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inspect&lt;/span&gt;

  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="ss"&gt;statusCode: &lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="ss"&gt;body: &lt;/span&gt;&lt;span class="no"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Bad request, please POST a request body!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, &lt;em&gt;&lt;strong&gt;app/&lt;/strong&gt;&lt;/em&gt; a folder with all the GraphQL schemas and models:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/oriolgual/serverless-ruby-graphql/tree/master/app"&gt;https://github.com/oriolgual/serverless-ruby-graphql/tree/master/app&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Although this works OK, keep in mind that it is not production-ready code.&lt;/em&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Let's build everything with Lambda
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZQIavaLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q5p5yd19rvspce1wyxnf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZQIavaLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q5p5yd19rvspce1wyxnf.jpg" alt="" width="400" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, maybe not. Building things with AWS Lambda and Ruby is straightforward, but would I build my next GraphQL API with it? Probably not.&lt;/p&gt;

&lt;p&gt;I’m not entirely sold on using AWS Lambda with user-facing APIs; response times are too unpredictable and quite high (yes, even if you keep your Lambdas &lt;a href="https://serverless.com/blog/keep-your-lambdas-warm/"&gt;warm&lt;/a&gt;). Things get [even]((&lt;a href="https://www.robertvojta.com/aws-journey-api-gateway-lambda-vpc-performance/"&gt;https://www.robertvojta.com/aws-journey-api-gateway-lambda-vpc-performance/&lt;/a&gt;) &lt;a href="https://www.reddit.com/r/aws/comments/6lfubn/aws_lambda_vpc_redis_slow/"&gt;slower&lt;/a&gt; if your Lambda needs to access resources inside a VPC (which is necessary if you want to access a database for example).&lt;/p&gt;

&lt;p&gt;I really like Lambda, but I think it shines when used to respond to events (such as S3 uploads or Kinesis streams) where you don’t really care about some extra latency but scalability can be an issue.&lt;/p&gt;

&lt;p&gt;I’m eager to try something similar with &lt;a href="https://github.com/knative/docs/"&gt;Knative&lt;/a&gt;, &lt;a href="https://kubeless.io"&gt;Kubeless&lt;/a&gt; or &lt;a href="https://openwhisk.apache.org"&gt;OpenWhisk&lt;/a&gt;. So far I’ve only used AWS Lambda, and I’d like to compare it to other solutions and get a better idea whether it would be a good option to deploy serverless, user-facing APIs.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>ruby</category>
      <category>serverless</category>
    </item>
  </channel>
</rss>
