<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cameron Paige</title>
    <description>The latest articles on DEV Community by Cameron Paige (@cfpaige).</description>
    <link>https://dev.to/cfpaige</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F188506%2Ffccad196-9a7d-42ce-b7ec-7decad7170d1.jpeg</url>
      <title>DEV Community: Cameron Paige</title>
      <link>https://dev.to/cfpaige</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cfpaige"/>
    <language>en</language>
    <item>
      <title>Fixing "not found: java" Mock API endpoint error</title>
      <dc:creator>Cameron Paige</dc:creator>
      <pubDate>Thu, 19 Dec 2019 20:13:02 +0000</pubDate>
      <link>https://dev.to/cfpaige/fixing-not-found-java-mock-api-endpoint-error-4eoi</link>
      <guid>https://dev.to/cfpaige/fixing-not-found-java-mock-api-endpoint-error-4eoi</guid>
      <description>&lt;p&gt;TL;DR: &lt;strong&gt;Download the Java SDK, then manually add the path to your environment variables.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;"My middle name is Edge Case," I joked, my hand the only one raised in a room of about 100 people. At that moment, I was the only person still unable to get &lt;code&gt;amplify mock api&lt;/code&gt; to work on the command line. &lt;/p&gt;

&lt;p&gt;The problem? No java:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YBwzeYSi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0xk5wa1kqjs64tm2rjxv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YBwzeYSi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0xk5wa1kqjs64tm2rjxv.png" alt='Screenshot of Git Bash CLI with red message "Failed to start API Mock endpoint Error: not found: java"'&gt;&lt;/a&gt;&lt;br&gt;
Easy fix. I found what I thought would be the right &lt;code&gt;npm&lt;/code&gt; package and blithely hit &lt;code&gt;Enter&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;I got back a wall of error messages, mostly having to do with &lt;code&gt;gyp&lt;/code&gt; missing &lt;code&gt;Python&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GWZKRqXZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lq8cwidykk9tae7dea3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GWZKRqXZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lq8cwidykk9tae7dea3w.png" alt='Screenshot of Git Bash CLI with multiple "gyp ERR! find Python" error messages and instructions for installing Python'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thankfully, somebody nearby was having a similar issue and had just solved it by downloading the &lt;a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk13-downloads-5672538.html"&gt;Java SDK&lt;/a&gt; directly from Oracle.&lt;/p&gt;

&lt;p&gt;I grabbed the Windows version, installed it, and ran &lt;code&gt;amplify mock api&lt;/code&gt; again. Again, it told me I had no java.&lt;/p&gt;

&lt;p&gt;I went into Programs and checked. There it was, happily ensconced between Internet Explorer (huh?) and Killer Networking (uhm... huh?).&lt;/p&gt;

&lt;p&gt;Maybe it was telling me I needed more coffee? I tried that. No luck.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aOUtXQiO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q6j5x3ayhjcixgaqe3dz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aOUtXQiO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q6j5x3ayhjcixgaqe3dz.jpg" alt='Photo of two coffee dispensers both labeled "Breakfast Blend"'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But then something clicked. I remembered similar issue I'd ran into during boot camp (the only Windows 10 user in my class). The solution then was to manually enter the path into Environment Variables.&lt;/p&gt;

&lt;p&gt;To try that, I went to the Control Panel\System and Security\System and clicked on &lt;a href="https://www.isumsoft.com/it/5-methods-to-open-windows-10-system-properties-advanced/"&gt;Advanced system settings&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C4TYGVw4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dhwce1yn32ahx43c9qch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C4TYGVw4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dhwce1yn32ahx43c9qch.png" alt="Screenshot of Windows Control Panel with the link to Advanced system settings highlighted in blue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the System Properties/Advanced panel that opened, I clicked on Environment Variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z1nGfLz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jrf9y9cx5uji2ckq5lyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z1nGfLz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jrf9y9cx5uji2ckq5lyl.png" alt="Screenshot of the System Properties/Advanced panel with the Environment Variables button highlighted in blue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That took me to the panel with &lt;code&gt;User&lt;/code&gt; and &lt;code&gt;System&lt;/code&gt; variables, both including the option to add a new &lt;code&gt;Path&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qrRxjLCV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/211b38fanc1r7vh1lyhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qrRxjLCV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/211b38fanc1r7vh1lyhk.png" alt="Screenshot of the System Variables panel with Path highlighted in gray for User variables and blue for System"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I first selected the User variables &lt;code&gt;Path&lt;/code&gt; and clicked on &lt;code&gt;Edit&lt;/code&gt;. That took me to the Edit environment variable panel with an option to add a new &lt;code&gt;Path&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l2Tu_P8L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t7tg1dwbyzqcujag47ru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l2Tu_P8L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t7tg1dwbyzqcujag47ru.png" alt="Screenshot of the Edit environment variable panel with New button and an empty row under existing paths highlighted in blue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make sure I entered the path correctly, I used the File Explorer to navigate into the &lt;code&gt;bin&lt;/code&gt; folder for &lt;code&gt;Java&lt;/code&gt;, then right clicked on the address to copy it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iGMhHuhm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fphaoxrh2af1kjx4fwig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iGMhHuhm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/fphaoxrh2af1kjx4fwig.png" alt="Screenshot of a File Explorer window opened to the bin folder inside the Java folder, with the option to copy the address highlighted"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I copied and pasted it into both &lt;code&gt;User&lt;/code&gt; and &lt;code&gt;System&lt;/code&gt; Path variables, and clicked &lt;code&gt;OK&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Th2b5S_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3xgs9w19d1galeihik3h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Th2b5S_u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3xgs9w19d1galeihik3h.png" alt="Screenshot of the Edit environment variable panel with the copied address pasted into the row under existing paths and the OK button highlighted in blue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, I kept clicking &lt;code&gt;OK&lt;/code&gt; until I was out of the Control Panel. Then, for the changes to register with the CLI, I had to close and reopen it again. Finally, I ran &lt;code&gt;amplify mock api&lt;/code&gt; one more time...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DiINTBQz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1s06735pndys6r6ia4u6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DiINTBQz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1s06735pndys6r6ia4u6.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It worked!&lt;/p&gt;

&lt;p&gt;And so, at long last, I could carry on with the workshop, &lt;a href="https://github.com/dabit3/aws-appsync-react-workshop"&gt;building real-time offline-ready applications with React, GraphQL &amp;amp; AWS AppSync&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>aws</category>
      <category>amplify</category>
    </item>
    <item>
      <title>Testing GraphQL Schema Without Data</title>
      <dc:creator>Cameron Paige</dc:creator>
      <pubDate>Wed, 06 Nov 2019 07:28:21 +0000</pubDate>
      <link>https://dev.to/cfpaige/testing-graphql-schema-without-data-4dek</link>
      <guid>https://dev.to/cfpaige/testing-graphql-schema-without-data-4dek</guid>
      <description>&lt;p&gt;"Cannot" is not in my vocabulary. So when I couldn't get GraphQL to work the way the tutorial I was following promised it would, I got a little bit... obsessed.&lt;/p&gt;

&lt;p&gt;So it's not much of a surprise that now, just a couple of months since the end of the bootcamp, I find myself in a hands-on two-day GraphQL workshop.&lt;/p&gt;

&lt;p&gt;Apart from the expected, what I learned today was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;that nobody else in the room had attempted using GraphQL with both Apollo and Prisma. (So maybe I should cut myself some slack there.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;that you can and should put comments in your schema.graphql file. (Something for another post.) And finally,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;that there's a way (not mentioned in the &lt;a href="https://graphql.github.io/graphql-spec/draft/"&gt;GraphQL spec&lt;/a&gt;*) to test the schema without creating a dedicated &lt;code&gt;.json&lt;/code&gt; file or fetching actual data from anywhere else.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's how:&lt;/p&gt;

&lt;p&gt;Set up your &lt;code&gt;index.js&lt;/code&gt; to require &lt;code&gt;apollo-server&lt;/code&gt; only**, and write your schema directly below. In the picture below, we were working on a simple schema for coffee orders at a cafe:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--owievfE---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zspew9oo2w0ww89tagk8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--owievfE---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zspew9oo2w0ww89tagk8.PNG" alt='Screenshot showing const { ApolloServer, gql } = require("apollo-server")' title="Require Apollo-Server Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, below your schema and resolvers, set up the server to use mock data for all your types:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SvJUbVvE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/m6cp3l46h273x8zgo84w.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SvJUbVvE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/m6cp3l46h273x8zgo84w.PNG" alt="Screenshot showing const server = new ApolloServer({ typeDefs, resolvers, mocks: true });" title="New Apollo-Server Using Mocks Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you run &lt;code&gt;npm start&lt;/code&gt; now, you should be able to test your schema locally in the &lt;a href="https://www.apollographql.com/docs/apollo-server/testing/graphql-playground/"&gt;GraphQL Playground&lt;/a&gt;, with dummy variables substituted for actual data.&lt;/p&gt;

&lt;p&gt;In the below example, I ran the &lt;code&gt;allFoodItems&lt;/code&gt; query asking for &lt;code&gt;name&lt;/code&gt; (specified as the scalar type String in the schema) and &lt;code&gt;price&lt;/code&gt; (scalar type Float), and got a valid response (textual data for &lt;code&gt;name&lt;/code&gt; and a signed double-precision fractional value for &lt;code&gt;price&lt;/code&gt;):&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Scvh_ekj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9c2wj2xpzx3msb8pfcgw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Scvh_ekj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9c2wj2xpzx3msb8pfcgw.PNG" alt="Screenshot of the GraphQL Playground Query Response"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if you do have some of the data already available, you can avoid it being overwritten with mock values by adding &lt;code&gt;mockEntireSchema: false&lt;/code&gt; to the &lt;code&gt;server&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h5hH5ro6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5d6ew3ce0vu4ah0wcymp.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h5hH5ro6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5d6ew3ce0vu4ah0wcymp.PNG" alt="Screenshot showing const server = new ApolloServer({ typeDefs, resolvers, mocks: true, mockEntireSchema: false });"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;*I'd know. I always read the docs.&lt;/p&gt;

&lt;p&gt;**I'm assuming that you're familiar with Node.js and have installed the necessary packages (&lt;code&gt;apollo-server&lt;/code&gt;, &lt;code&gt;graphql&lt;/code&gt;, and &lt;code&gt;nodemon&lt;/code&gt;) already.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>graphql</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>What's the point of pseudo-coding anyway?</title>
      <dc:creator>Cameron Paige</dc:creator>
      <pubDate>Wed, 16 Oct 2019 17:04:20 +0000</pubDate>
      <link>https://dev.to/cfpaige/what-s-the-point-of-pseudo-coding-anyway-4ldf</link>
      <guid>https://dev.to/cfpaige/what-s-the-point-of-pseudo-coding-anyway-4ldf</guid>
      <description>&lt;p&gt;One of the first assignments we were given during coding boot camp was to write out the instructions for making a PB&amp;amp;J sandwich. No code, just the steps.&lt;/p&gt;

&lt;p&gt;"But WHY?," I asked (always the trouble-maker).&lt;/p&gt;

&lt;p&gt;Because it would help us understand how fastidious computers were when it came to incomplete or ambiguous instructions, the reply went. And it was good practice to break a task most of us assumed to be exceedingly simple into its component parts.&lt;/p&gt;

&lt;p&gt;At the time, I figured that meant I could ignore pseudo-coding if in my mind I already had a clear picture of what I wanted to build, and how.&lt;/p&gt;

&lt;p&gt;I was wrong.&lt;/p&gt;

&lt;p&gt;Also, hubris is a terrible, terrible drug.&lt;/p&gt;

&lt;p&gt;Here's what I'd learned about the importance of pseudo-coding in the three short months of building progressively more complicated apps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;It helps you understand what it is you're actually trying to accomplish. Before writing a single line of code, you should have the equivalent of a movie's tagline for your app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Breaking it down into its component parts is just the first step. The end goal should be to simplify, simplify, simplify. Can you bundle the logic for some steps into a single function? Can you further break down others, so you don't slip into the nesting hell of if statements conditional on other if statements conditional on other ifs? Can you arrange your logic in such a way that, should a step become redundant later on, it can be easily removed? Pseudo-coding is where you figure those things out. (Something, something, global variables suck.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clean code is fast code. It's also easier to maintain. If you don't focus on it in pseudo-coding, sooner or later you'll be refactoring your code instead (cleaning it up once it's written). Pseudo-code the heck out of that bad boy, and you'll be thanking yourself later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other people will thank you, too. Clean code is easier to read, and easier to build upon. Plus, keeping some of your pseudo-code as comments is a neat way of explaining your thought process to anyone who might want to use/improve your code (and to yourself later on, once you've forgotten why you decided to do something a certain way that now seems to make little sense--and that's okay, you've probably learned a lot since).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With good pseudo-code, you're 75% there to good documentation. Good documentation is king. It's how others decide how useful your app might be, and how to implement it for their needs. Get that right, and your stuff will be far more likely to get cloned. Which is how you become GitHub-popular. (Which is the best kind of popular, obviously. Now go write that darn README.)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>cleancode</category>
    </item>
  </channel>
</rss>
