<?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 Amo Moloko on Medium]]></title>
        <description><![CDATA[Stories by Amo Moloko on Medium]]></description>
        <link>https://medium.com/@PrinceAshburton?source=rss-a6d2ffd91457------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7YsiDHcKoAvhI3Hh1tl65A.jpeg</url>
            <title>Stories by Amo Moloko on Medium</title>
            <link>https://medium.com/@PrinceAshburton?source=rss-a6d2ffd91457------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:57:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@PrinceAshburton/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[Migrating from the Serverless Framework to AWS CDK]]></title>
            <link>https://medium.com/@PrinceAshburton/migrating-from-the-serverless-framework-to-aws-cdk-bff84e550d81?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/bff84e550d81</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 11:05:20 GMT</pubDate>
            <atom:updated>2024-03-05T10:29:47.479Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1DA2EKCF_dWbtkT0OHG7sg.png" /></figure><p><a href="https://en.wikipedia.org/wiki/Serverless_computing">Serverless</a> as a technology is no longer a fad as we venture into 2024. <a href="https://www.aleios.com/">Aleios</a> who have done an amazing job at helping large organisations get to grips with the technology and realize its operational cost savings, held the Cape Town edition of <a href="https://capetown.serverlessdays.io/">Serverless Days</a> (unsurprisingly) in October of 2023 to learn what the community has been building with Serverless.</p><p>This post is a written version of the talk I gave at Serverless Days about how the Team at <a href="http://tripplo.co/">Tripplo</a> migrated away from the <a href="https://www.serverless.com/">Serverless Framework</a> and adopted the AWS <a href="https://aws.amazon.com/cdk/">Cloud Development Kit (CDK)</a>.</p><h4>Backstory on Tripplo</h4><p>Tripplo was founded in 2019 by our CEO Victor who was working at an investment company while running a fleet of trucks as a side hustle. Like all great founders, he quickly grew tired of the admin and inefficiencies he was experiencing while running his fleet and decided it was time to solve his own problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64ECtGbHuTVe0KbEwZP6ew.jpeg" /><figcaption>The Tripplo team circa 2020 at the Founders Factory Africa (FFA) offices in Johannesburg</figcaption></figure><p>He corroborated with fellow truck owners in Johannesburg to understand if they were going through a similar problem. He started making Excel spreadsheet macros to alleviate the problem, however this was just a stop gap solution until he came up with a hypothesis that there would be a gap in the South African market for a SaaS product geared around Fleet Management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ttSNb0uvHEY4rpcg29suw.png" /><figcaption>My Fleet: Allows transporters to manage trucks,trailer &amp; drivers</figcaption></figure><p>At the start of 2020, we came out and launched My Fleet! Which allowed transporters to manage their trucks, trailers and drivers in one UI. As well as see when their permits such as vehicle licenses, cross-border permits, passports, etc expire.</p><p>However, a few months later the pandemic hit and it was apparent that Cargo Owners had excess capacity that they could not fulfil within the existing network of their transporters. Furthermore, smaller transporters struggle to get work for their fleet. Thus, we introduced the Loads Marketplace. At the time we coined it as the uberization of road freight, where we paired Cargo Owners/Brokers with transporters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t3Dfae-kBN5xoLHWHllfxQ.png" /><figcaption>Loads Marketplace: Cargo Owners can issue out loads to Transporters, upload load related documents and much more.</figcaption></figure><p>Once this kicked off, customers were asking us how can they see when their cargo will be at the loading point? Some transporters were complaining that they’d like an aggregated view of all the trucks that are on different tracking providers. I then scrambled to create Loads Tracking, which allowed Cargo Owners to see where their cargo is in real-time. Granted the transporter that was doing the load is registered with the five tracking providers we have partnered with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*klg44I_gdafb7DdK439j_Q.png" /><figcaption>Loads/Trip Tracking allows Cargo Owners &amp; Transporters to see where their cargo is.</figcaption></figure><p>In addition to getting all those three products off the ground, our work got recognised by Fast Company (South Africa) in 2021 as being the <a href="https://youtu.be/5D3WkyUVOr0?si=3CsxFlIEAPnK_Tp3&amp;t=3187">most innovative company</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoXObX_sGSJTMPnJFL4IqA.jpeg" /><figcaption>Fast Company Award for being the Most Innovative Company of 2021 and An Award from Africa Arena.</figcaption></figure><p>You might be wondering why you’ve read this far and thinking if you have received a mini Sales Pitch ? Well partially 0.000001% yes and 99.999999% no. I believe everything I have mentioned will provide value when I get to explaining what tools we used to solve the various business problems above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFNl1VeF8bKIEdWuvvDTEA.jpeg" /><figcaption>Victor at one of our customer’s warehouses during a pilot. I suspect he must have been on two Zoom calls at once.</figcaption></figure><h3><strong>Tripplo’s Tech stack</strong></h3><p><em>Our Philosophy</em></p><p>Tripplo was founded back in 2019, around this point in time Serverless was gaining a lot of traction and interest. Enterprises took a keen interest due to the cost savings that were accrued by adopting Serverless patterns. Also, the Serverless Framework was the most popular way for teams to reliably scale &amp; ship Serverless projects. This made it a no-brainer for us to adopt a Serverless <a href="https://aws.amazon.com/event-driven-architecture/">Event-Driven Architecture</a> hosted on AWS.</p><h3>Tools</h3><p>Let us have a quick run through of the different AWS tooling we are using.</p><p><strong>Compute</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQKc1zj_ALXjwQRFOSzYag.png" /></figure><p><a href="https://aws.amazon.com/lambda/"><strong>AWS Lambda</strong></a> — Amazon’s Serverless Function service that handles all your compute needs.</p><p><a href="https://aws.amazon.com/s3/"><strong>s3</strong></a> — Allows us to store objects in blob storage such as documents, our landing page &amp; React Web Apps.</p><p><a href="https://docs.aws.amazon.com/cognito/"><strong>Cognito User Pools</strong> </a>— A user management directory that has APIs to handle all your authentication needs.</p><p><a href="https://aws.amazon.com/dynamodb/"><strong>DynamoDB</strong></a> — A NoSQL database, I highly recommend reading <a href="https://www.dynamodbbook.com/">“The DynamoDB Book”</a> and <a href="https://www.youtube.com/watch?v=KYy8X8t4MB8">watching this talk</a> to understand how to use it properly. One thing to note is that you might not be able to query your data in a particular way months after using it if you have not designed your access patterns &amp; schema correctly.</p><p><strong>Application Integration</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y1nyuW0ovf_rD_qpL109Yg.png" /></figure><p><a href="https://aws.amazon.com/eventbridge/"><strong>Amazon EventBridge</strong></a> — An event-bus tool that allows you to publish events and fan out messages to different parts of your infrastructure.</p><p><a href="https://aws.amazon.com/sns/"><strong>SNS</strong></a> — Simple Notification Service, allows you to create topics to consume and send out to other AWS services.</p><p><a href="https://aws.amazon.com/sqs/"><strong>SQS</strong></a> — Simple Queue Service enables you to create and publish data to queues, this is helpful for our intra-service communication.</p><p><a href="https://aws.amazon.com/location/"><strong>Location Service</strong></a> — This service enables you to create Geofences, Routing, reverse geocoding and other location related functionality.</p><p><strong>Analytics</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cWVB7E6HseCzDW2Ab2BwjQ.png" /></figure><p><a href="https://docs.aws.amazon.com/athena/latest/ug/what-is.html"><strong>Athena</strong></a> — A SQL database that reads data from a s3 bucket for data analysis.</p><p><a href="https://aws.amazon.com/kinesis/"><strong>Kinesis</strong></a> — Allows you to stream data from various sources and send it to a destination data source like Redshift or other Lambdas.</p><p><a href="https://aws.amazon.com/opensearch-service/"><strong>OpenSearch</strong></a> — Amazon’s ElasticSearch replacement that we use to query our records that are in DynamoDB that gives us lighting search results.</p><p><a href="https://aws.amazon.com/quicksight/"><strong>QuickSight</strong></a> — AWS’ PowerBI alternative that helps us surface the data from Athena for our internal BI needs.</p><p><a href="https://aws.amazon.com/glue/"><strong>Glue</strong></a> — AWS Glue schemas allow us to query data from Athena.</p><p><strong>Runtime</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6mJlE_iv0GMh9RN7Em18Q.png" /></figure><p><a href="https://www.typescriptlang.org/"><strong>TypeScript</strong></a> — We are a full JavaScript shop that allows developers of all skill levels to drive value across the stack for the company.</p><p><a href="https://react.dev/"><strong>React</strong></a><strong>/</strong><a href="https://reactnative.dev/"><strong>React Native</strong></a> — Our web clients are written in React while React Native allows us to target Android &amp; iOS.</p><h3><strong>Patterns</strong></h3><p><strong><em>S3 to DynamoDB</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDKNOhFvpQYkOL4ccDPA2g.png" /></figure><p>In logistics whether it be long-haul or last mile delivery, transporters need to provide proof that the cargo has been dropped off. This done by the use of a Proof-Of-Delivery (POD).</p><p>When uploading a POD onto Tripplo, they upload the document into a bucket and it triggers a Lambda event which then can write the payload to DynamoDB to indicate that the load is actually complete.</p><p>Below is a snippet of how we achieve the s3 to DynamoDB pattern:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86ab2780ae961d419ed4572c43997918/href">https://medium.com/media/86ab2780ae961d419ed4572c43997918/href</a></iframe><p><strong><em>SQS to SES</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMX29034JVYFPcoAqHyQcA.png" /></figure><p>We love using SQS to send out emails or complete other child related processes. In our case when a Cargo Owner creates a load, the Parent Lambda dumps the data into SQS which triggers another Lambda that then fires off an email with the help of SES.</p><p>This works well for us to be able to isolate which areas a particular bug might be occurring and gives us separate CloudWatch logs.</p><p>Below is a snippet of how you could use SQS together with SES:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85fb27c9b52fd60655db639c943f2298/href">https://medium.com/media/85fb27c9b52fd60655db639c943f2298/href</a></iframe><p><strong><em>Location — EB — Lambda</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ugz71CAqaBbRZy57LgpB4w.png" /></figure><p>When a truck triggers a <a href="https://www.verizonconnect.com/glossary/what-is-a-geofence/#:~:text=A%20geofence%20is%20a%20virtual,straight%20line%20between%20two%20points.">geofence</a> event, Location Service fires up an event to EventBridge which then allows us to consume that event for pre-processing in other Lambdas to consume as we please, as you can see below in the snippet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0cc91a4a09aa22593409cfd0cf55b1c/href">https://medium.com/media/a0cc91a4a09aa22593409cfd0cf55b1c/href</a></iframe><h3><strong>Our Problems</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3QWfMsI8IaarXxtBt6%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3QWfMsI8IaarXxtBt6%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcHJ2eDdtemFnM20yYmlvZ25lanYxOG44OGxxeGw5NDc2ZzVnYnVxdyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3QWfMsI8IaarXxtBt6%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="363" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad721cad25da3d66df3f35e4b915b567/href">https://medium.com/media/ad721cad25da3d66df3f35e4b915b567/href</a></iframe><p>It is pretty great looking at all those cool patterns that we use on AWS right? However, some issues were not making us sleep so great at night. Lets dig into some of the issues that made certain facets of our developer experience terrible.</p><p><em>Mocking Our functions</em></p><p>To functionally test our code after completing a user story we would need to escape JSON and run the following command:</p><p>sls invoke local -s dev -f function_name -p path_to_json_mocks</p><p>You might be thinking why did these clowns not us Postman? Fairpoint, however mocking functions via the slscommand or Postman negates the fact that your new code is not being run against AWS’ limits for various services. Especially with Lambda there are a wide variety of <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html">limits</a> that you can run into if you are not aware of them beforehand!</p><p><em>Click Ops</em></p><p>Previous engineers made key resources via <a href="https://blog.equinix.com/blog/2022/12/01/what-is-clickops-and-how-can-you-prevent-it/">ClickOps</a> in the console. This prevented us from deploying this service into another region if the business case arose. Our initial DynamoDB tables and API Gateway configuration was created via the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2KEHAU586HL-CL6tEJUhPw.png" /></figure><p><em>Polyglot Repos</em></p><p>A pattern we started adopting was that for every new large module/feature we would create a service for it. An example would be that if a transporter wanted to maintain the service history of their truck or if we wanted to enable transporters to get early financing for their work, we would create a separate repo for that service,which would create a new API Gateway instance.</p><p>This illogical thinking eventually caught up with us, when working on new user stories you had to do mental gymnastics to figure out which services needed to be worked on simultaneously. Once a feature would go out to Production, we would frequently cause outages because we forgot to deploy one of the dependant services with the rest of our changes to Production.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FX6FFwR3gVK9ag%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbmN5bjB1Ymx5dzFzYjZ3cjB2YzVxYXVueTdxajc2cjZmYmUxemE4eiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FX6FFwR3gVK9ag%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbjQyb3RpY3EzZm1vemR4YjVxMGFrbno2a2d5anY1ODN0NnU2c3VoZyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FX6FFwR3gVK9ag%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="428" frameborder="0" scrolling="no"><a href="https://medium.com/media/824a8eba1b1c2b5b7343eb3c1ba96765/href">https://medium.com/media/824a8eba1b1c2b5b7343eb3c1ba96765/href</a></iframe><h3><strong>What were our options?</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FTrIzneEdpgAgw%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExYXV4aGt1eDZ6bDRyNWV1c3FuazN3Z2xicXQ3Z293ajd6ZGJ0bWV4dSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FTrIzneEdpgAgw%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExY2JtbG85Z2Rub2NvcHZ5Z3Rib3RpMGszNGNudDU4aGdqdGF5cmN3cSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FTrIzneEdpgAgw%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="296" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4b2cc0021e71ef56139def06ac855d3/href">https://medium.com/media/b4b2cc0021e71ef56139def06ac855d3/href</a></iframe><p>Coming to asses our options, we could have either stuck with what we know and make incremental improvements or hop onto a completely novel toolset to use as a team.</p><p>We could have opted to stick with the Serverless Framework by learning their new CI/CD solution, refactoring all these distributed repos into a MonoRepo and using <a href="https://github.com/localstack/localstack">LocalStack</a> to stimulate our AWS environment locally.</p><p>The second option was to truly adopt IaC and use AWS’ CDK, which is completely different from their Software Development Kit (SDK) that you use to interact with all their services. The CDK allows you to provision infrastructure in your favourite runtime of choice. Which in turns creates CloudFormation templates for you.</p><p>The CDK option was truly tempting however, it leaves you with a lot to do with regards to local development and CI/CD and does not have the batteries included that we needed.</p><p>Previously, we had been using the <a href="https://github.com/AnomalyInnovations/serverless-bundle">serverless-bundle</a> plugin that was created by the team over at <a href="https://anoma.ly/">Anomaly Innovations</a>. They also began seeking ways to move away from the Serverless Framework that powered most of <a href="https://seed.run/">Seed</a>. So they created <a href="https://sst.dev/">SST</a>!</p><p>SST is a TypeScript construct built on top of the CDK, that lets you provision CloudFormation Templates. Its worth mentioning that in early 2024 the SST team have decided to make a push to migrate away from the CDK and use Terraform and Pulumi under the hood. You can learn more about it in this <a href="https://sst.dev/blog/moving-away-from-cdk.html">blog post</a>.</p><p><strong>Key learnings</strong></p><p><em>Usage of existing Patterns</em></p><p>Before embarking on migrating a service, identify whether or not you are going to just get it over the line by migrating it to a new language/framework or whether or not you’re going to introduce a new pattern or not.</p><p>In our case, we ran into instances where by a DynamoDB Scan was being used for a particular endpoint, we had to decide whether putting additional work to supporting GSIs and Querying from the SDK was worth it or not. It is vital to catch this early on otherwise you could end up still keeping previous tech debt while trying to pay off previous tech debt.</p><p><em>Replicating Existing Workloads</em></p><p>When you and your team are working on particular endpoints, I’d highly recommend seeding your local storage (databases,buckets, etc) infrastructure with the same volume of data that is in production. Seems like something obvious but it can easily be overlooked, until you move your work into production and your Lambda is timing out because you did not account for the large payloads coming through.</p><p><em>Shutting Down Existing Services</em></p><p>Key task to plan for is how other services might be affected once a primary one is being migrated. In our case our Organisations service was being migrated with its DynamoDB table being moved into a different account as well. The problem was that our Alerts service was written in Python and pointing to resources from the Organisation service.</p><p>Looking at the engagement data, we made a tricky call to suspend the service. Due to having it written in Python and testing everything again to ensure it gets the data from the correct resources, it was not worth the time to add a patch job to a service that would be rewritten completely within the next month or so.</p><p><strong>Code comparison</strong></p><p>In the next section I’m going to go over some code comparison between how we setup our CloudFormation in YAML using the Serverless Framework and how we replicated it in TypeScript using SST.</p><p><em>DynamoDB vs YAML</em></p><p>First up we have an example of how we would setup our DynamoDB tables in YAML. This is pretty straight forward no real complaints other than you have to read YAML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ngZvTbZbb4onxBoU2ZlZfA.png" /></figure><p>Below is how we setup our tables using SST now. The bonus of doing it in TypeScript is that we can now make GSIs and field names dynamically or from a constants file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-DxQRfVrri0bcw1HhrOTw.png" /></figure><p><em>S3 vs YAML</em></p><p>What is prominent in this YAML file is the attachment of our SQS queues and their names. As well as the length of the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DKlW4xr7xAovTuDMRyFOfg.png" /></figure><p>As you can see here we have created a new s3 bucket stack in one line. While the rest of the code is import declarations and creation/exporting of a function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SuKN-6sxXBjuyRzidJohvg.png" /></figure><h3><strong>Did we manage to solve all of our problems?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sq8G2me2wBm72ytZF5LFDQ.png" /></figure><p>Key question now is did migrating to SST really solve the problems we were facing?</p><p>If you look below we have a list of all our REST APIs that we have created. This helps a lot because now we can invoke these functions from the SST console locally, which remember is invoking functions on AWS’ infrastructure in a sandbox account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7bq9Un6UdgnMxlEq8Uw7Q.png" /></figure><p>This is a massive win from creating mocks and running sls commands in the terminal.</p><p>Another win is that we can interact with DynanoDB in the SST console locally as well. Since each developer has an AWS Sandbox account they configure the data in their tables however they please to ensure they are solving the dynamic needs of their user stories.</p><p>All of this also extends to RDS instances, s3 Buckets, GraphQL endpoints and Cognito Pools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShMbPB-E2dsl4LxPIyTMEg.png" /></figure><p><em>True IaC</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Susk61zRg9d19heiE8_Sag.png" /></figure><p>Now we have true Infrastructure as Code, when we declare app.stack we pass in the resource we have created and then SST will use the CDK to create the CloudFormation resources for us.</p><p>This is now easily reusable and deployable into another AWS account &amp; region if there is ever the business case for that.</p><p><strong>Benefits of a mono repo</strong></p><p><em>Changes in one place</em></p><p>When someone needs to work on one or more services, the changes will all come up in one pull request. Meaning that they get deployed at the same time and there are no more cases of downtime due forgetting to deploy the changes of another service in another repo.</p><p><em>Work Gets Deployed Faster</em></p><p>Borrowing from the points above our deployment frequency has increased due to us not waiting to sit with changes for too long on a branch. We are then forced to get changes up to production as quickly as possible so everyone has a working version of our codebase that is up-to-date.</p><p><em>Feature Flags</em></p><p>Due to putting work out into production quickly, some changes might not be necessary for all of our customers to start using. Hence we started leveraging feature flags to navigate a subset of traffic to specific set of customers.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o6ZtpxcHcYPbxkJuU%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdGY2bDZ5ZnhiYnM2dHhoanZkMTR3dGE2d3htbHprZ2p6aWdoanRtdyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3o6ZtpxcHcYPbxkJuU%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaHQweGtscnhncG56Y3hhdnYwcjFhdTkyODR0YWFmcG82OXo3MzFnYiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3o6ZtpxcHcYPbxkJuU%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/048aec72d71e34806b28ceca28727e3e/href">https://medium.com/media/048aec72d71e34806b28ceca28727e3e/href</a></iframe><p>I’d like to give a massive shoutout to <a href="https://www.linkedin.com/in/margaux-woellner/">Margaux</a>, <a href="https://www.linkedin.com/in/aiden-walton/">Aiden</a>, <a href="https://www.linkedin.com/in/tatenda-m-302644135/">Tatenda</a> and <a href="https://www.linkedin.com/in/liza-okennedy/">Liza</a> for putting together an awesome day for the community to share what they’ve being doing with regards to Serverless technologies.</p><p>Lastly, I’d also like to thank <a href="https://www.linkedin.com/in/peterakinlolu1/">Peter</a>, <a href="https://www.linkedin.com/in/brandon-williams-wma/">Brandon</a>, <a href="https://www.linkedin.com/in/peggy-mailula?miniProfileUrn=urn%3Ali%3Afs_miniProfile%3AACoAADZaz0YB3eDECGaBc5f4himdJRDXd51mN5c&amp;lipi=urn%3Ali%3Apage%3Acompanies_company_people_index%3B4e2a7e9b-bdc4-4b8d-b588-cf5bcddb3927">Peggy</a>, Joko and <a href="https://www.linkedin.com/in/nathanpen/">Nathan</a> for all the efforts in getting our migration over the line 🤩. None of this would’ve been possible without your industrious productivity!</p><p>This was little insight into what our migration from the Serverless Framework was like. Do you have a similar story of how you migrated a project to a particular framework? Lets connect in the comments because I’d love to hear your insights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bff84e550d81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A List of The Newsletters I’m Subscribed Too]]></title>
            <link>https://medium.com/@PrinceAshburton/a-list-of-the-newsletters-im-subscribed-too-fa045df7ae5d?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa045df7ae5d</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 21:59:03 GMT</pubDate>
            <atom:updated>2023-03-31T08:09:56.947Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYflWYQuAr0cFAYt6d6gRg.png" /></figure><p>Over the years I’ve collected a decent collection of links for Tech newsletters. The different publications cover: Modern Web Dev, Serverless technologies, React Native, JavaScript and databases.</p><p>A critical benefit that these publications provide is seamlessly connecting both the supply and demand factions of the job market. Forward thinking companies can put themselves in front of people that are able to invest in improving their ability to delivery of value for their teams.</p><p>The different publications below generally provide fresh insight into: new tooling, developer trends, different practices and fresh perspectives while keeping up with JavaScript’s break neck development speed.</p><p>Here are the different publications below:</p><p>⚠️<strong><em>⚠️LAST UPDATED:31 March 2023::10:09::SAST⚠️⚠️</em></strong></p><h4>Key 🗺️</h4><p>🪄 -Link</p><p>📀- Sample</p><h3>Bytes.DEV</h3><p>🪄- <a href="https://bytes.dev/">https://bytes.dev/</a></p><p>📀 — <a href="https://bytes.dev/archives">https://bytes.dev/archives</a></p><h3>Deno</h3><p>🪄- <a href="https://deno.news/">https://deno.news/</a></p><p>📀 — <a href="https://deno.news/archive/56-deno-v131-a-look-back-at-2022-and-more">https://deno.news/archive/56-deno-v131-a-look-back-at-2022-and-more</a></p><h3>JSK Daily</h3><p>🪄— <a href="https://us9.campaign-archive.com/?u=4ba84fe3f6d629e746e48e5b7&amp;id=9e189c5118">https://us9.campaign-archive.com/?u=4ba84fe3f6d629e746e48e5b7&amp;id=9e189c5118</a></p><h3>Node Weekly</h3><p>🪄 — <a href="https://nodeweekly.com/">https://nodeweekly.com/</a></p><p>📀- <a href="https://nodeweekly.com/issues/375">https://nodeweekly.com/issues/</a>479</p><h3>Webdesigner news</h3><p>📀- <a href="https://www.webdesignernews.com/">https://www.webdesignernews.com/</a></p><h3><strong><em>Status Code Weekly</em></strong></h3><p>🪄 — <a href="https://weekly.statuscode.com/">https://weekly.statuscode.com/</a></p><p>📀 — <a href="https://weekly.statuscode.com/issues/303">https://weekly.statuscode.com/issues/3</a>23</p><h3>Frontend Focus</h3><p>🪄 — <a href="https://frontendfoc.us/issues/477">https://frontendfoc.us</a></p><p>📀 — <a href="https://frontendfoc.us/issues/477">https://frontendfoc.us/issues/</a>586</p><h3>React Status</h3><p>🪄 -<a href="https://react.statuscode.com/">https://react.statuscode.com/</a></p><p>📀 — <a href="https://react.statuscode.com/issues/332">https://react.statuscode.com/issues/332</a></p><h3><strong>React Newsletter</strong></h3><p>🪄 — <a href="https://reactnewsletter.com/">https://reactnewsletter.com/</a></p><p>📀 — <a href="https://reactnewsletter.com/issues/360">https://reactnewsletter.com/issues/360</a></p><p><a href="https://reactnewsletter.com/">Join React Newsletter - Your weekly dose of React</a></p><h3>Serverless Status</h3><p>🪄 -<a href="https://serverless.email/">https://serverless.email/</a></p><p>📀 — <a href="https://serverless.email/issues/280">https://serverless.email/issues/280</a></p><p><a href="https://serverless.email/issues/187">Serverless Status Issue 187: February 12, 2021</a></p><h3>DB Weekly</h3><p>🪄 -<a href="https://dbweekly.com/">https://dbweekly.com/</a></p><p>📀 — <a href="https://dbweekly.com/issues/360">https://dbweekly.com/issues/360</a></p><p><a href="https://dbweekly.com/issues/341">DB Weekly Issue 341: February 12, 2021</a></p><h3>Hacker Newsletter</h3><p>🪄 -<a href="https://hackernewsletter.com/">https://hackernewsletter.com/</a></p><p>📀 — <a href="https://mailchi.mp/hackernewsletter/567">https://mailchi.mp/hackernewsletter/567</a></p><p><a href="https://mailchi.mp/hackernewsletter/541?e=4642bad9a3">Hacker Newsletter #541</a></p><h3>GraphQL Weekly</h3><p>🪄 -<a href="https://www.graphqlweekly.com/">https://www.graphqlweekly.com/</a></p><p>📀 — <a href="https://www.graphqlweekly.com/issues/308/#content">https://www.graphqlweekly.com/issues/308/#content</a></p><p>Are you subscribed to anything not on this list and you think is AMAZING? Please drop a link in the comments. 🗃️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa045df7ae5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Puppeteer]]></title>
            <link>https://itnext.io/serverless-puppeteer-271b68f5a409?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/271b68f5a409</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[puppeteer]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 18:42:54 GMT</pubDate>
            <atom:updated>2023-03-31T07:33:50.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OvthZRmOcvikcBaa--WXQ.png" /></figure><blockquote><strong>Note this blog post has been adapted from a Talk I did on the same topic at </strong><a href="https://nodejsone.com/speaker/amogelang-moloko-2/"><strong>NodeJSOne Africa23</strong></a></blockquote><p>This post aims to outline the various use cases an engineering team can use Serverless and Puppeteer in production. We will cover what the two technologies are, their use out in the wild and cover an example with code that you can run.</p><p>🔗 — <a href="https://github.com/AmoDinho/nodejs-africa23-talk">Github link</a> || <a href="https://www.youtube.com/watch?v=VuGLaQbEpcY">Link to Talk</a> || <a href="https://www.figma.com/proto/wfTuuiWP4TwRRsdcefLp4x/Lunar-Tour-App-v2?node-id=1567-3350&amp;scaling=contain&amp;page-id=1566%3A3346&amp;starting-point-node-id=1566%3A3347">Link to slides</a></p><h3>What is Serverless 🌬️?</h3><p><a href="http://Serverless Computing – Amazon Web Services  Amazon.com https://aws.amazon.com › serverless">Serverless</a> is a computing model whereby you, as the developer, do not have to provision servers for your backend services which could be APIs, Cron-Jobs, Database etc. Essentially all you’re doing is providing your code in whatever runtime you use and letting your cloud provider worry about scaling your infrastructure based on your traffic.</p><p>One of my personal favorite reasons for using Serverless is that you can take real advantage of on-demand computing. Meaning you only get charged for when your users use your APIs, which brings massive cost savings.</p><p>However, with the use of Serverless, teams need to be aware of the different mental models needed for concepts like Authentication, Queues, Databases and for the purpose of the post Headless Browsers [Puppeteer].</p><p>Serverless can be easily adopted with a tool that will generate cloudformation templates for your provider. I’m all in on <a href="https://aws.amazon.com/console/">AWS</a> and primarily use <a href="https://sst.dev/">SST</a> and the <a href="https://www.serverless.com/">Serverless Framework</a>. More on SST Later.</p><h3>What is Puppeteer 🧞‍♀️?</h3><p><a href="https://pptr.dev/">Puppeteer</a> is a Headless Browser made by the Chrome Dev team, which opens a world of possibilities like end-end testing of frontends and document generation. Not only that, but due to Puppeteer being an API for Chrome, it opens up avenues for you to use your own Web-App on the server if any use case like that was needed.</p><p>The alternatives to Puppeteer are <a href="https://www.selenium.dev/">Selenium</a> &amp; <a href="https://playwright.dev/">Playwright</a>.</p><h3>Use of Puppeteer in the wild 👨‍🏭</h3><p><strong>Uber</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dfJcMg7Ytfa5RXLRAET-CA.png" /><figcaption>Uber Eats generated Invoice</figcaption></figure><p>Here we have an example of Uber Eats sending me an invoice via email with a PDF after my meal had been delivered.</p><p>This is extremely dynamic because an event must have been fired off in their services that has my card info, address data and info about my order. This would be a great use of <a href="https://aws.amazon.com/eventbridge/">EventBridge</a> if I had to replicate this myself.</p><p>With the use of Puppeteer you could easily have a Lambda that is attached to a <a href="https://aws.amazon.com/sqs/">SQS</a> queue or EventBridge that generates this in the browser and stores the PDF in <a href="https://aws.amazon.com/s3/">s3</a>.</p><p><a href="https://www.tripplo.co/"><strong>Tripplo</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhmMnVOOb8YCHq2ScgJJ0Q.png" /><figcaption>Tripplo Generated PDF Load Confirmation</figcaption></figure><p>At Tripplo where I work, we use Puppeteer to generate load confirmations for Transporters and Cargo Owners. A load conf is a contract that lists all the details that are needed to be meet for the transporter to carry the cargo for the Cargo Owner.</p><p>In our case, once a transporter has indicated that they would like to move a load, we fire off a payload to SQS and a <a href="https://aws.amazon.com/lambda/">Lambda</a> function generates the PDF with all the data about the load and dumps it into s3 and saves the link in <a href="https://aws.amazon.com/dynamodb/">DynamoDB</a>.</p><h3>Demo Time</h3><p>In 2020, I released a course called <a href="https://fsgql.com/">Fullstack Serverless GraphQL</a>. It enabled people to book vacations to the moon. In this demo, I took the payload for the listings and created an API that allows you to create invoices for your trips.</p><p>On the backend, I’m using SST which uses the <a href="https://aws.amazon.com/cdk/">AWS CDK</a> to create a Lambda and s3 Bucket. The main value proposition of SST is that it allows you to create a full one-one clone of all your AWS services locally so that you fully simulate your AWS Cloud environment.</p><h4>Here is a full run down of the tech stack:</h4><p>💻 <strong><em>Frontend</em></strong></p><ul><li><a href="https://tailwindcss.com/">TailwindCSS</a></li><li><a href="http://nextjs.org/">NextJS</a></li><li><a href="https://ant.design/">Ant Design</a></li><li><a href="https://www.apollographql.com/docs/react/">Apollo Client</a></li></ul><p>🗄 <strong><em>Backend</em></strong></p><ul><li><a href="http://www.typescriptlang.org/">TypeScript</a></li><li>SST</li><li>Puppeteer</li><li>AWS s3</li><li>AWS Lambda</li></ul><p>In our case, we have a Mutation that accepts info about the trip:</p><pre>input CustomerInput {<br>  name:String!<br>  guide:String!<br>  price:String!<br>  tripName:String!<br>}<br>type Mutation {<br>    generateInvoice(input:CustomerInput!):String!<br>}</pre><p>Then the mutation invokes a function called GenerateBuffer that returns a base64 file to store in an s3Bucket and return the object URL:</p><pre>const generateInvoice = async (<br>  parent: undefined,<br>  { input }: { input: ICustomer }<br>): Promise&lt;String | null&gt; =&gt; {<br>  const buffer = await GenerateBuffer(InvoiceDataTemplate(input));<br>  const buf = Buffer.from(buffer, &#39;base64&#39;);<br>  const params = {<br>    Bucket: process.env.InvoiceBucketResource,<br>    Key: `${input.name}-invoice`,<br>    ACL: `public-read`,<br>    Body: buf,<br>    ContentType: &#39;png&#39;,<br>  };<br><br> <br>  const result = await putS3Object(params);<br><br>  if (result === &#39;Successfull uploaded&#39;) {<br>    return `https://${process.env.InvoiceBucketResource}.s3.${process.env.AWS_REGION}.amazonaws.com/${params.Key}`;<br>  }<br>};</pre><p>This function below, invokes launches an instance of Puppeteer. once the instance is created, we can pump it with HTML. By utilising page.screenshot() you can take a screenshot of the screen of whatever is in your headless browser:</p><pre>const puppeteer = chromium.puppeteer;<br>const browser = await puppeteer.launch({<br>      args: chromium.args,<br>      executablePath: await chromium.executablePath,<br>    });<br><br>const page = await browser.newPage();<br>             await page.setContent(content);<br><br>const buffer = await page.screenshot({ path: &#39;default_image.png&#39; });</pre><p>To generate the HTML we can write a function that returns HTML and accepts the dynamic props that will be recieved from whatever event the Lambda function is attached to:</p><pre>export const InvoiceDataTemplate = (customerInfo: ICustomer) =&gt; `<br>&lt;html&gt;<br>${head}<br>&lt;body&gt;<br>&lt;div class=&quot;bg-gray-50 min-h-screen flex-col overflow-hidden py-6 sm:py-12&quot;&gt;<br>  &lt;div class=&quot;p-10 flex justify-between&quot;&gt;<br>    &lt;h1 class=&quot;text-4xl font-bold text-grey-dark&quot;&gt;My Invoices&lt;/h1&gt;<br>    &lt;h1 class=&quot;text-smal font-bold text-grey-dark&quot;&gt;21 February 2430&lt;/h1&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;p-5&quot;&gt;<br>    &lt;hr class=&quot;border-red&quot; /&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;flex flex-row gap-5 p-10&quot;&gt;<br>    &lt;span class=&quot;flex flex-col&quot;&gt;<br>      &lt;h2 class=&quot;text-xl underline&quot;&gt;Item&lt;/h2&gt;<br>      &lt;p&gt;${customerInfo.tripName}&lt;/p&gt;<br>    &lt;/span&gt;<br>    &lt;span class=&quot;flex flex-col&quot;&gt;<br>      &lt;h2 class=&quot;text-xl underline&quot;&gt;Price&lt;/h2&gt;<br>      &lt;p&gt;${customerInfo.price}&lt;/p&gt;<br>    &lt;/span&gt;<br>    &lt;span class=&quot;flex flex-col&quot;&gt;<br>      &lt;h2 class=&quot;text-xl underline&quot;&gt;Your Guide&lt;/h2&gt;<br>      &lt;p&gt;${customerInfo.guide}&lt;/p&gt;<br>    &lt;/span&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;mt-16 flex p-4&quot;&gt;<br>    &lt;h2 class=&quot;text-2xl&quot;&gt;Total:&lt;/h2&gt;<br>    &lt;p class=&quot;ml-3 text-2xl italic&quot;&gt;${customerInfo.price}&lt;/p&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;mt-16 flex p-4&quot;&gt;<br>    &lt;h2 class=&quot;text-2xl&quot;&gt;Account holder:&lt;/h2&gt;<br>    &lt;p class=&quot;ml-3 text-2xl italic&quot;&gt;${customerInfo.name}&lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>`;</pre><p>As you can see, I’m using <a href="https://tailwindcss.com/">TailwindCSS</a> and using basic HTML to render data from the mutation. This truly makes your team empowered to provide your users excellent UX for the document related features.</p><p>As you can see there is nothing special happening here code wise but now where it gets tricky is that you need to configure a <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html">Lambda layer</a> and note some modules as external:</p><pre>export default function ExampleStack({ stack }: StackContext) {<br>  // Create the GraphQL API<br>  const InvoiceBucket = new Bucket(stack, &#39;invoice-bucket&#39;, {<br>    region: &#39;us-east-1&#39;,<br>  });<br>  const layerArn: string = `arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:31`;<br><br>  const layerConfig: AddLayerVersionPermissionCommandInput = {<br>    Action: &#39;lambda:AddLayerVersion&#39;,<br>    LayerName: layerArn,<br>  };<br><br>  const layer = new AddLayerVersionPermissionCommand(layerConfig);<br><br>  const api = new GraphQLApi(stack, &#39;ApolloApi&#39;, {<br>    server: &#39;packages/functions/src/lambda.handler&#39;,<br>    defaults: {<br>      function: {<br>        timeout: 20,<br>        environment: {<br>          AWS_ACCOUNT_NUMBER: process.env.AWS_ACCOUNT_NUMBER,<br>          SECRET_ACCESS_KEY: process.env.SECRET_ACCESS_KEY,<br>          ACCESS_KEY: process.env.ACCESS_KEY,<br>          InvoiceBucketResource: InvoiceBucket.bucketName,<br>        },<br>        permissions: [InvoiceBucket.bucketName],<br>        bundle: {<br>          // format: &#39;esm&#39;,<br>          externalModules: [&#39;@sparticuz/chrome-aws-lambda&#39;, &#39;mitt&#39;],<br>        },<br>        layers: [layer],<br>      },<br>    },<br>  });<br><br>  // Show the API endpoint in output<br>  stack.addOutputs({<br>    ApiEndpoint: api.url,<br>  });<br>}</pre><p>We’ve reached the end of this concept on using Puppeteer with AWS Lambda. Remember you can access all the talk’s supporting content free below. I would love hear if you’ve done similar or are planning to. 🦄🪙</p><p>🔗 — <a href="https://github.com/AmoDinho/nodejs-africa23-talk">Github link</a> || Link to Talk || <a href="https://www.figma.com/proto/wfTuuiWP4TwRRsdcefLp4x/Lunar-Tour-App-v2?node-id=1567-3350&amp;scaling=contain&amp;page-id=1566%3A3346&amp;starting-point-node-id=1566%3A3347">Link to slides</a></p><h4>Credits 💰</h4><p><a href="https://linkedin.com/in/peterakinlolu1">Peter Akinlolu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=271b68f5a409" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/serverless-puppeteer-271b68f5a409">Serverless Puppeteer</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An overview of React State Management Techniques in 2021 ⚜️]]></title>
            <link>https://itnext.io/an-overview-of-react-state-management-techniques-in-2021-%EF%B8%8F-1590242b1cbc?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/1590242b1cbc</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Mon, 07 Jun 2021 07:04:41 GMT</pubDate>
            <atom:updated>2021-06-07T07:04:41.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXaDiA1rWp6bhJcwyea3Zw.png" /></figure><p>When you get the chance to build large frontends, the need arises for a global store of state in your app. This could be to store data about the user that is logged in, maintain metadata for specific parts of your UI or data from a service. The question that comes about is how can you actually implement this?</p><p>This post aims to cover only three of them, <a href="https://www.apollographql.com/docs/react/local-state/local-state-management/">Apollo’s Local Cache</a>, <a href="https://recoiljs.org/">Recoil</a> and <a href="https://redux.js.org/">Redux</a>. I will cover all three tools in the following manner: Overview, Code Walk through, Thoughts.</p><p>Each will be given a rating to measure if I would add it to my frontend stack if I was building out a largish Frontend Web app in React.</p><p>All these experiments were generated from the<a href="https://github.com/AmoDinho/react-bleeding-edge-kit"> React Bleeding Edge kit</a>, which is a batteries included toolkit with <a href="https://www.apollographql.com/docs/react/">Apollo Client</a>, <a href="https://tailwindcss.com/">TailwindCSS</a> and <a href="https://reach.tech/router">Reach Router</a> tossed on top of <a href="https://github.com/facebookincubator/create-react-app">Create React App (CRA)</a> for elite level productivity.</p><h3><strong>Apollo Local Cache</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2yW5y8NNWrMsMhJhaQ4yQ.png" /></figure><p><a href="https://github.com/Fullstack-Serverless-GraphQL/lunar-tour-react">Link to repo</a> || <a href="http://lunar-tour-react.netlify.app/">Link to Demo</a></p><p><strong>Overview </strong>📡</p><p>If you use Apollo Client in React or <a href="http://Vue Apolloapollo.vuejs.org">Vue</a>, you can use it’s Local Cache for State management. The bonus is that you get to use GraphQL for querying and mutating your data. In the walkthrough below I used Apollo 2 which required the use of local resolvers, however, bear in mind that they are deprecated.</p><p>You’re probably wondering why this clown of an author is taking you through something that will be deprecated?🤡 Well the short of it is that I don’t fancy Apollo’s Thesis of State Management, but more of my biases for later 🥲. However, be sure to checkout <a href="https://github.com/apollographql/ac3-state-management-examples">Apollo 3’s latest implementation</a> and you can also view a <a href="https://github.com/LauraBeatris/apollo-cache-management-talks">talk by Laura Beatris</a> on it too🍦.</p><p><strong>Code walkthrough </strong>🖥️</p><p>To set up Apollo’s cache in a React app, in the index.jsfile, all you’ve got to do first is initialize the state that you want to keep a record of:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4503781298c5c5028e60313c573bc370/href">https://medium.com/media/4503781298c5c5028e60313c573bc370/href</a></iframe><p>The global state gets stored in the app’s cache with use of the cache.writeDatafunction. It is utterly imperative that you add the __typenamefield so that Apollo knows which part of the object you will be querying and mutating. If I need to store more data on additional state objects, I would need to create them and specify that __typename field for each field, which is already a massive drawback.</p><p>Next up I had to create a local Resolvers file, with a mutation like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35c79ef5cfddcf16140e87ae891b3807/href">https://medium.com/media/35c79ef5cfddcf16140e87ae891b3807/href</a></iframe><p>I’m reading the cache for the most up to date version of the form data. If the queryResultis not undefined from it, I can proceed with creating a new formData object by reading the arguments from the mutation and writing it to the cache.</p><p>In order to read the data from the cache we first need to write a query to do so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a54d2025c6a9c73dceab85a0fd84834d/href">https://medium.com/media/a54d2025c6a9c73dceab85a0fd84834d/href</a></iframe><p>This schema document is basically querying the formDataobject on the client for the email,customer and date. You will need to use this again in other components through out the app.</p><p>Next we need to create a Mutation that will allow us to update the formData:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0024a50fd4f765685c425937b67f6ed1/href">https://medium.com/media/0024a50fd4f765685c425937b67f6ed1/href</a></iframe><p>This accepts an email,date and CustomerInput. Lets look at it in action where we have a form that allows someone to add an array of customers as objects:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43075fc1a018edf94beeca7f7604769b/href">https://medium.com/media/43075fc1a018edf94beeca7f7604769b/href</a></iframe><p>This component allows us to add multiple customers to an array, in order to store the data to the local state, we first run the query to get the customers,email and date, while we run the mutation to update the customers that will be coming along for the trip. This way when we take the user to the next component we have the most update version of the store.</p><p><strong>Thoughts </strong>🤔</p><p>Local resolvers aside, the whole setup is unpredictable and adding GraphQL’s schema validation would not work out so great when you could end up storing an object with over 15 fields in your local state. Apollo 3 aims to fix that, however the implementation does not seem straight forward, given if you have a big app you’re going to need to keep your State Management logic in different files so that it is modular. So as a GraphQL groupie it breaks my heart to say that I do not see the value in using it.</p><blockquote><strong>Rating:</strong> ⭐</blockquote><h3><strong>Recoil</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07NvRWWMCIp-ianmevKS0Q.png" /></figure><p><a href="https://github.com/AmoDinho/recoil-state-management-demo">Link to repo</a> || <a href="https://recoil-state-man-demo.netlify.app/">Link to Demo</a></p><p><strong>Overview </strong>📡</p><p><a href="https://recoiljs.org/">Recoil</a> was released around mid 2020 with the goal of alleviating some of the problems associated with using React’s built in state management tools (at least from my point of view 🦧).</p><p>Its core concepts are around Atoms which form pieces of state and selectors which allow you to mutate state. Selectors make use of nested functions in objects which allow you to be able to read the state into components using hooks as well as mutate the state. It aims to make the process of state management simple and less boilerplate like.</p><p><strong>Code walkthrough </strong>🖥️</p><p>This demo is extremely <a href="https://www.formula1.com/">Formula One (F1)</a> themed. I even used the public F1 API for us to go over some asynchronous calls. I have a file called atoms.js that has all the state I’m trying to track:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89d1c8006492bc18569b0a9f2dc6e892/href">https://medium.com/media/89d1c8006492bc18569b0a9f2dc6e892/href</a></iframe><p>The way you need to initialize state is pretty straightforward in the form of objects with keys that are very important to take note of because this is how you will reference this state in different parts of your app. Also there is a default key which is used to add the default state by also specifying its type (object,string,array etc). In my case I’m tracking the driverState which is an array, the circuitState which is also an array of circuits and the singleDriverState in an object to store all the info about a driver.</p><p>I felt that it was a quick win to just display all the drivers on the index page while reading it from the state:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/184d2954f2f956cfd8df89781e07ee28/href">https://medium.com/media/184d2954f2f956cfd8df89781e07ee28/href</a></iframe><p>With the useRecoilValue() hook, you can easily reference the state you’ve initialized as atoms by passing it into the hook as a parameter, like I’ve done with the driverState .</p><p>Next up we have an asynchronous example that is a common requirement across many apps. So imagine you’d like to get a user’s bank transactions for the month and allow different parts of the app access to it. You can use the selectorFamily() util in your selectors like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fca1e781c76472f63e450e4e37eed46/href">https://medium.com/media/7fca1e781c76472f63e450e4e37eed46/href</a></iframe><p>In my case I wanted to get information about a Driver, but to do that I need their name. The key property is making this selector aware that we are dealing with the driver atom. While the get() key allows us to actually call an asynchronous function to get the details about a driver. The set key is a function that now allows us to store the data about the driver into the driver atom.</p><p><strong>Thoughts </strong>🤔</p><p>Overall, Recoil is nice and nimble. Certainly a modern React library that is hooks based with a nice clean API and documentation that made it pretty straight forward to implement. The only reason why it can’t get the five is because I had to over heat my brain to thoroughly think carefully about the selectors. 🎭</p><blockquote><strong>Rating</strong>: ⭐⭐⭐⭐</blockquote><h3><strong>Redux</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*nlWbo_rZ9b47C_SRhO4uYg.png" /></figure><p><a href="https://github.com/AmoDinho/redux-toolkit-state-management-demo">Link to repo</a> || <a href="https://redux-toolkit-state-management-demo.netlify.app/">Link to Demo</a></p><p><strong>Overview</strong></p><p>Last but not least we have the darling of the react community, <a href="https://redux.js.org/">Redux</a>! Initially set out to prevent issues of prop-drilling. Redux works on a flux pattern whereby you setup an initial state that is linked to a set of actions which help the application reduce its state. There are different approaches to writing out Redux apps that can be <em>boilerplatish</em>, fortunately I discovered the <a href="https://redux-toolkit.js.org/">Redux Toolkit</a> after mastering how to use Redux with files and functions in a module fashion.</p><p><strong>Code walkthrough</strong></p><p>I usually structure my Redux apps like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*zcIU9AUMlnDyV3A0P-Qgqw.png" /></figure><p>Quite bloated and you need to make changes in a couple of files before seeing any results. This is counterproductive and an unnecessary <a href="https://www.gamebyte.com/wp-content/uploads/2021/01/cyberpunk-apology-meme.jpg">brain dance</a>.</p><p>Fortunately, enough there is something called the Redux Toolkit which sort of adopts the same architectural principles that Recoil does. You simply need to make a slice, which could be referred to as a piece of state. In this case I made a layout slice to be able to change the page header of each route:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f906d1b296435db363300d9c57fb668f/href">https://medium.com/media/f906d1b296435db363300d9c57fb668f/href</a></iframe><p>layout is the the name of the state I’m using to track the pageHeader string. It is given a default value of <strong><em>Page. </em></strong>I have a reducer called setPageHeader to set the value of the pageHeader , more detail on how to export the reducers into their files just now.</p><p>Now for the reducers! In a file called layoutReducer :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5befb3fc0b37d3d80c9fda120d7862bd/href">https://medium.com/media/5befb3fc0b37d3d80c9fda120d7862bd/href</a></iframe><p>I’ve simply exported a function called setNewTitle that assigns the payload back to the pageHeader in the global state.</p><p>We can now consume the state in the global App component with a useSelector hook:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e77f2c051a8cc698fb9e0cb0633b0495/href">https://medium.com/media/e77f2c051a8cc698fb9e0cb0633b0495/href</a></iframe><p>One way to change the pageHeader Title is to use the useEffect hook :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb3d2a120bd5b8033b3408310311d73c/href">https://medium.com/media/cb3d2a120bd5b8033b3408310311d73c/href</a></iframe><p>With the use of a useDispatch hook we are able to use the setPageHeader action we exported in the dispatch function. This is much neater than having to create mapDispatchToProps and mapStateToProps functions.</p><p>Similarly enough I initialized an array of mountains in the state and was able to dispatch them like this via a form in the app:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16e794e17f29a5845c18a9fbb693f046/href">https://medium.com/media/16e794e17f29a5845c18a9fbb693f046/href</a></iframe><p>With a reducer that looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52af45bf59585dbe2c6efa3e7d968c98/href">https://medium.com/media/52af45bf59585dbe2c6efa3e7d968c98/href</a></iframe><p><strong>Thoughts </strong>🤔</p><p>Compared to how I used to write Redux before knowing of the Redux Toolkit, this is great and clean. It can be easily abstracted nicely as an application grows.</p><blockquote><strong>Rating: </strong>⭐⭐⭐⭐</blockquote><p>Overall I’m a big fan of knowing how to architect a frontend correctly because if the state management is setup poorly it can be a pain. Recoil and the Redux Toolkit will definitely enable one to make sure the state management layer is crisp and modular.</p><p>As a recap, here are links to the various Repos 🔌:</p><p><strong>Apollo</strong></p><p><a href="https://github.com/Fullstack-Serverless-GraphQL/lunar-tour-react">Link to repo</a> || <a href="https://lunar-tour-react.netlify.app/">Link to Demo</a></p><p><strong>Recoil</strong></p><p><a href="https://github.com/AmoDinho/recoil-state-management-demo">Link to repo</a> || <a href="https://recoil-state-man-demo.netlify.app/">Link to Demo</a></p><p><strong>Redux</strong></p><p>RTK : <a href="https://github.com/AmoDinho/redux-toolkit-state-management-demo">Link to repo</a> || <a href="https://redux-toolkit-state-management-demo.netlify.app/">Link to Demo</a></p><p>Plain Redux: <a href="https://github.com/AmoDinho/redux-state-management-demo">Link to repo</a></p><p><strong>Credits </strong>🦠</p><p><a href="https://github.com/apollographql/ac3-state-management-examples">Apollo’s State Management Examples</a></p><p><em>Thanks to </em><a href="https://za.linkedin.com/in/benjanecke"><em>Ben Janecke</em></a><em> for reading a draft of this. </em>🧙‍♂️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1590242b1cbc" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/an-overview-of-react-state-management-techniques-in-2021-%EF%B8%8F-1590242b1cbc">An overview of React State Management Techniques in 2021 ⚜️🌐</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build An App That Books Vacations To The Moon with GraphQL, Lambda, DynamoDB, Serverless Framework…]]></title>
            <link>https://itnext.io/build-an-app-that-books-vacations-to-the-moon-with-graphql-lambda-dynamodb-serverless-framework-569b26b6e85?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/569b26b6e85</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Thu, 24 Dec 2020 09:38:31 GMT</pubDate>
            <atom:updated>2020-12-25T16:45:00.564Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foKh0s3SNfWYfSW-Wcwypw.png" /></figure><h3>Build An App That Books Vacations To The Moon with GraphQL, Lambda, DynamoDB, Serverless Framework, Vue, React and TailwindCSS 🌝</h3><blockquote>Head on over to the course docs 👉 <a href="https://fsgql.com/">HERE</a></blockquote><p>If you are ready to improve your frontend and backend <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript">JavaScript</a>, learn about <a href="https://graphql.org/">GraphQL</a> and <a href="https://martinfowler.com/articles/serverless.html">Serverless</a>, then this is the <a href="https://fsgql.com/">resource for you</a>! In this course you will learn how to make a bleeding edge fullstack application with the following toys:</p><ul><li><a href="https://aws.amazon.com/lambda/?c=ser&amp;sec=srv">AWS Lambda</a></li><li><a href="https://aws.amazon.com/dynamodb/?c=ser&amp;sec=srv">AWS DynamoDB</a></li><li>GraphQL ( <a href="https://www.apollographql.com/docs/apollo-server/">Apollo Serve</a>r, <a href="https://www.apollographql.com/docs/react/">Client</a>, <a href="https://www.notion.so/Links-b512a3954ee24765a24ffd2fe17eaf6c#a60a67d807a047caae789682fb9fea26">Vue Apollo</a>)</li><li><a href="http://vuejs.org/">VueJS</a></li><li><a href="https://reactjs.org/">ReactJS</a></li><li><a href="https://tailwindcss.com/">TailwindCSS</a></li><li><a href="https://www.serverless.com/">Serverless Framework</a></li><li><a href="https://ant.design/">Ant Design</a></li></ul><p>When I started my first job I really struggled to setup an app with this stack. I had to piece different tutorials together and it was a nightmare. Eventually I setup a boilerplate project to scaffold a Serverless GraphQL API in JavaScript and TypeScript. While there are lots of examples of how to use GraphQL on the frontend there were few resources on how to develop and deploy a fullstack project. So I also needed a bleeding edge app on hand for me to refer to from time. So this guide is meant to be your resource to achieve it. It is quite opinionated , so if it does not fit in with your stack you can look at different parts of the project and take what you need.</p><p>The beauty of this course is that you can choose your own adventure on the frontend between Vue and React. On the Vue side we explore how to scaffold a project using <a href="https://cli.vuejs.org/">Vue CLI</a> and manage state in a parent component across its children. While if you choose to do the frontend part of the course in React, you will learn how to use Apollo’s Local Cache as a replacement for <a href="https://redux.js.org/">Redux</a>.</p><p>Tailwind CSS is creeping into everyone’s workflow to manage their CSS, while I believe you can use it in conjunction with <a href="https://styled-components.com/">Styled Components</a> in your React app, it introduces different benefits for styling your app. These benefits are:</p><ul><li>Giving you complete ability to build custom styles without overriding existing styles.</li><li>Easier to build responsive UI.</li><li>Easier to adopt and implement your design system into code.</li></ul><p>This project was hugely inspired by the folks over at <a href="https://anoma.ly/">Anomaly Innovations</a> who created the <a href="https://serverless-stack.com/">Serverless Stack</a> which is a course that teaches you to ship Serverless APIs with REST.</p><p>The wait to get your hands on how to build a fullstack serverless GraphQL app is over! <a href="https://fsgql.com/">Get it for Free!</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F4GIcsQJorDZOU%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F4GIcsQJorDZOU%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F4GIcsQJorDZOU%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/40fdb4e24d5f4991fe9dfc0c38b9dfb5/href">https://medium.com/media/40fdb4e24d5f4991fe9dfc0c38b9dfb5/href</a></iframe><p>Here are the links to the various repos and demo apps 🎮:</p><ul><li><a href="https://lunar-tour-vue.netlify.app/">Vue Frontend</a> || <a href="https://github.com/Fullstack-Serverless-GraphQL/lunar-tour-frontend">Deployed App</a></li><li><a href="https://github.com/Fullstack-Serverless-GraphQL/lunar-tour-react">React Frontend</a> || <a href="https://lunar-tour-react.netlify.app/">Deployed App</a></li><li><a href="https://github.com/Fullstack-Serverless-GraphQL/lunar-tour-api">Serverless API</a></li><li><a href="https://github.com/Fullstack-Serverless-GraphQL/fullstack-serverless-graphql-docs">Course Repo</a> || <a href="https://fsgql.com/">Course Docs</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1m-LHz13XQRpes84klPNrw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=569b26b6e85" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/build-an-app-that-books-vacations-to-the-moon-with-graphql-lambda-dynamodb-serverless-framework-569b26b6e85">Build An App That Books Vacations To The Moon with GraphQL, Lambda, DynamoDB, Serverless Framework…</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lets take Prisma 2 for a test drive on AWS Lambda with GraphQL ️]]></title>
            <link>https://itnext.io/lets-take-prisma-2-for-a-test-drive-on-aws-lambda-with-graphql-%EF%B8%8F-f4be711e93cc?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4be711e93cc</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Fri, 01 May 2020 17:24:53 GMT</pubDate>
            <atom:updated>2020-05-01T19:09:38.487Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kuh7wGixOnBkP04LmfN4PQ.png" /></figure><p><a href="https://www.prisma.io/">Prisma</a> is an open source database toolkit for <a href="https://nodejs.org/">Node</a>. It is meant to replace <a href="https://blog.bitsrc.io/what-is-an-orm-and-why-you-should-use-it-b2b6f75f5e2a">ORMs</a> like <a href="https://typeorm.io/">TypeORM</a>, <a href="https://knexjs.org/">Knex.js</a> and others. Prisma is also an alternative to writing raw <a href="https://www.w3schools.com/sql/">SQL</a> in your backend API. Initially it was touted around with <a href="http://graphql.org/">GraphQL</a>, however, you can use it with <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST</a> too. Prisma makes it easier for you to work with your database by creating queries that match the models of your database.</p><blockquote>Note Prisma only supports<a href="https://www.mysql.com/"> MySQL</a>, <a href="https://www.postgresql.org/">PostgreSQL</a> and <a href="https://www.sqlite.org/">SQLite</a> at the moment.</blockquote><p>I’ve used Prisma 1 before on a <a href="https://github.com/AmoDinho/formulaone-graphql">project</a> and had an awful time getting it deployed. This time out the gate there is clear documentation for how to get it deployed. So I will spend the rest of this post going over what I experienced while giving Prisma 2 a test drive on <a href="https://aws.amazon.com/lambda/">AWS Lambda</a>.</p><p>A repo is available on <a href="https://github.com/AmoDinho/prisma2-f1-demo">GitHub</a> with the final code that is used throughout this post and IMO it is pretty decent for you to get up and running and building something important.</p><p>Throughout this post I’m assuming you have used <a href="https://www.serverless.com/framework/docs/providers/aws/guide/credentials/">AWS</a> and the <a href="https://www.serverless.com/framework/docs/providers/aws/guide/installation/">Serverless Framework</a> before. 🤰 If not the <a href="https://serverless-stack.com/">Serverless Stack</a> tutorial is a great free resource! 🌠</p><h3>How do go about setting everything up?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl16WKGFMNJttoUE2pH%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ff1-formula1-silverstone-britishgp-l16WKGFMNJttoUE2pH&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl16WKGFMNJttoUE2pH%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/abee7309079c3d8bead3869ba949a0b3/href">https://medium.com/media/abee7309079c3d8bead3869ba949a0b3/href</a></iframe><p><a href="https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-cli/installation">Prisma CLI</a> will be what you use to to set up your Prisma project and tell it what database you are using.</p><p>While the Prisma Client is what will look into your database and make all the queries for you. In this particular case I am using GraphQL, Prisma generally advocates for a <a href="https://www.prisma.io/blog/the-problems-of-schema-first-graphql-development-x1mn4cb0tyl3">Code-first approach</a> when making your GraphQL schema. Which will require you to use their <a href="https://nexus.js.org/">Nexus library</a>. In this particular project I’m going for a <a href="https://www.apollographql.com/docs/graphql-tools/generate-schema/">SDL first</a> approach. 🤠</p><p>So I first scaffolded a <a href="https://serverless.com/">Serverless</a> project with the <a href="https://github.com/pimp-my-book/serverless-graphql-nodejs-starter">Serverless GraphQL Node Starter</a>. Then I made a database in MySQL locally on my machine with the following schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52YQFCnY4MiMJs4SvVhExg.png" /></figure><p>I used <a href="https://dev.mysql.com/downloads/workbench/">MySQL workbench</a> to create the tables.</p><p>Next, I installed the Prisma CLI and got the project initialised. Once that was done, I then added my local database URL to the schema.prismafile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UKD5b6bMS3NHiqa7hkhSOQ.png" /></figure><p>After this we need to introspect the database so Prisma can generate models for us, with the following command:</p><pre>$ prisma introspect</pre><p>Which will then create a data model for you, like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mg5v4XWkxHA2MozoasYPBw.png" /></figure><p>Now remember we need to use <a href="https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/api">@prisma/client</a>to allow us to connect to the data model to be able to run queries against our database. If you run <strong><em>yarn prisma generate</em></strong>in your terminal you should get the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*Lis6L4F9inHqU0-hUYGg7Q.png" /></figure><p>With everything setup you should be able to write queries against your database. Since I am using GraphQL, I setup a simple schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*dL-W7dQ2Mhuoe7RqLNGsYQ.png" /></figure><p>So In my case I just wrote a mutation to create a F1 Team:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S2NCAUC6gY5ndit7hJ339Q.png" /></figure><p>Simple right? If I execute this in Playgroud, after running sls offlineit returns the data from the newly created mutation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIILKGIyicoNpWQUCN6oqA.png" /></figure><p>So now everything is working locally, but If you’ve made apps in the cloud long enough you would know that it does not work till it works on the cloud.</p><p>The key is to make sure you have the necessary Prisma commands in your package.jsonand have your <a href="https://webpack.js.org/">Webpack</a> configured correctly. Lots of credit needs to go to <a href="https://dested.com/">Salvatore</a> (check out his <a href="https://github.com/dested/OrbitalGa.me">fullstack project</a> with a similar stack) who ran into a similar issue when deploying to AWS. CloudWatch gives the following error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TS0Y9US0rxdAwq8T0aUlvQ.png" /></figure><p>To avoid this error make sure these commands are in your <strong><em>package.json:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JyKD9tPqsoe5grctN26LwA.png" /></figure><p>Now you need to add the <a href="https://webpack.js.org/plugins/copy-webpack-plugin/">copy-webpack-plugin</a> that will give Webpack access to the binary file that is needed once our code is bundled.</p><p>Next up make sure you are referencing the prisma generate command in the custom part of your <strong><em>serverless.yml</em></strong>under the Webpack section. This is done to make sure your Prisma Client Library is created in <strong><em>node_modules:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*BHwKZwpGMF42xc555yKpZw.png" /></figure><p>Lastly, we just need to update our Webpack config accordingly to tell the plugin where to find the binary file (<strong><em>schema.prisma</em></strong>) to copy it into our build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IYlsMU0HrAOoWsQPUJIjvw.png" /></figure><p>Everything should be done on the code side of things 🚀.</p><p>Now we need infrastructure for a <a href="https://aws.amazon.com/rds/aurora/serverless/">Serverless RDS Aurora cluster</a>. Make sure you have an AWS account and configured a <a href="https://aws.amazon.com/vpc/">VPC</a> for your Lambda. You can follow the first part of this <a href="https://hackernoon.com/a-crash-course-on-serverless-with-aws-building-apis-with-lambda-and-aurora-serverless-49885c46e37a">post</a> to configure Aurora Serverless on RDS. If you have time you can try and configure it as <a href="https://en.wikipedia.org/wiki/Infrastructure_as_code">IaaS</a> by looking at this <a href="https://github.com/serverless/examples/tree/master/aws-node-graphql-and-rds">example repo</a> from the Serverless framework team.</p><p>Once all that is done make sure you have your VPC referenced in serverless.yml.Then also insure you have added the connection URL to your<em> </em><strong>.env</strong>file for Prisma to be able to connect to the database in the cloud.</p><p>Here is an example .envfile (courtesy of Prisma):</p><pre>DATABASE_URL=&quot;mysql://johndoe:randompassword@localhost:3306/mydb&quot;</pre><p>And here is what the <strong><em>serverless.yml</em></strong>with the VPC endpoints looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XoCBan9YyoHA9KXAXZVXAQ.png" /></figure><p>Now we can deploy this function:</p><pre>$ sls deploy</pre><p>If everything went well your console output should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L1jXLR8ceohFy8r4YWwHcQ.png" /></figure><p>We should be able create a mutation after clicking on the provided endpoints:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9HwILsBaDYBi6msGbwHmZQ.png" /><figcaption>make sure ‘/dev/’ is inbetween the Lambda endpoint and ‘graphql’</figcaption></figure><p>This example does not account for a change in NODE_ENVstages, where you would have different database URLs based on your environments (dev,staging etc). To achieve that I would try the following:</p><pre> process.env.database_url = process.env.NODE_ENV = DEVELOPEMENT ? ‘dev_url’ : ‘prod_url’</pre><h3>Cool so why would we want to use this over what is out in the wild currently 🤷‍♂️?</h3><h4>Raw SQL</h4><p>Personally I do not want to be writing raw SQL again, This what I wrote in a <a href="https://github.com/pimp-my-book/pmb-plus-backend">previous project</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AFETMM3snEA7tmeVLwhxeg.png" /></figure><p>This is because Knex and <a href="https://sequelize.org/">Sequelize</a> did not work on Lambda, which ultimately left me with no choice but to write raw SQL.</p><p>The developer experience using Prisma was seamless! After an hour I had something up and running locally, which would make it a strong case when advocating it to your CTO/tech lead.</p><h4>Prisma Studio</h4><p>If you run the following in your terminal:</p><pre>$ prisma studio --experimental</pre><p>It opens a new window in your browser with this 😯:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Xv4s4o_081d_Q9QZzQDcg.png" /><figcaption>Prisma Studio</figcaption></figure><p>Prisma Studio allows me to see all the data related to the models that I created in a nice GUI and can do basic CRUD operations. This totally removes the need for installing other 3rd-party tools for these kinds of workflows. 🎉</p><p>However, Prisma 2 is still in Beta so you might want to hold back on using it for production workloads. Once it is generally available and with the content from this post you should be able to manufacture a bleeding edge, production ready API on Lambda with GraphQL !💰</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FAatW9hUhdcX5e%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ftelevision-dance-the-office-AatW9hUhdcX5e&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FAatW9hUhdcX5e%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2f8c926c261a61c42a1435f909296f7/href">https://medium.com/media/e2f8c926c261a61c42a1435f909296f7/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4be711e93cc" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/lets-take-prisma-2-for-a-test-drive-on-aws-lambda-with-graphql-%EF%B8%8F-f4be711e93cc">Lets take Prisma 2 for a test drive on AWS Lambda with GraphQL 🏎️</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Systems Zero To Hero ]]></title>
            <link>https://itnext.io/design-systems-zero-to-hero-5eacf6dde999?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eacf6dde999</guid>
            <category><![CDATA[desig]]></category>
            <category><![CDATA[product-design]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Fri, 20 Dec 2019 12:00:24 GMT</pubDate>
            <atom:updated>2019-12-20T12:00:24.774Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I leveled up my design systems game and made two component libraries in React and Vue.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpHQK_N0XXFe5hQAOQTAeA.png" /></figure><p>I am on this Whatsapp group were there must be just around 100 devs who are into Blockchain, Machine Learning and Web development and I always thought that its a waste having people who solve problems for a living and we are not sharing or showing off the cool stuff we make. So I organized a meetup, 5 people showed and I made a monster of a talk on Design Systems, which brings us to this very medium post your eyes are feasting on. A link to the talk can be found <a href="https://www.figma.com/proto/KedEPuWZk0CXWWNAEf806cOZ/GOA?node-id=1692%3A35&amp;scaling=scale-down">here</a>.</p><p>In this post I’m gonna walk you through how I built two design systems and made component libraries in Vue called <a href="https://github.com/pimp-my-book/narshik">Narshik </a>and in React called <a href="https://github.com/pimp-my-book/umqombothi-component-library/blob/master/src/index.js">Umqombothi</a>. Hopefully by following along you could also build yours in no time at all. However the outputs are really bare bones and the goal is to get your design system out in the wild to be used in your apps and marketing activities.</p><h3><strong>Why do design systems exist?</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fa5viI92PAF89q%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freaction-a5viI92PAF89q&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fa5viI92PAF89q%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2c74c6d595a148db0c9f99ded280a56/href">https://medium.com/media/d2c74c6d595a148db0c9f99ded280a56/href</a></iframe><p>Design systems exist purely because they help teams provide a consistent brand and user experience for their products or services.</p><p>Your users are everywhere your brand is. Web, mobile, print, film and clothing are just a few places where your customers/users interact with your brand.</p><p>Design systems help bridge the gap between these different platforms and give your team guidelines on how to execute the design and brand.</p><p><strong>Lets see this in action from a company that does a great job of designing at scale</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbTp4kQAhVwGDIKOTrxjfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*yfogHMlt-t9jLGmAzUkYhA.jpeg" /></figure><blockquote>Netflix on the web</blockquote><blockquote>Netflix on iOS</blockquote><p>The Netflix brand is consistent, because where ever I choose to watch, it looks and feels the same everywhere. Other cool examples exist everywhere, check out the <a href="https://github.com/alexpate/awesome-design-systems">awesome-design-systems</a> repo for more examples.</p><h3><strong>How can it improve your ability as a designer/engineer?</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fe7OsUEFwy4Z4GvbjXM%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fshowtimesports-e7OsUEFwy4Z4GvbjXM&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fe7OsUEFwy4Z4GvbjXM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c9603d8c5251bd309a34e66153b18de/href">https://medium.com/media/3c9603d8c5251bd309a34e66153b18de/href</a></iframe><p>Thanks to <a href="https://tylermcginnis.com/">Tyler McGinnis</a> I always make sure I ask myself how can a tool, school of thought or workflow improve my ability to do what I do after I have established why it exists. My reasoning for design systems are the following:</p><p><strong>You can prototype faster</strong></p><p>When building out stuff you want to make sure that you’re able to make sure your business requirements are sound. So when making hi-fidelity prototypes the cognitive load of managing the styling of your app and still making sure the use cases are valid can really eat me up. Also if mockups do not look almost real enough you will struggle to get that important buy in from your team and decision makers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_sBd8Uvaup82qGxhSYL2rg.png" /><figcaption>Three screens where a student can select between ordering a book or calculator.</figcaption></figure><p>This took me about 15 minutes to do, while looking over a use case that has two different alternative steps. Since, I was able to easily drag and drop components willy nilly, I was able to focus on business requirements and get approval from stakeholders before worrying about fixing small details that might be affecting this design from a UX perspective.</p><p><strong>Enable sharing code between components</strong></p><p><a href="http://pmbnewsroom.netlify.com/">Pimp My Book</a> launched a bursary app called <a href="https://gogoa.co.za/">GOA </a>which helps university bursary students order their educational materials and aids bursaries to cut down on wastage. So I had initially made a landing page in Vue, then a month later I needed a tool to help me with documentation for the app. So I used <a href="https://gridsome.org/">Gridsome</a> after having a real trash time with <a href="https://vuepress.vuejs.org/">VuePress</a>, when starting on the <a href="https://help.gogoa.co.za/">docs site</a> I was copying and pasting code between projects. It was really ugly and painful, but I did not have time to waste while making the docs site so it did not justify the need to start on Narshik. Nevertheless making the docs site was an interesting risk because nobody on the team could see we need it and did not believe that it could be shipped in time.</p><h3><strong>Phases of building a design system ⚡️</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1PBjpxiEKR5ba%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fparks-and-recreation-ron-swanson-rec-gif-1PBjpxiEKR5ba&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F1PBjpxiEKR5ba%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="174" frameborder="0" scrolling="no"><a href="https://medium.com/media/07ed58ef73d98d6ad0cc5a324cd6dca3/href">https://medium.com/media/07ed58ef73d98d6ad0cc5a324cd6dca3/href</a></iframe><p><em>So I went through two phases: design and engineering.</em></p><p>Out of the design phase you need to come out with a UI Kit in a design tool of your choice, while in the engineering phase you need a component library packaged for your target platform (Web, iOS/Andriod, watchOS, tvOS etc).</p><h4><strong>Overview of design phase</strong></h4><p>I was a bit of a one man team at times. So it is not smart to do too much over designing in this stage of the project but rather keep things simple. If you’re in a larger team I would still recommend that you try to keep this stage simple and make sure engineers are participating in your plans for what the components will look like. Because you could come up with a design that your engineering team might not know how to pull off (even though that is what we’re paid to do 😝) and it will just take longer for the components to be shipped because they now have to go out of their way to figure out how to bring your over designed components to life.</p><p><strong><em>Design tools: choose one</em></strong></p><p>When it comes to design tools, it is easy to get overwhelmed. So I will make the decision for you!</p><blockquote><a href="http://figma.com/">FIGMA </a>is the way!<a href="http://figma.com/">FIGMA </a>is the way!<a href="http://figma.com/">FIGMA </a>is the way!<a href="http://figma.com/">FIGMA </a>is the way!</blockquote><p><strong><em>Why Figma?</em></strong></p><p>Besides a really generous free tier, you have all the serious functionality to be productive without needing to fork out money.</p><p>It is primarily based on the web so it solves accessibility problems without needing to have a certain OS or device.</p><p>Neat advanced features like local styles and the ability to access to your components in other pages come along with it. This video explains the concept of local styles nicely:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgtQ_A3imzsg%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgtQ_A3imzsg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgtQ_A3imzsg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a9ed0798238532e297f42fbafb0a8c3/href">https://medium.com/media/3a9ed0798238532e297f42fbafb0a8c3/href</a></iframe><p>Most importantly, you can illustrate, design various apps and host prototypes on it. Recently, plugins have just been launched meaning other makers are introducing extended functionality into Figma as well as the ability to prototype animations. It is now basically a one stop shop for everything in a designers workflow. Also I think Figma uses C++ under the hood with the help of Web Assembly. This is just further confirmation of how much heat Figma brings!!!👀</p><p><strong><em>Start on colours &amp; typography</em></strong></p><p>Once you have setup your colours and typography you are on the road to success. Simply go onto <a href="https://dribbble.com/">Dribbble </a>or <a href="http://pinterest.com/">Pinterest </a>and search/scroll through all those artsy UI’s you like and steal their colour palette.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VyAwW6tkhd7J4Il9XIrDCg.png" /><figcaption>GOA’s colour pallet in Figma.</figcaption></figure><p>You need to have at least two base colours and accents. So If we look at GOA’s DS, I set a base colour, then I go about two shades darker and two shades lighter to get four other shades from the base colour. Then do the same for your accents, which will always be yellow, blue, red, white and grey. For palettes go to <a href="http://coolors.co/">coolours </a>or <a href="https://colorhunt.co/">colourhunt</a>. I have Green (#4ECA5D) as my primary but I use the lightest green as my secondary colour (#D7FFF1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k2ibEjJ5osGmFnNYA4_kkw.png" /></figure><p>For your typography simply take two fonts from <a href="https://fonts.google.com/">Google Fonts</a>, one for headings and the other for your body text. Then have five or six main headings and have a body text, caption text and whatever text styles you want to implement.</p><p>Most importantly, systematize the sizing for your fonts and also spacing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6CpR1u0eSB71nbMP6kvIw.png" /><figcaption>This is just for spacing, however, you can have similar that systematizes spacing for your grids.</figcaption></figure><p><strong><em>Use premade components</em></strong></p><p>If you are sitting in your design tool of choice and making components from scratch like making a rectangle and adding widths, border radius and all that to make a button, then you need to rethink how you value your time. Pay it forward by using premade <a href="https://www.figmacrush.com/free-figma-ui-kits/">UI libraries </a>and then customize everything according to your set colours and typography that speak to your product’s identity.</p><p>I’ve been using the <a href="http://pdkit.co/">Product Design Kit 1.0</a> and it is extremely useful. It comes with premade UI components for the web, a handy style guide and all the hard work of setting up the local styles and component stuff has been done for you. This is a really good place to start and will make you productive sooner.</p><p><strong><em>It shouldn’t take you more than five days</em></strong></p><p>During this design phase, it should not take longer than a working week to get the UI library functional for you to build high fidelity mockups.</p><p>Our goal by doing this is to insure that you’re able to ship your project faster because key stakeholders might not be able to detect tangible progress in your project.</p><p>As mentioned earlier, you need a UI kit in your design tool of choice after a week of designing. Below are links to GOA’s and PMB +’s design systems in Figma:</p><p>💎 <a href="https://www.figma.com/file/KedEPuWZk0CXWWNAEf806cOZ/GOA?node-id=0%3A1">GOA</a></p><p>💎 <a href="https://www.figma.com/file/MH0ruI8pUrg7s2NXM4jra59W/PMB-%2B?node-id=0%3A1">PMB +</a></p><h4><strong>Overview of engineering phase 💅</strong></h4><p>So now you’re done with the designing of things. We get to bring things to life! You want to start planning how you are going to create a codebase that is maintainable for others and has an awesome developer experience.</p><p><strong><em>Choose a framework/language</em></strong></p><p>I’ve shipped two component libraries for different projects written in Vue and React respectively. I can’t say I have a favourite but the reasoning behind it is that I like doing more complicated apps with React and lightweight apps with Vue.</p><p>So choose either one and you should be good to go. However, my main consideration would’ve been if my team was larger and whether people know how to ship stuff in the framework of choice. Makes it a lot easier if you need someone to do something for you and they have an understanding of the framework, so you do not have to put their Jedi skills to the test unnecessarily.</p><p><strong><em>Decide on a strategy for your CSS</em></strong></p><p>So I’ve opted to use <a href="https://tailwindcss.com/">TailwindCSS </a>for both my projects. This was because it allows me complete control over custom styling and the use of utility classes. Which means I can ditch BEM and Styled Components altogether.</p><p>Personally I do not like overwriting existing styles from other UI libraries. This usually has me inspecting the dev tools just to change a colour. However, for complex components like an accordion, just import that specific component from a popular library and go through the pain of customizing it.🙃</p><p><strong>Playground for your components</strong></p><p>So when building the component library, you can’t structure it like you would a normal web app. This means no routing. You need to figure out how to export all your components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5zqUtRvU8Wy1YY6nBOcgQ.png" /><figcaption>index.js from Narshik written in Vue</figcaption></figure><p>In Narshik’s case I imported the components and chucked them into an object and looped over them to instantiate each as a new Vue component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TImlnb5Mhoca0UD4GlVySA.png" /><figcaption>index.js from Umqombothi written in React</figcaption></figure><p>While for Umqombothi all I had to do was export each as a named default export.</p><p>Then once that is done you need to a playground that allows you to refresh and view all your components as you are building them. In my case I first started using <a href="https://github.com/styleguidist/react-styleguidist">Styleguidist </a>but I was not liking the freedom it was giving me with larger components so I opted for <a href="https://storybook.js.org/docs/basics/introduction/">Storybook </a>and never looked back. Just like with Styleguidest you’re able to deploy the components for view as a static site, which I did for both <a href="https://umqombothi.netlify.com/">Umqombothi </a>and <a href="https://umqombothi.netlify.com/">Narshik </a>.</p><p>Only thing I found with Storybook is that I needed to get dirty with Webpack in order to use PostCSS as it is a dependency of TailwindCSS. Other than that you just need a storybook.config.js file that tells Storybook where to look for your stories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAN9knAU4DFMzjrhnNCiVQ.png" /><figcaption>storybook.config.js</figcaption></figure><p><strong>CI/CD &amp; Publishing</strong></p><p>Initially when I started building the library, I started with trying to get the simplest component to NPM and verifying it works by installing it in a CodeSandbox app.</p><p>To publish to NPM you just need to :</p><p>1. sign up for an account</p><p>2. generate a token for your application</p><p>So what I did was first deploy locally from my machine by using npm publish. First make sure you are logged into your account by using the npm login command. Then NPM will take care of the rest.</p><p><strong>Before I go over CI/CD lets just touch over my workflow.</strong></p><p>⚡️ create a branch for the component eg: feature/dropdown</p><p>⚡️Write a test case for my component. Here I basically state what it’s functionality needs to be.</p><p>⚡️ Create the component file, eg: Dropdown.vue and I would add a plain native HTML &lt;select&gt; tag.</p><p>⚡️ Then create a `Dropdown.story.js` file to make sure the Storybook server can pick it up.</p><p>⚡️ Then I would go out building the component till it matches the designs in my design system in Figma and has the desired functionality.</p><p>⚡️Once I’m happy with that I start finishing up my unit-test and make sure it passes locally.</p><p>⚡️Then I start merging the PR, since <a href="https://travis-ci.org/">Travis </a>is linked to my repo it will run all my other tests to make sure I’ve not introduced any bugs while editing any of the other components.</p><p>⚡️Once the tests have passed I merge the specific PR with master and Travis then will publish to <a href="https://www.npmjs.com/">NPM </a>on my behalf.</p><p>I use the <a href="https://testing-library.com/docs/react-testing-library/intro">React </a>and <a href="https://testing-library.com/docs/vue-testing-library/intro">Vue </a>implementations from the <a href="http://testing-library.com/">Testing Library</a>. Really easy to use, all you need is <a href="https://jestjs.io/">Jest</a> configured and install either library and you’re good to go. Here is an <a href="https://github.com/goldbergyoni/javascript-testing-best-practices">awesome link</a> on how to think about testing.</p><p>So Continuous Integration/Continuous Development is the practice of being able to easily add new code to your codebase without breaking or introducing new bugs into the codebase, while being able to deploy new code frequently and often. As well as automating the deployment process and running of tests.</p><p>(might not be accurate but this is how I understand it and implement it) 🏊</p><p>At work I use Travis for NPM libraries and <a href="https://seed.run/">Seed </a>for my Lambdas. While I use the CI baked into <a href="https://www.netlify.com/">Netlify </a>for my frontends.</p><p>These deployment tools are there to help you not constantly type in build commands in your terminal every time you want to ship something. So with Travis I just need to create a <a href="https://github.com/pimp-my-book/umqombothi-component-library/blob/master/.travis.yml">travis.yml</a> file and then give it an encrypted token from NPM. Creating a .yml file is a common practice among CI/CD tools to further automate the entire process and configure your deployments to your needs.</p><h3><strong>TL;DR </strong>😁</h3><p>Lets just sum up everything:</p><p>🔩 Grab a set of colours and decide on two fonts for your typography</p><p>🔩 Use an existing UI tool kit in your design tool of choice</p><p>🔩Customize the kit according to your brand and make all the components you need to achieve the UX you desire</p><p>🔩 Start with a typography component in your web framework of choice</p><p>🔩 deploy to NPM to verify everything is sound</p><p>🔩 Set up CI/CD + unit tests</p><p>🔩 Then build out each component one by one with unit tests. Basically every PR should be a new component added to the library for a user to use.</p><p>🔩Repeat the cycle until all your required components are done.</p><p>Okay but this is all nice, however, one must ask what issues are you most likely to encounter when embarking on the design systems journey?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F11e0gEWxYoSYTK%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freactiongifs-mrw-oc-11e0gEWxYoSYTK&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F11e0gEWxYoSYTK%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="178" frameborder="0" scrolling="no"><a href="https://medium.com/media/be442573768c1a3b3906f7080209e4af/href">https://medium.com/media/be442573768c1a3b3906f7080209e4af/href</a></iframe><p><strong><em>Time </em></strong>⏰</p><p>You are in the best position to determine whether there is time on a project to start on a design system. So make sure you’re taking a calculated risk if you have strict deadlines. If there is no time, what is always best is to at least have the design system in Figma and enforce the guidelines in your application’s components instead of having a published component library. This way there is still a documented guideline for your team to enforce. You are also using a design system but just a little half baked, which is better than nothing.</p><p><strong><em>Versioning </em></strong>🔧</p><p>It is really easy to mess up while bringing updates for bug fixes and everything in between. There is something called <a href="https://semver.org/">semantic versioning </a>, give it a try with your library and hopefully you can avoid the same blunders I made.</p><p><strong><em>SSR compatibility</em></strong> 📡</p><p>In some cases your library might need to be used for apps that are <a href="https://flaviocopes.com/react-server-side-rendering/">Server Side Rendered</a>. Umqombothi is SSR compatible while Narshik is not because it was not a requirement. For Umqombothi I had to include my entire src/ folder that used named default exports to export the components. I tried using <a href="https://rollupjs.org/guide/en/">Rollup.js</a> that made a dist folder with es &amp; commonjs modules, but they did not work. There is very little literature on how to make a component library SSR compatible, so you its one of things you have to constantly try different bundling strategies till something sticks.</p><p><strong><em>Documentation </em></strong>📎</p><p>One thing that is missing from Narshik &amp; Umqombothi is clear documentation in terms of providing instructions on how to use the design system and component library. However this in itself is another time consuming task that if time is not on your side might be smart to let it sit first class in the backlog.</p><h4>Resources used</h4><p>🚀 <a href="https://refactoringui.com/">Refactoring UI</a></p><p>🚀 <a href="https://www.designbetter.co/design-systems-handbook">Design Systems Handbook</a></p><p>🚀 <a href="https://github.com/chakra-ui/chakra-ui">Chakra UI</a></p><p>🚀 <a href="https://exploringjs.com/es6/">Exploring ES6</a></p><p>🚀 <a href="https://github.com/segmentio/evergreen">Evergreen</a></p><p>With all that said, hope you found my journey into design systems insightful and would love see what component libraries you’ve built, as well as your personal experiences building them. Most importantly if you found a way for me to do things better in my approach, give me a shout in the comments! 👯‍♀️</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FkGW0Vv1YgGMKzZdQyU%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fworldrugby-rugby-england-rwc2019-kGW0Vv1YgGMKzZdQyU&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FkGW0Vv1YgGMKzZdQyU%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd57f5d4e3e224db9a74929f858ba525/href">https://medium.com/media/dd57f5d4e3e224db9a74929f858ba525/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eacf6dde999" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/design-systems-zero-to-hero-5eacf6dde999">Design Systems Zero To Hero 🎉</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing the Serverless GraphQL NodeJS Starter ‍♂️]]></title>
            <link>https://itnext.io/introducing-the-serverless-graphql-nodejs-starter-%EF%B8%8F-c9de0ab285ae?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9de0ab285ae</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Thu, 21 Nov 2019 11:02:04 GMT</pubDate>
            <atom:updated>2019-11-21T11:02:04.421Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1W2Lhqmu1KLA81Kb_FdPlg.png" /></figure><p>I found myself writing serverless GraphQL APIs by hand far too often in the middle of the year. So I took the <a href="https://github.com/AnomalyInnovations/serverless-nodejs-starter">Serverless NodeJS Starter kit</a> from the lovely folks who made the <a href="https://serverless-stack.com/">Serverless Stack tutorial </a>and adapted it to support <a href="https://graphql.org/learn/queries/">GraphQL queries and mutations</a>. Thus introducing the <a href="https://github.com/pimp-my-book/serverless-graphql-nodejs-starter">Serverless GraphQL Starter Kit</a> !</p><p>This kit targets <a href="https://aws.amazon.com/lambda/">AWS Lambda</a> specifically with <a href="https://www.apollographql.com/docs/apollo-server/">Apollo Server </a>. However, I am pretty sure you can configure it with <a href="https://cloud.google.com/">GCP </a>and <a href="https://azure.microsoft.com/en-us/">Azure</a> as Apollo does have implementations for them. Once installed you can deploy the function, extend it by linking other resources like <a href="https://aws.amazon.com/dynamodb/">DynamoDB </a>tables , <a href="https://aws.amazon.com/s3/">S3 Buckets</a> etc.</p><p>If you want to take a microservices approach, you would need to experiment with <a href="https://www.apollographql.com/docs/apollo-server/federation/introduction/">Apollo federation</a> and be prepared to get your hands dirty. Also if you are seeking to use <a href="https://www.apollographql.com/docs/apollo-server/data/subscriptions/">Subscriptions </a>for real time use cases, I would recommend using<a href="https://aws.amazon.com/appsync/"> AWS AppSync</a> which is a serverless GraphQL managed backend. Then you would just need to configure your Client on your frontend to accept <a href="https://medium.com/open-graphql/apollo-multiple-clients-with-react-b34b571210a5">multiple API endpoints</a>, then Bob is your uncle.</p><h4>What about integrating different databases types? 🤔</h4><p>Well here is an <a href="https://github.com/pimp-my-book/pmb-plus-backend-poc">example with DynamoDB</a> and if you want to use <a href="https://aws.amazon.com/rds/aurora/?nc2=h_ql_prod_db_aa">Aurora </a>then you can check out this <a href="https://serverless.com/blog/graphql-api-mysql-postgres-aurora/">excellent post</a> by Gareth from <a href="https://serverless.com/">Serverless</a>. If you are worried about cold starts due to your lambda being in a VPC (Virtual Private Cloud), you shouldn’t worry too much. On a project I am currently working on I see about 3–6 seconds of loading time for queries and mutations.</p><p>My advice would be to use a regular RDS MySQL/ PostgreSQL instance for your local development and then spin up two Serverless Aurora clusters for either MySQL/ PostgreSQL for your dev and prod stages. This is because the Lambda needs to be in the same VPC as Aurora, and when working locally you will get the dreaded “<strong><em>Unexpected token S in JSON at position 0</em></strong>” error message, if you’re trying to access your Serverless Aurora clusters. Unless someone has a working alternative please share 🙃.</p><p>Furthermore, I was unable to get the lambda working using <a href="http://knexjs.org/">Knex </a>and <a href="https://sequelize.org/">Sequelize </a>as an ORM. Once I settled on the <a href="https://github.com/jeremydaly/serverless-mysql">Serverless MySQL</a> module I was good to go. I was getting internal server errors for too many times and was happy to compromise writing raw SQL to get the project up and running.</p><p>If you are new to Serverless or GraphQL, at <a href="https://pimpmybook.co.za/">Pimp My Book</a> we created a resource to skill up engineers to get up to speed with these awesome technologies called <a href="https://github.com/pimp-my-book/CodeJavaScript">#CodeJavascript</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F5PhpqBTmiqNFsvwNxS%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ff1-win-celebrate-5PhpqBTmiqNFsvwNxS&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F5PhpqBTmiqNFsvwNxS%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/60a01a436ea23cd460a74c34296006e4/href">https://medium.com/media/60a01a436ea23cd460a74c34296006e4/href</a></iframe><blockquote>GraphQL all the thiiiings!!! 🎉🌟🎈</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9de0ab285ae" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/introducing-the-serverless-graphql-nodejs-starter-%EF%B8%8F-c9de0ab285ae">Introducing the Serverless GraphQL NodeJS Starter 🤩👷🏾‍♂️</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Get Started With GraphQL  ]]></title>
            <link>https://medium.com/@PrinceAshburton/how-to-get-started-with-graphql-a3fbe3d154a1?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3fbe3d154a1</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Sun, 17 Feb 2019 18:35:21 GMT</pubDate>
            <atom:updated>2019-02-17T18:35:21.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2yznzxf-1s6cNlrQX8LXA.png" /></figure><p>This post aims to provide you with a direction on how to get to grips with <a href="https://graphql.org/">GraphQL</a>. 99% of the resources covered are free they only cost your time.</p><p>I am not going to bother trying to convince you why you should adopt GraphQL over <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST </a>but rather direct you to project related resources, videos and reading material that will allow you to form your own opinion on whether it would be worth it trying to deliver value to your customers/users. If you go over these resources and manage to recreate them with your own projects, you will be able to use GraphQL in production in no time.</p><h3>How to GraphQL</h3><p><a href="https://www.howtographql.com/">How to GraphQL - The Fullstack Tutorial for GraphQL</a></p><p>This resource is an effort by the folks at <a href="https://www.prisma.io/">Prisma </a>that helps the community get to grips with GraphQL. They provide various tutorials depending on your tech stack preference. I recommend that go through the introduction and you choose the language you currently use and do the tuts for the Backend. There is only one Frontend tut for React and a repo for <a href="https://github.com/howtographql/vue-apollo">Vue</a>. This means that for iOS and Android you’re going to need to fly solo and read Apollo’s documentation or do some Googling.</p><p>Then once you’re done, you’ve gotta choose a project idea and use the learnings from the tutorials and implement your own project. Here are GraphQL related projects you can reference while building yours:</p><ul><li><a href="https://github.com/AmoDinho/formulaone-graphql-client">FanBoost</a></li><li><a href="https://github.com/wesbos/Advanced-React">SickFits </a>(You can take <a href="https://advancedreact.com/">Wes’ paid course</a> if you like)</li><li><a href="https://github.com/alan345/naperg">Naperg</a></li></ul><p>For ideas I’d suggested doing an extension of something you’re really interested in. For example, I like Star Wars so I would make a Galactic Map App that helps the Death Star navigate through Hyperspace or a weapons registry for Stormtroopers. But <a href="https://medium.freecodecamp.org/want-to-build-something-fun-heres-a-list-of-sample-web-app-ideas-b991bce0ed9a">here </a>and <a href="https://medium.freecodecamp.org/the-secret-to-being-a-top-developer-is-building-things-heres-a-list-of-fun-apps-to-build-aac61ac0736c">here </a>are regular ideas if you need, remember keep it light and simple!</p><p>There is a chance you might not use Prisma for a production app, which is fine. As Prisma is just an ORM, all the other GraphQL principles will still be applicable when using other libraries. Your recreation of those tutorials is just a quick throwaway to get to grips with GraphQL.</p><h3>Wrapping Around A Rest API</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLillGF-RfqbZrjw48EXLdM4dsOhURCLZx&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DSEMTj8w04Z8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FSEMTj8w04Z8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ab35a1e87fdafaee72c4138f48be658/href">https://medium.com/media/0ab35a1e87fdafaee72c4138f48be658/href</a></iframe><p>This video course (four-part) by Brad Travesy is excellent as he will walk you through taking an existing REST API and wrap it in GraphQL. Most importantly he will help you deploy the app too!</p><p>After you’re done with it, find an existing REST API and wrap it with GraphQL. Here are a l<a href="https://github.com/toddmotto/public-apis">ist of public APIs</a> to help you.</p><p>Why this is important,is because most likely your company will have existing REST APIs that you can wrap with GraphQL and convince your work-mates of GraphQL’s value. Or even better there are existing REST APIs out there that you can use to form the basis of a product for a startup by wrapping it in GraphQL API.</p><h3>More Video Content</h3><p>The following videos are a mixture of talks and tuts</p><ul><li><a href="https://youtu.be/DyvsMKsEsyE">Begineer GraphQL Series</a> by Ben Awad</li><li><a href="https://youtu.be/UBGzsb2UkeY">Zero to GraphQL in 30 Minutes</a> by Steven Luscher || <a href="https://github.com/steveluscher/zero-to-graphql">Github Repo</a></li><li><a href="https://youtu.be/8DNzDKAMPTw">From Idea to IPO: Convincing Your CTO about GraphQL</a> by Abhi Arora</li><li><a href="https://youtu.be/eUrtRzqN0h0">Hard-Learned GraphQL Lessons: Based on a True Story</a> by Natalie Qabazard &amp; Aditi Garg</li><li><a href="https://youtu.be/iW4il6wUlvs">Wrapping REST with GraphQL</a> by Jon Wong</li><li><a href="https://youtu.be/zVNrqo9XGOs">Lessons from 4 Years of GraphQL</a> by Lee Byron</li></ul><h3>GraphQL In Serverless Environments</h3><p>📹 : <a href="https://youtu.be/AjbeIwWIyw8">GraphQL + Serverless === 😎</a></p><p>For Serverless examples look below:</p><ul><li><a href="https://github.com/serverless/serverless-graphql">Serverless GraphQL</a></li><li><a href="https://github.com/boazdejong/serverless-graphql-api">Serverless GraphQL API using Lambda and DynamoDB</a></li><li><a href="https://github.com/nikhilaravi/serverless-graphql">Serverless Jukebox app</a></li><li><a href="https://github.com/DasithKuruppu/serverlessGraphQL">Boilerplate for serverless/lambda on AWS using Cloud Formation with graphQL as the API</a></li><li><a href="https://github.com/briantbates/slbugs">Serverless Bug Tracker</a></li></ul><p>Also I am going to include Vanilla GraphQL examples just for control 🎈 :</p><ul><li><a href="https://github.com/nikolasburk/plain-graphql">plain-graphql</a></li><li><a href="https://github.com/aurelkurtula/IMDBgraphql">IMDBgraphql</a></li><li><a href="https://github.com/chentsulin/awesome-graphql">awesome-graphql</a></li></ul><h3>Reading Material</h3><h4>GraphQL Docs</h4><p>The docs of any technology is always a great place to start:</p><p><a href="https://graphql.org/learn/">Introduction to GraphQL | GraphQL</a></p><h4>Learning GraphQL</h4><p>This book by Eve Porcello and Alex Banks is great! The book you gotta purchase but the code is Open Source! 😍</p><p>The book:</p><p><a href="http://shop.oreilly.com/product/0636920137269.do">Learning GraphQL</a></p><p>The repo:</p><p><a href="https://github.com/MoonHighway/learning-graphql">MoonHighway/learning-graphql</a></p><h4>Full-stack React + GraphQL Tutorial</h4><p>This eight part series walks you through building a full-stack GraphQL app courtesy of the Apollo GraphQL blog:</p><p><a href="https://blog.apollographql.com/full-stack-react-graphql-tutorial-582ac8d24e3b">Full-stack React + GraphQL Tutorial</a></p><h4>GraphQL Glossary</h4><p>You will cover a ton of terms while building, this glossary should help get that smart brain of yours around all of them:</p><p><a href="https://www.apollographql.com/docs/resources/graphql-glossary.html">GraphQL Glossary | Platform</a></p><p>Hopefully these resources help you get to the point of seeing how GraphQL can be an awesome tool in your arsenal. However, a word of warning it is completely useless just following along with the tutorials/videos etc mentioned in this post. You really need to create your own projects with the content from them to reach the necessary level of mastery to use the technology in production!</p><h4>GraphQL All The Things! 😁✨🤠👯‍♂️🎉</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FuiKYGWayrTPN6gLkDE%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ff1-sebastian-vettel-lewis-hamilton-uiKYGWayrTPN6gLkDE&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FuiKYGWayrTPN6gLkDE%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/437f8b7bcbc79ad28597fdaa99612c1e/href">https://medium.com/media/437f8b7bcbc79ad28597fdaa99612c1e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3fbe3d154a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Experience With Severless GraphQL ‍]]></title>
            <link>https://itnext.io/my-experience-with-severless-graphql-2e95e5a8bda7?source=rss-a6d2ffd91457------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e95e5a8bda7</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Amo Moloko]]></dc:creator>
            <pubDate>Tue, 12 Feb 2019 17:13:17 GMT</pubDate>
            <atom:updated>2020-12-15T08:34:16.199Z</atom:updated>
            <content:encoded><![CDATA[<h3>My Experience With Serverless GraphQL 👨‍🎨</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYTNkYl3bVKol0d91_nOmw.png" /></figure><p>I started work at Pimp My Book in the second week of December 2018, my first task was to develop a proof of concept for our bursary division. Basically, university students were placing orders for textbooks via Google Forms and email last year in the company’s first attempt at taking this division on board. Our clients needed to see some form of improvement and also our staff needed a more automated approach to the entire process.</p><p>From the 10th of December fast forward 4 weeks into the future I managed to Deliver <a href="http://zansi.co.za/">Zansi</a>! A simple bare bones service that allows students to place orders for their textbooks and allows the staff at <a href="http://www.pimpmybook.co.za/">Pimp My Book</a> the ability to see those orders come in and update their status (eg: on-order, delivered, etc) and information like which vendor has the book, its delivery date and so forth.</p><p>With that background in mind, this did not come without its troubles to get to the end goal. In the second half of 2018, I invested lot of time in my honours programme to learn <a href="https://graphql.org/">GraphQL</a>. However, I first started off using <a href="https://www.prisma.io/">Prisma </a>and shipped <a href="https://github.com/AmoDinho/formulaone-graphql-client">FanBoost</a>. My overall opinion was that there are a few aspects of Prisma that would just complicate my ability to deliver Zansi on time and their support for Serverless deployments needed a bit more configuration. It would be doable but not ideal for the extremely short deadline hanging over my head.</p><p>Also, <a href="https://aws.amazon.com/appsync/">AWS AppSync</a> was an option but I was extremely skeptical of the ability to implement custom business logic in their resolver mapping templates. Originally, I was under the misguided assumption that you’re not given the ability to write the resolvers in the programming language of your choice. But you are able to so in the form of <a href="https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html">Lambdas</a>, you can also check out this <a href="https://medium.com/thundra/making-appsync-easier-with-thundra-6570994cda5b">post by Sarjeel Yusf</a> that walks you through using Lambda as a data source for you AppSync service.</p><p>So I decided on <a href="https://www.apollographql.com/docs/apollo-server/deployment/lambda.html">Apollo-Server-Lambda</a> on <a href="https://aws.amazon.com/lambda/">AWS lambda</a> for my backend with a Node.JS runtime and use the <a href="https://serverless.com/">Serverless Framework</a>. While choosing React with <a href="https://www.apollographql.com/docs/react/">Apollo-Client </a>on the Front-end with a <a href="https://www.designbetter.co/design-systems-handbook">design system</a> powered by <a href="https://styled-components.com/">Styled-Components</a>.</p><p>There were several stumbling blocks that filing Github issues, emailing people and Googling just did not solve. So below are things that tripped me up, because literally I spent several days wondering how the hell people use GraphQL in serverless environments, you on the other hand do not deserve the pain and frustration I went through.</p><h3>Catch 1 : Do Not Invoke It Like a REST API 😒</h3><p>After creating my “Hello World” equivalent of a Serverless GraphQL API, I made the mistake of invoking it locally like so:</p><pre>$ serverless invoke local -function graphql</pre><p>and I would get the following error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uV1HOnINOCnZGkTu3Hyhkg.png" /></figure><p>Do not be a wasteman like me, all you gotta do is run:</p><pre>$ sls offline</pre><p>then navigate to <strong>localhost:4000/name_of_endpoint</strong> in your browser and <a href="https://github.com/prisma/graphql-playground">playground</a> will open. However, you gotta make sure your <strong>serverless.yml</strong> is configured like such:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*VEcJuaeH62vAARZp0oBjwg.png" /></figure><h3>Catch 2: Authentication With Cognito On Lambda</h3><p>In most cases you will need to know who your users are in your app and what they are able to access and do within your app.</p><p>One thing to note is that no matter what tool you’re using for authentication all of them can be configured to work with your GraphQL API.</p><p>This talk below helped me get an idea of the mental model needed to implement authentication for my API:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F4_Bcw7BULC8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4_Bcw7BULC8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F4_Bcw7BULC8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a7c3d9c15ed577cb7524820317d5002/href">https://medium.com/media/6a7c3d9c15ed577cb7524820317d5002/href</a></iframe><p>In my case, I used <a href="https://aws.amazon.com/cognito/">AWS’ Cognito</a> service. Step 1 would be to make sure you have created userpools for your Dev and Prod environments.</p><p>Then make sure your <strong>serverless.yml</strong> for the function is configured like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*Kbw3QInyJRZkC-7rkKrnlg.png" /></figure><p>Because you are using an AWS service, Cognito’s payload will be available in the context of your lambda so there is no extra config needed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Qk1Ac3BC5S_E4NQLxscgw.png" /><figcaption>graphql.js</figcaption></figure><p>Now, how do you access your users’ attributes? Due to using the <strong>lambda_proxy </strong>integration there is a different way to access them :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fI6uNj_4jZgvyay8aMpUog.png" /></figure><p>If you needed to add custom attributes to your Cognito Pool you can easily add them but make sure you make them readable and writable by doing the following:</p><h4>Step 1</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*3rv4vdmXrbTbYoZZA6x-DQ.png" /><figcaption>First make sure you’ve created the custom attribute, then click App Clients</figcaption></figure><h4>Step 2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*mDFntF0pLLqa9BRFS0QzKQ.png" /><figcaption>Then click show details then “set attribute read and write permissions”</figcaption></figure><h4>Step 3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*8WC1MUhJxrw_GGFcHjqZgw.png" /><figcaption>Then tick the relevant attribute you need to be readable and writable and save the changes.</figcaption></figure><p>Now how do you go about testing your API in Playground? Dam good question mate🤯 !</p><ol><li>I first had to hard code the cognito variables with dummy variables to run the function locally. This is because Serverless Offline does not work with custom authorizers.</li><li>Once happy I push to Dev, then I generate a <a href="https://jwt.io/">JWT </a>from the front-end and visit my dev endpoint and paste the token in authorization header.</li><li>After this, I hook up the relevant query/mutation to the front-end.</li></ol><p>Not Ideal, but I’m yet to find a nice work around for this, please share if you have a better way avoid this crappy process!</p><h3>Catch 3: Authentication With Cognito In React</h3><p>On the front-end things are quite easy. You just need to install <strong>react-apollo or your preferred Apollo client library </strong>and set up an auth header for your endpoint with like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yuD-Fwn6oCdZ6y97ZwpGwQ.png" /><figcaption>index.js</figcaption></figure><p>For your Sign up component, this is how you submit the custom Cognito attributes with <a href="https://aws-amplify.github.io/">Amplify</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGLZK08ohf7X9v5E4mnGCg.png" /></figure><p>Only issue with Amplify is that by default the users info is stored in localStorage, so a workaround needs to be investigated thoroughly for apps with stricter security requirements. I think using Cookies might be the way to go.</p><h3>Catch 4: Not Understanding The Superpowers Of A ‘serverless.yml’ File</h3><p>Your <strong>serverless.yml</strong> is the middleman between you and your AWS services. You should invest time in understanding how to configure this properly to be able to speak to your various services. Understanding the link between it and cloud-formation helped me overcome some of the authentication issues I faced with Cognito.</p><p>This <a href="https://serverless.com/framework/docs/providers/aws/events/apigateway/">serverless doc</a> explores different options available to you to configure your <strong>serverless.yml</strong> in a particular way to get different API Gateway configurations.</p><h4>In closing, now that students are placing orders for their textbooks, what are things I regret?</h4><p>Mainly using <a href="https://www.dynamodbguide.com/">DynamoDB</a>, it does not accept empty strings and has tonnes of reserved Keywords that bit me in the arse.</p><p>With that adventure under my belt, GraphQLing all the things was certainly worth it. Outside of the above issues I faced, all I can say is that the more you’re able to embrace getting stuck and understand that its part of the process which is unique to your job as a dev the easier it will be to fix your blockers. Just my 2c…💰</p><h4>GRAPHQL ALL THE THINGS!! ✨🤠</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl2SpPgYMDCBFEptfi%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fl2SpPgYMDCBFEptfi&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl2SpPgYMDCBFEptfi%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="232" frameborder="0" scrolling="no"><a href="https://medium.com/media/cebecf8e8f6e699ef9e61d759e996be6/href">https://medium.com/media/cebecf8e8f6e699ef9e61d759e996be6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e95e5a8bda7" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/my-experience-with-severless-graphql-2e95e5a8bda7">My Experience With Severless GraphQL 👨‍🎨</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>