<?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 Jesse Martin on Medium]]></title>
        <description><![CDATA[Stories by Jesse Martin on Medium]]></description>
        <link>https://medium.com/@motleydev?source=rss-41fd8c34bd4e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T5YndYNCSFYtBpAMZpETnA.jpeg</url>
            <title>Stories by Jesse Martin on Medium</title>
            <link>https://medium.com/@motleydev?source=rss-41fd8c34bd4e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 05:04:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@motleydev/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[How to improve search, get better answers, and do less work.]]></title>
            <link>https://medium.com/@motleydev/how-to-improve-search-get-better-answers-and-do-less-work-3bf6d940306f?source=rss-41fd8c34bd4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bf6d940306f</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[search]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Jesse Martin]]></dc:creator>
            <pubDate>Thu, 14 May 2020 08:04:04 GMT</pubDate>
            <atom:updated>2020-05-14T08:45:27.518Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6agnI0KgWDEKJVaIskd37Q.jpeg" /></figure><p>Note: This was written in 2016 but never released, recent updates to tab behavior in Google Chrome reminded me of this article so I decided to publish it anyways. Enjoy!</p><p>I’d like to propose something a little out there. Got 5 minutes? I want you to volunteer your time and your computer’s processor to help make the internet a better place. With your help we can have more meaningful search results which will lead to finding the answers you want, faster.</p><p>Search is a very basic problem. You begin with a stack of data and you need to find the piece of data that answers your original question. Looking for a needle in the proverbial haystack. No matter your search domain, the issue is a classic quantity and quality dilemma. The more options you have, the longer it takes to go through the files. The more random the various articles (let alone simply misleading or false) the longer it takes. That can be described as a noise problem. A smaller search domain doesn’t help either. Good luck finding the cause of a “runny nose” in pre WWII medical documents where the <em>lingua franca</em> was mostly German. Today, you can search for the most malformed query possible and get a reasonable answer in a short time-frame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*byxjK0LLvBCAeRqR." /><figcaption>“A view from above the white curved bookshelves.” by <a href="https://unsplash.com/@chuttersnap?utm_source=medium&amp;utm_medium=referral">chuttersnap</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The giant of Google is built on solving this problem. And they are really good at it. And it is really expensive. Hundreds of Thousands of servers across the world employ a software army, armed with algorithms, to visit myriads of websites, make notes, look for references and build a giant index to help us harness the immense stack of data we call the internet.</p><p>A few years ago, it was estimated that every day there were 140k new websites. That number only goes up.</p><p>The robot army is not a bad solution. Search companies look at websites, figure out ways to make sense of the data, and then structure the programs (algorithms) to process the page to various levels of comprehension. Then they move on.</p><p>What if the protein army could help? <em>I mean people, no one cares about your opinion, gym-bro.</em> What if we harnessed the power of the crowd and what we know about network effects to add something to the magic sauce?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ubFv0dUy6TJe515L." /><figcaption>Photo by <a href="https://unsplash.com/@ninjason?utm_source=medium&amp;utm_medium=referral">Jason Leung</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The web of data is connected on multiple levels. Most of that has to do with explicit links where article A points to article B. The more important your website seems, as in the more people pointing to your website or the more credible sources pointing to it (edu, gov, org domains) the greater the importance that is placed on your little node of the network. Simplified, if Harvard points to your tax advising business, you’re probably trustworthy. How do we know Harvard is trustworthy? Because the internet says it is.</p><p>There’s a lot more that goes into determining the importance of a website which is why we have a whole industry around the topic of search engine optimization. Google is notorious for not sharing the recipe. The holy grail is that accurate and open content floats to the top when you search for life’s more challenging questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6a-1GDcmrc17059VVBM4HQ.png" /></figure><p>The rise of artificial intelligence promises a solution to this “validity” question. It’s able to make sense of the article and ascribe meaning in context of the vast amount of data out there. It doesn’t need thousands of people saying the website is valid. It can figure that out for itself.</p><p>The problem is, if indexing the web was expensive. Running machine learning on every website is <strong>expensive</strong>. Like, you can’t even <a href="http://bigocheatsheet.com/">Big-O</a> estimate that because the technical limit of Artificial intelligence is just how much you want to restrain the graph of knowledge it’s using for a reference.</p><p>That’s where the protein army comes in.</p><p>On any given day, millions of people fire up their browsers tasked with some topic to which they are trying to find the answer. If they are like most people, they’ll enter their search request and then click on the first five or six links with one very significant change in behavior compared to searches of yore. They’ll open it in a tab. Then they’ll rephrase their question a couple of different ways, look for promising titles, and repeat the action until they have a browser with 10–20 tabs that SHOULD have the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ol4FAQ_1AwcQXQgOfGWkEw.jpeg" /><figcaption>Your browser. Right now.</figcaption></figure><p>Over time, they’ll end up with multiple browsers filled with tabs from various topics representing various interests and questions they have come across over the course of a few days or weeks. At the moment, this is <strong>a terrible practice — </strong>if not very common<strong>. This author is as guilty as anyone else, </strong>but what if it wasn’t a terrible idea?</p><p>So, here’s the crazy idea. What if your browser could read the articles for you? What if you gave your browser permission to look across the pages you were “tabbing” to find the relevant pieces between the documents? Together with the original query information and the power of the web, your browser can extrapolate a much deeper level of understanding into a single page document that prioritizes the information from the most repeated to the least. That’s the power of artificial intelligence. Suddenly, 20+ tabs of data can become a single page with the most relevant data in a single document for you to consume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nWP-tEmqbmpHsItQ4XCNw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3tA2liD601O16sF3SCGjA.jpeg" /></figure><p>From a product perspective, this data would allow you to tweak the results as needed and then this analysis would be sent back to the server to provide an all-together deeper understanding of the relationship between pages of data and the <strong>intent</strong> that brought those documents together. Think of it as micro-webs of data with search queries as the nucleus. No longer requiring a flat web of data to find the answer, but being able to build a type of knowledge organism composed of a cluster of these search atoms.</p><p>Now wasn’t this whole AI thing supposedly too expensive to run at scale? Yes, but when it’s run on private computers across the globe, that’s no longer the search company’s concern. The workload is offloaded to the client parsing the data. I can load up 30 tabs on Intermittent Fasting, hit “go”, and then go to bed while my processor plays scorched earth with my office desk. Or I can simply have a real-time tab update with new results as I add to my search domain and work async with my personal RA. When I’m done, I have the results outlined and ready to go and the search company has an intensely deeper understanding of those 30 pages, what kind of people would find those 30 pages most relevant, and which pages potentially are just copying everyone else.</p><p>That’s it. The elevator-got-stuck-pitch about harnessing the lost utility of willing participants in the data parsing game. There are a lot of execution details to be figured out including user expectation in regards to battery consumption, how to avoid bad actors uploading skewed results, as well as a rather intricate user, flow from a UX perspective. Maybe more on those details later. Leave your thoughts in the bottom or feed my ego and follow me on Twitter <a href="https://twitter.com/motleydev">@motleydev</a> — either way, thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bf6d940306f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphQL for Data Visualisation]]></title>
            <link>https://medium.com/open-graphql/i-recently-wrote-a-large-tutorial-for-my-company-graphcms-about-creating-a-project-from-start-to-2cae24c3b733?source=rss-41fd8c34bd4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cae24c3b733</guid>
            <category><![CDATA[content-marketing]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jesse Martin]]></dc:creator>
            <pubDate>Mon, 16 Jul 2018 20:05:00 GMT</pubDate>
            <atom:updated>2018-07-16T20:10:17.627Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7TEfDP9MV9jgqN7whk-D9w.png" /></figure><p>I recently wrote a large tutorial for my company, GraphCMS, about creating a project from start to finish. We cover everything from analysing data-types to pulling the data into the client. It’s well worth the read and is split into two parts:</p><p>The tutorial: 👉 <a href="https://graphcms.com/blog/wine-db/">Link</a><br>The visual: 👉 <a href="https://beta.observablehq.com/@motleydev/the-wine-folly-food-pairing-guide-as-interpreted-by-graphcm">Link</a></p><p>In the process, however, I uncovered some additional power-tips for data visualisations that really let GraphQL shine.</p><h3>GraphQL for Data-visualisation</h3><p>For a reference, here’s two of the charts that were created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KG6TU1eRY5Acw5keRiP4uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*6Q5VvKHiZ-O0PfcZMClfKQ.png" /><figcaption>An interactive chart that found the cross-section of wines shared between multiple food classes.</figcaption></figure><p>So, it wasn’t a design tutorial. But what it did reveal to me is that GraphQL is really well suited for flexible data formatting! The database itself is a series of connected nodes based on the Wine Folly food pairing chart. <a href="https://winefolly.com/review/simple-food-and-wine-pairing/">A cool resource worth checking out in its own right.</a></p><p>The library I chose to use was D3. More or less a given in modern day, data visualisation. But I came across a handful of cases where I really needed the data formatted differently than it had come from the server. There’s a host of solutions to this kind of problem. You can use a library such as Crossfilter which is tailor made for this kind of situation. In my case, because the data set was small and I wanted to perform fewer network requests, I just brute force reformatted the data in Javascript.</p><p>But if you have the luxury of, say, 2–3 API requests IN TOTAL (i.e. a perfectly acceptable tolerance IRL) then GraphQL can come to our rescue. According to the spec, we are able to make one very important assumption about the network response. The data will respond exactly as the request was made.</p><p>This means making a request like:</p><pre>// Request 1<br>{<br>  people {<br>    name<br>    age<br>    height<br>  }<br>}</pre><pre>// Request 2<br>{<br>  people {<br>    height<br>    age<br>    name<br>  }<br>}</pre><p>would return the same data but in the specific orders requested.</p><h3>The Basic Ideas</h3><p>In D3 the order of data is often important. Placing a series of lines across the page is a matter of looping over the data. If you want to nest content inside of those shapes, the most effective way is to have your data structures also nest in a similar matter.</p><p>The most common pattern being Loop over 3 items, make a group for each, enter each group and add data for the nested items.</p><p>To create the chart above, I did a basic search for all the Food Classes and their contained foods and their related wine pairings. It’s a simple query that looks like this:</p><pre>{<br>  foodClasses(orderBy: foodCategory_ASC) {<br>    name<br>    foodCategory<br>    foods {<br>      name<br>    }<br>    wineClassPairings(orderBy: slug_ASC) {<br>      name<br>      slug<br>      wines {<br>        name<br>        wineClass {<br>          name<br>        }<br>      }<br>    }<br>    wineClassWFPPs(orderBy: slug_ASC) {<br>      name<br>      slug<br>      wines {<br>        name<br>        wineClass {<br>          name<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>Don’t worry about the specifics of our syntax, the gist of what it does should be clear.</p><h3>A Crash Course in D3</h3><p>A key concept in D3 are the scale functions. I cover them in the visual part of my tutorial, but the basic idea is that if I tell my function to accept a range of [1..5] and to output a color value between Red and Blue, I would expect 2 to be very “reddish” and 4 to be some kind of purple.</p><p>Giving these functions the correct input data is important. The majority of my scales took a “discrete” input, meaning I would give it one of a concrete set of values (as opposed to any floating point between 1 and 5, for example.) This would allow me to give my function the top most Food Class in from my data response and get a value close to 0 for being near the top of my chart, and the last Food Class in my response would give me something near the bottom of my chart. In my case, my discrete array of values mapped to something like [0..1200].</p><h3>How GraphQL Helps</h3><p>But how do I get a reduced set of values of wine classes? My data response has many duplicates, and if this were a larger data set, it could be 10’s of thousands — not something I want to do on the client!</p><p>Well, in GraphQL. We can simply ask for this exact subset of data!</p><pre>{<br>  wineClasses {<br>    name<br>  }<br>}</pre><p>Another issue came up with the Food Category labels on the left. This took a little bit of D3 hackery, but the basic concept was to loop over each Food Category, get the subset of related Food Classes, and, as described above, use the Food Class scale function on the first subset Food Class and the last Food Class to get the positions of where my shape should start and stop. Cool! Sounds like a logical idea, doesn’t it! The only problem is, my data is not structured for that! Not even close!</p><p>This allows us to bring in a really powerful concept in GraphQL called Aliases.</p><h3>Aliases for the Win!</h3><p>Aliases allow us to map our response to a new key:value pair. It can be completely arbitrary and it gives us great flexibility. An example of this query would then look like this:</p><pre>query getFoodPairing() {<br>  Vegetables: foodClasses (<br>    where:{<br>     foodCategory: Vegetables<br>  }) {<br>    name<br>  }<br>  Dairy: foodClasses(<br>    where: {<br>      foodCategory: Dairy<br>    }) {<br>     name<br>  }<br>  Meat: foodClasses(<br>    where: {<br>      foodCategory: Meat<br>    }) {<br>     name<br>  }<br>  ...<br>}</pre><p>In fact, we could simply append a generic helper request on our original data request to get an alias of our formatted data like this:</p><pre>...<br>  wineClasses(orderBy:slug_ASC) {<br>    name<br>  }<br>  foodCategories: foodClasses {<br>    foodCategory<br>  }</pre><p>And so, by simply changing our request structure we are able to get the data, both the content and SHAPE as needed from the server.</p><p>As you can see, the flexibility in which we are able to request our data and change it’s shape depending on any arbitrary reason is a powerful paradigm for data exploration and the layout out of our designs. The syntax I used is part of the opinionated stack behind GraphCMS but writing your own resolvers and directives can create even more powerful abilities.</p><p>I hope you found this quick read interesting and I invite you to play with the data yourself! The API can be found at <a href="https://api-euwest.graphcms.com/v1/cjj75a4cx05hv01gg1zjttejo/master">https://api-euwest.graphcms.com/v1/cjj75a4cx05hv01gg1zjttejo/master</a></p><p><a href="https://graphcms.com/">Check out GraphCMS</a> if you want the best of both worlds! A powerful, API driven CMS with a completely open API for the developers and a thoughtful UI for content creators and those less comfortable in the terminal.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cae24c3b733" width="1" height="1" alt=""><hr><p><a href="https://medium.com/open-graphql/i-recently-wrote-a-large-tutorial-for-my-company-graphcms-about-creating-a-project-from-start-to-2cae24c3b733">GraphQL for Data Visualisation</a> was originally published in <a href="https://medium.com/open-graphql">Open GraphQL</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Start to Finish: A Wine Chart with GraphCMS]]></title>
            <link>https://medium.com/@motleydev/start-to-finish-a-wine-chart-with-graphcms-306c9b82d098?source=rss-41fd8c34bd4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/306c9b82d098</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jesse Martin]]></dc:creator>
            <pubDate>Mon, 16 Jul 2018 13:44:19 GMT</pubDate>
            <atom:updated>2018-07-16T19:25:09.374Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Visit the original post at </em><a href="https://graphcms.com/blog/wine-db/"><em>https://graphcms.com/blog/wine-db/</em></a><em> for better code readability/syntax-highlighting.</em></p><p>Content projects are complex. Getting the technical pieces in play is only half of the game. The other half is actually defining a content model that will successfully represent your idea without limiting you in the future. While GraphCMS makes many of the involved steps rather straight-forward, we’re going to do a complete project together from start to finish!</p><p><strong>What we will do</strong><br> At each step we will combine some manual (from the user interface) changes as well as programmatic changes, using the API directly.</p><ul><li>We will define our content model</li><li>Migrate our data</li><li>Display the content in an interactive way, looking at the various features of the the GraphQL language.</li></ul><p><strong>What you should know</strong><br> While I will attempt to write in a way that non-technical people can follow along, if you want to adapt any of the code to your own use cases you will need to know the basics of HTML, Ecmascript, Node, GraphQL - but don’t worry! We’ll explain the parts as we go along!</p><h3>What we will be creating</h3><p>As someone with a bit of a foodie flair, I’m a big fan of the folks at Wine Folly. Not just because they kill it on the content department, but because they are from my home state! So, without asking (they say it’s ok for personal use? 🤔) we will recreate this poster, digitally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mnHcfwbE-wC3xmpe.png" /></figure><h3>Creating the Project</h3><p>The first step is to create our project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qfYgarpLDiXS_7s2.gif" /></figure><p>Let’s look at our data! We have two types to choose from when defining our schema. A model represents complex data structures and an enumeration represents a defined list of singular values (think something akin to a select box).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X59o1fr8whbQb0G7.png" /></figure><p>Let’s unpack this.</p><h3>Identifying the types</h3><p><strong>1 “Vegetables”</strong><br> This seems to be a defined list. It is one of Meat, Preparation, Dairy, etc.</p><ul><li>Food Category =&gt; Enumeration</li></ul><p><strong>2 “Alliums”</strong><br> At first this would also seem to be a member of a defined list where there’s a singular property. However, this is a bit misleading. Take a look at 1 and 5? Our value assignment (pairing, perfect pairing) as well as vegetable belong to this entry! It&#39;s a model!</p><p>This is helpful for us for additional reasons. Imagine if we wanted to do a little more with our content later? Right now we only borrow the category name, but what if we wanted to include a flag for known allergens such as on Nightshades? Now we have a fourth value to include.</p><p>Why not make Vegetables a model as well? At some point you have to draw a line. Technically we could add additional data to Vegetables as well, however, a helpful mental model to structure our method with is reducing the amount of fields the higher up the classification goes. Vegetable is the top classification in our case, so we’ll limit it’s property set. Keeping this as an enum also has benefits later which we’ll see.</p><p><strong>3 “onion”, “shallot”, etc</strong><br> This is a member of Alliums, amd there can be many members, so it’s a Model. Models can only have a single entry from a selected Enumeration.</p><p><strong>4 &amp; 8 “Bold Red”</strong><br> I labeled this twice, but they are technically the same. Bold Red is the top classification in our wine analogy, and so we would normally give it an Enumeration. However, number 2 owns several instances of these classifications through the edges of pairing and perfect pairing. With an Enumeration you can have exactly one selection. Further, in my case, I want to track the pairings based on type, not by adding all wines of a type directly to the food pairing. That gives us more flexibility in the future. For example, adding a new white wine would only require choosing the correct Wine Class and it will be instantly connected throughout our graph.</p><p><strong>5, 6 &amp; 7</strong><br> This becomes a bit more complex. 5 is actually a reference to 4 - which is our Wine Class, such as Bold Red. The rating actually exists as a member of Food Class. Written out, Nuts &amp; Seeds has a collection of Wine Classes that are food pairings. It also has a collection of Wine Classes that are perfect pairings.</p><p><em>Side note, a perfect pairing is a subjective (and arguably universal in many cases) judgement about how well the drink pairs.</em></p><p>In this case, I am going to add 6 and 7 as two fields onto our 2 model as a relationship comprised of 5 – our Wine Class. In this case, 5 is a presentational artifact, something that appears as a default of the relationship between 2, 4, 6 and 7. These will be &quot;field definitions&quot; on our Food Class model.</p><p>Tongue-tied yet? Keep going, it will become clearer when we actually create the models!</p><p><strong>8 (See 4)</strong></p><p><strong>9 Malbec</strong><br> Since this belongs to a category and has at least one additional field (the label), it’s a Model.</p><h3>Identifying the fields</h3><p>From our above analysis, we are left with 1 Enumeration for the top level Food Category. Since they are simple lists of values, there&#39;s no fields to identify.</p><p>On our Models, however, the fields are everything. After we broke everything down, we were left with 4 Models. One for the Food entry, one for the Food Class, one for the Wine entry and one for the Wine Class.</p><p>Each of these need their own set of fields to help reconstruct our visual later and add the magical powers to our graph.</p><p><strong>Wine Model</strong></p><ul><li>Name =&gt; String</li><li>Category =&gt; Enumeration</li></ul><p><strong>Wine Classification</strong></p><ul><li>Name =&gt; String</li><li>Wine =&gt; Relation to Wine Model</li></ul><p><strong>Food Classification</strong></p><ul><li>Name =&gt; String</li><li>Food Category =&gt; Enumeration</li><li>Pairing =&gt; Relation to Wine Classification Model</li><li>WF Perfect Pairing =&gt; Relation to Wine Classification Model</li></ul><p><strong>Food</strong></p><ul><li>Name =&gt; String</li><li>Food Classification =&gt; Relationship to Food Classification Model</li></ul><p>And with that, our content analysis is complete! We can move on to defining the models and enumerations in our schema!</p><p><em>A Note about Display Names:</em> In the future, we’ll offer a field type that is simply a dropdown of strings which will allow better handling of display names. In my project I could also use all Models to be able to control my display names since Enumerations have very strict rules about their composition. For my purposes, I will format those to desired values on the client later on.</p><h3>Defining the schema</h3><p>We are going to edit our schema in two ways. Manually and with the API.</p><p>Here’s how we create an enum with the UI.</p><p><em>Note: In an earlier iteration of this post, I had the wine category as an Enum. This video is not actually part of the tutorial any more, but is helpful to show how how you could create an enum manually.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C_jV-_jkipUwYuDu.gif" /></figure><p>Totally easy! But if we have several models to define or lots of options to add to our enums, it’s by far easier to do this in code!</p><p><strong>Enter, the API Playground</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d0xxhA5-ecOTvz6r.png" /></figure><p>We need to get the stageId of our project, so we&#39;ll use this query to accomplish that.</p><p><em>Note that we are on the Management API. The Management API allows us to change all aspect of the project, where as the Project API let’s us change all aspects of the content.</em></p><p><em>Double Note: The management API is still being developed, it’s possible there will be some breaking changes. We will update this post accordingly, but if things aren’t working, check out the documentation.</em></p><pre>{<br>  viewer {<br>    projects {<br>      name<br>      stages {<br>        name<br>        id<br>      }<br>    }<br>  }<br>}</pre><p>Let’s create our last enum with the following query and variable input:</p><p><strong>Query</strong></p><pre>mutation createEnum($kinds: [String!]!) {<br>   createEnumeration(data: {<br>     stageId: &quot;YOUR_STAGE_ID_FROM_THE_FIRST_QUERY&quot;,<br>     apiId: &quot;FoodCategory&quot;,<br>     displayName: &quot;Food Categories&quot;<br>     values: $kinds<br>   }) {<br>     values<br>   }<br> }</pre><p><strong>Variables</strong></p><pre>{<br>  &quot;kinds&quot;: [<br>   &quot;Herbs_Spices&quot;,<br>   &quot;Dairy&quot;,<br>   &quot;Meat&quot;,<br>   &quot;Preparation&quot;,<br>   &quot;Starch&quot;,<br>   &quot;Sweet&quot;,<br>   &quot;Vegetables&quot;<br>  ]<br>}</pre><p>You can imagine the time savings this creates if you are provided with a large list of enum values that you otherwise have to copy and paste! Now it’s time to move on to creating some models. Of course, this is quite easy in the GUI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7d-SVT51NLYqUUBx.gif" /></figure><p>And, of course, it’s also quite easy from the API as well. First we need to create a model and get it’s ID on return.</p><pre>mutation {<br>  createModel(data: {<br>    stageId:&quot;YOUR_STAGE_ID&quot;,<br>    apiId: &quot;Wine&quot;,<br>    displayName: &quot;Wine&quot;<br>  }) {<br>    model {<br>      id<br>    }<br>  }<br>}</pre><p>Using the id from the previous query we can create the fields.</p><p><strong>Mutation</strong></p><pre>mutation addFields($modelID: ID!) {<br>  createStringField(data: {<br>    modelId: $modelID,<br>    apiId: &quot;name&quot;,<br>    displayName: &quot;Name&quot;,<br>    isRequired: true,<br>    isUnique: true,<br>    isList: false,<br>    formConfig: {<br>      renderer: &quot;GCMS_SINGLE_LINE&quot;<br>    },<br>    tableConfig: {<br>      renderer: &quot;GCMS_SINGLE_LINE&quot;<br>    }<br>  }) {<br>    field {<br>      displayName<br>    }<br>  }<br>#   This part is no-longer relevant but is interesting to see for sake of reference!<br>#   createEnumerationField(data: {<br>#     modelId: $modelID,<br>#     enumerationId: &quot;YOUR_ENUM_ID&quot;,<br>#     apiId: &quot;category&quot;,<br>#     displayName: &quot;Category&quot;,<br>#     isRequired: true,<br>#     isUnique: false,<br>#     isList: false,<br>#     formConfig: {<br>#       renderer: &quot;GCMS&quot;<br>#     },<br>#     tableConfig: {<br>#       renderer: &quot;GCMS&quot;<br>#     }<br>#   }) {<br>#     field {<br>#       displayName<br>#     }<br>#   }<br>}</pre><p><strong>Variables</strong></p><pre>{ &quot;modelID&quot;: &quot;YOUR_MODEL_ID_FROM_PREVIOUS_MUTATION&quot; }</pre><p>One of the selling points for GraphCMS is that we abstract way some of the pain of writing these queries when you don’t want to. In the case of adding fields, it’s not actually easier to use the API. We’ll only create one model with fields via the API.</p><p>This model, and most of the other models, will incorporate a Reference - before we explain that, see if you can get a new model to look like this!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/0*xyJlvkvZao0tncv3.png" /></figure><p>References are powerful in a graph database, they’re what drive the magic connections that allow for highly detailed queries. You can read more about them in our documentation <a href="https://docs.graphcms.com/user-guides/content-management-interface-cmi/relations">here</a>.</p><p>In our case, we are going to create a one to many relationship between our wine model and our wine classification model. The reason is that our wine classification can have many wines, but for our current content needs, a wine can have only one wine classification. Drag the reference field onto the wine model and arrange the settings like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/0*toxIlkMicNRWlsNW.png" /></figure><p>Moving on we can create our food model, which will also need a relationship. Start by creating a model that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/0*sEfVdyMKG_ZLd5wx.png" /></figure><p>And then add a relationship with these settings. Similar to wine, a food can have one Food Class but a Food Class can have many foods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/0*dTnuAsvI0rtzZSXG.png" /></figure><p>Now that we’ve gotten comfortable in our “Relationship” abilities. We’re going to revisit our Food Class model and customize some relationship properties on there.</p><p>Our pairings and our perfect pairings are both relationships to the Wine Class model. In one example, a sub-selection of wine classes are pairs, and in the other a sub-selection of wine classes are perfect pairs. In this case, we also don’t want the default API ID, we want to customize it to something we can reason about when looking at our data response from the server.</p><p>Add two more reference fields to the Wine Class model, and match these configurations.</p><p><strong>Pairings</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VAZ6ihEujVWhaNSN.png" /></figure><p><strong>Perfect Pairs</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4B17WpxZEMEr_Lv0.png" /></figure><p>Here we have two relationships that point to the same underlying model but are customized in naming to help us identify their purpose later on.</p><h3>Adding a second unique field to a model</h3><p><em>Warning: Deep API usage coming up</em></p><p>By the time you are reading this, it’s quite likely that adding extra unique fields to a model will be supported from the user interface. Until then, we will do this via the API Explorer. We will be adding a second field to track a difference between our display name and a second “slug” field. For example, if we wanted to create a navigable route in our action to Rosé, a type of wine, the slug will need to be stripped of any special characters to just Rose.</p><p>Here’s the mutation.</p><pre>mutation {<br>  createStringField(data: {<br>    modelId: &quot;YOUR_WINECLASS_MODEL_ID&quot;<br> isUnique: true<br>    isRequired: false<br>    isList: false<br>    apiId: &quot;slug&quot;<br>    displayName: &quot;Slug&quot;<br>    formConfig: {<br>      renderer: &quot;GCMS_SINGLE_LINE&quot;<br>    },<br>    tableConfig: {<br>      renderer: &quot;GCMS_SINGLE_LINE&quot;<br>    }<br>  }) {<br>    field {<br>      displayName<br>    }<br>  }<br>}</pre><p>and we’ll add a slug to our FoodClass model for the same reason.</p><pre>mutation {<br>  createStringField(data: {<br>    modelId: &quot;YOUR_FOODCLASS_MODEL_ID&quot;<br> isUnique: true<br>    isRequired: false<br>    isList: false<br>    apiId: &quot;slug&quot;<br>    displayName: &quot;Slug&quot;<br>    formConfig: {<br>      renderer: &quot;GCMS_SINGLE_LINE&quot;<br>    },<br>    tableConfig: {<br>      renderer: &quot;GCMS_SINGLE_LINE&quot;<br>    }<br>  }) {<br>    field {<br>      displayName<br>    }<br>  }<br>}</pre><p>And with that, our content models are completed! Now we can move on to migrating data!</p><h3>Importing the data</h3><p>The next step will be writing our import script. Here’s where some knowledge of Node.js will be helpful and/or required.</p><h3>Creating our script project</h3><p>Let’s create a new script project. Create a new directory on your computer, navigate inside from the terminal and run the following series of commands;</p><pre># Init a project<br>   $ npm inif -f<br># Add dependencies<br>  $ yarn add csvtojson isomorphic-fetch<br># Create our script file<br>  $ touch importWine.js importWineClass.js importFood.js importFoodClass.js<br># Make a directory called data<br>  $ mkdir data<br># Download our data sets<br># Wine<br>  $ curl <a href="https://gist.githubusercontent.com/motleydev/689ac7b59fdecf5f70579e700ffb9524/raw/65db79a2b50a42716e2123334337f0058cc1372c/wine.csv">https://gist.githubusercontent.com/motleydev/689ac7b59fdecf5f70579e700ffb9524/raw/65db79a2b50a42716e2123334337f0058cc1372c/wine.csv</a> &gt; ./data/wine.csv<br># Food<br>  $ curl <a href="https://gist.githubusercontent.com/motleydev/0d32837213431fd7889d1f029ca58897/raw/9799c0e68f46fb05280d79fbb004777e89d5ca9e/food.csv">https://gist.githubusercontent.com/motleydev/0d32837213431fd7889d1f029ca58897/raw/9799c0e68f46fb05280d79fbb004777e89d5ca9e/food.csv</a> &gt; ./data/food.csv<br># Food Classes<br>  $ curl <a href="https://gist.githubusercontent.com/motleydev/709d3f8e1ea0aef6af67f613dfb8b635/raw/d3127a05520c72a89d498491ff078042b0936d8c/foodClasses.csv">https://gist.githubusercontent.com/motleydev/709d3f8e1ea0aef6af67f613dfb8b635/raw/d3127a05520c72a89d498491ff078042b0936d8c/foodClasses.csv</a> &gt; ./data/foodClasses.csv</pre><h3>Creating a token for our API</h3><p>By default, our api is closed to the public. We’ll need to authenticate ourselves somehow. To do that, we can create a Permanent Auth Token (Yes, they can be deleted later!)</p><p>Here’s a quick animation on how to do that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jExclXGVa5dcmRKL.gif" /></figure><h3>Coding</h3><h3>Importing the Wine Classes</h3><p>Now let’s open up importWineClass.js in a code editor. It&#39;s always a good idea to create the dependent pieces of data before bringing in your primary content model. In our case, both our data models are rather simple, and so we&#39;re going to jump right into the deep-end and show you how to import BOTH at once, and connect them! Hold on!</p><p>Here’s the body of our script.</p><pre>const csv = require(&#39;csvtojson&#39;)<br>const fetch = require(&#39;isomorphic-fetch&#39;)</pre><pre>// Our endpoint, which we can get from the project dashboard<br>const endpoint = &quot;YOUR_API_ENDPOINT&quot;</pre><pre>// Typically you&#39;d never want to put a token here<br>// in plain text, but for our little script, it&#39;s ok.<br>const token = &quot;YOUR_TOKEN&quot;<br>// Our mutation to write data to our database<br>const mutation = `mutation CreateWineClass(<br>    $kind: String,<br>    $wines: [WineCreateWithoutWineClassInput!]<br>      ){<br>    createWineClass(data: {<br>      name: $kind<br>      slug: $kind<br>      wines: {<br>        create: $wines<br>      }<br>    }) {<br>          name<br>      id<br>    }<br>  }`;</pre><pre>// Our script to import the data<br>csv()<br>.fromFile(&#39;./data/wines.csv&#39;)<br>.then( wines =&gt; {</pre><pre>// Sets allow us to force unique entries,<br>    // so we have just a set of our wine classes<br>    // from our larger data set.<br>    const wineClasses = new Set()<br>    <br>    // Pushing our wine classes into our set.<br>    for (const wine of wines) {<br>        wineClasses.add(wine.kind)<br>    }<br>    <br>    // The [...wineClasses] allows us to<br>    // convert the set to an array, so we<br>    // can use map, so we can make async<br>    // asynchronous calls, so, yah…<br>    const promises = [...wineClasses].map(async wineClass =&gt; {<br>        try {<br>            const formattedWine = ({<br>                kind: wineClass, // The Class<br>                wines: wines.filter(<br>                    // Filter our wines by the current class<br>                    wine =&gt; wine.kind == wineClass<br>                ).map(<br>                    // Format our data in a way our API likes,<br>                    // see the video to explain<br>                    // how I figured that part out.<br>                    wine =&gt; ({name:<br>                            wine.value,<br>                            status: &#39;PUBLISHED&#39;})<br>                )})<br>            <br>            // The Fetch statement to send the data for each<br>            const resp = await fetch(endpoint, {<br>                headers: {<br>                    &#39;Content-Type&#39;: &#39;application/json&#39;,<br>                    &#39;Authorization&#39;: `Bearer ${token}`},<br>                method: &#39;POST&#39;,<br>                body: JSON.stringify({<br>                    query: mutation,<br>                    variables: formattedWine<br>                })<br>            })<br>            <br>            // Parse the response to verify success<br>            const body = await resp.json()<br>            const data = await body.data</pre><pre>console.log(&#39;Uploaded&#39;, data)<br>            return</pre><pre>} catch (error) {<br>            console.log(&quot;Error!&quot;, error)<br>        }<br>    })</pre><pre>Promise.all(promises).then(()=&gt; console.log(&quot;Done&quot;))<br>    <br>})</pre><p>The astute will notice that I’ve forgotten to add the PUBLISHED status to my wine class. Well, my mistake is your win, here&#39;s an example query in the API Explorer that demonstrates how easy bulk updates are.</p><pre>mutation {<br>  updateManyWineClasses(where: {<br>    status: DRAFT<br>  }, data: {<br>    status: PUBLISHED<br>  }) {<br>    count<br>  }<br>}</pre><p>The power of the API Explorer cannot be underestimated!</p><p>I want to explain the mutation statement from our create function above. There’s a lot going on here, so I’ve recorded a short video to explain the parts.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDrcMPcn3ZCc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDrcMPcn3ZCc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDrcMPcn3ZCc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a00a17f1ace805c3c9395496e83d0f59/href">https://medium.com/media/a00a17f1ace805c3c9395496e83d0f59/href</a></iframe><p>Go back to your content window and see if we have our data. Let’s do a test query in the API Explorer to make sur everything looks like we’d expect!</p><pre>{<br> wines {<br>  name<br>  wineClass {<br>    name<br>  }<br> } <br>}</pre><p>And here’s another query that will start to reveal some of the power behind the graph connections.</p><pre>{<br> wines(where: {<br>  wineClass: {<br>    name_in: [&quot;Bold_red&quot;, &quot;Medium_Red&quot;]<br>  }<br>}, orderBy: name_ASC) {<br>  name<br> } <br>}</pre><p>Good job! Now we will repeat the process to import our food classifications. Here’s what our foodClasses.csv data set looks like.</p><pre>classification, kind, pairing, wfpp<br>Meat, RED MEAT, Bold_Red;Medium_Red, Bold_Red<br>Meat, CURED MEAT, Bold_Red;Medium_Red;Light_Red;Rose;Sparkling;Sweet_White;Dessert, Light_Red;Sweet_White<br>Meat, PORK, Bold_Red;Medium_Red;Rose;Sparkling, Medium_Red<br>Meat, POULTRY, Medium_Red;Light_Red;Rose;Rich_White;Light_White;Sparkling, Light_Red;Rich_White<br>Meat, MOLLUSK, Light_White;Sparkling, Sparkling<br>...</pre><p>This would be quite typical for how we might get data from a third-party data source. I had the benefit of being able to hand craft the data, but tried to replicate standard csv export behavior.</p><p><em>Note: The author has done some additional work to ensure the integrity of the data, hopefully you won’t have any issues, but since this was a hand generated data-set, some fat-finger issues were bound to happen!</em></p><p>Back to the scripting! Let’s open up importFoodClass.js and paste in this script.</p><pre>const csv = require(&#39;csvtojson&#39;)<br>const fetch = require(&#39;isomorphic-fetch&#39;)</pre><pre>// Our endpoint, which we can get from the project dashboard<br>const endpoint = &quot;YOUR_API_ENDPOINT&quot;</pre><pre>// Typically you&#39;d never want to put a token here<br>// in plain text, but for our little script, it&#39;s ok.<br>const token = &quot;YOUR_TOKEN&quot;</pre><pre>// Our mutation to write data to our database<br>const mutation = `mutation CreateFoodClass(<br>    $kind: String!,<br>    $classification: FoodCategory!,<br>    $pairing: [WineClassWhereUniqueInput!],<br>    $wfpp: [WineClassWhereUniqueInput!],<br>  ){<br>    createFoodClass(data: {<br>      name: $kind,<br>      slug: $kind,<br>      status: PUBLISHED<br>      foodCategory: $classification,<br>      wineClassWFPPs: {<br>        connect: $wfpp<br>      },<br>      wineClassPairings: {<br>          connect: $pairing<br>      }<br>    }) {<br>      name<br>    }<br>  }`;</pre><pre>// Our script to import the data<br>csv()<br>.fromFile(&#39;./data/foodClasses.csv&#39;)<br>.then( foodClasses =&gt; {<br>    <br>    // Format our data and provide null value for missing data<br>    // in the API, a [Type!] can be null, but can&#39;t be an array<br>    // with null values. This would cause an import error.<br>    const createFormattedArray = arr =&gt;<br>        arr.length &gt;= 1<br>        ? arr.split(&#39;;&#39;)<br>        .map(item =&gt; ({slug: item}))<br>        : null<br>    <br>    const promises = foodClasses.map(async foodClass =&gt; {<br>        // Parse our &#39;item;item;item&#39; string into an array<br>        // with the proper shape for the API, which we find in<br>        // the api explorer.<br>        foodClass.pairing = createFormattedArray(foodClass.pairing)<br>        foodClass.wfpp = createFormattedArray(foodClass.wfpp)<br>        <br>        try {<br>            // The Fetch statement to send the data for each<br>            const resp = await fetch(endpoint, {<br>                headers: {<br>                    &#39;Content-Type&#39;: &#39;application/json&#39;,<br>                    &#39;Authorization&#39;: `Bearer ${token}`},<br>                method: &#39;POST&#39;,<br>                body: JSON.stringify({<br>                          query: mutation,<br>                         variables: foodClass})<br>            })<br>            <br>            // Parse the response to verify success<br>            const body = await resp.json()<br>            // I introduced an error catcher<br>            // which wasn&#39;t in the previous<br>            // import scripts. It&#39;s a good idea.<br>            // As a spec rule, error will always be &#39;errors&#39; which<br>            // is a one or more array of errors and some<br>            // diagnostic data.<br>            // I just wanted the error message.<br>            if (body.errors) {<br>                console.log(&quot;Error&quot;,<br>                   body.errors.map(error =&gt; error.message))<br>            }<br>            const data = await body.data</pre><pre>            console.log(&#39;Uploaded&#39;, data)<br>            <br>            return</pre><pre>} catch (error) {<br>            console.log(&quot;Error!&quot;, error)<br>        }<br>    })</pre><pre>Promise.all(promises).then(()=&gt; console.log(&quot;Done&quot;))<br>})</pre><p>Let’s test our imported data so far. We’re going to write a query that combines multiple values.</p><pre>{<br>  foodClasses {<br>    name<br>    wineClassWFPPs {<br>      name<br>      wines {<br>        name<br>      }<br>    }<br>    wineClassPairings {<br>      name<br>      wines {<br>        name<br>      }<br>    }<br>  }<br>}</pre><p>Hopefully you’re starting to get excited! Look at all that wine, I mean, data! Now for our <strong>last</strong> import! Food!</p><p>Open importFood.js and paste in this script:</p><pre>const csv = require(&#39;csvtojson&#39;)<br>const fetch = require(&#39;isomorphic-fetch&#39;)</pre><pre>// Our endpoint, which we can get from the project dashboard<br>const endpoint = &quot;YOUR_API_ENDPOINT&quot;</pre><pre>// Typically you&#39;d never want to put a token here<br>// in plain text, but for our little script, it&#39;s ok.<br>const token = &quot;YOUR_TOKEN&quot;<br>// Our mutation to write data to our database<br>const mutation = `mutation CreateFood(<br>    $value:String!,<br>    $kind:String!<br>  ) {<br>    createFood(<br>      data: {<br>        name: $value,<br>        status: PUBLISHED,<br>        foodClass: {<br>          connect: {<br>            slug: $kind<br>          }<br>        }<br>      }<br>    ){<br>      name<br>    }<br>  }`;</pre><pre>// Our script to import the data<br>csv()<br>.fromFile(&#39;./data/food.csv&#39;)<br>.then( foods =&gt; {<br>    <br>    const promises = foods.map(async food =&gt; {<br>        try {<br>            // The Fetch statement to send the data for each<br>            const resp = await fetch(endpoint, {<br>                headers: {<br>                    &#39;Content-Type&#39;: &#39;application/json&#39;,<br>                    &#39;Authorization&#39;: `Bearer ${token}`},<br>                method: &#39;POST&#39;,<br>                body: JSON.stringify({<br>                      query: mutation,<br>                      variables: food})<br>            })<br>            <br>            // Parse the response to verify success<br>            const body = await resp.json()<br>            // Catch Errors<br>            if (body.errors) {<br>                console.log(&quot;Error&quot;,<br>                   body.errors.map(error =&gt; error.message))<br>            }<br>            const data = await body.data</pre><pre>console.log(&#39;Uploaded&#39;, data)<br>            return</pre><pre>} catch (error) {<br>            console.log(&quot;Error!&quot;, error)<br>        }<br>    })</pre><pre>Promise.all(promises).then(()=&gt; console.log(&quot;Done&quot;)) <br>})</pre><p>And our content is imported! Let’s run one last query that will check if all our data is present and connected.</p><pre>{<br> wines {<br>  name<br>  wineClass {<br>    foodClassPairings {<br>      name<br>      foods{<br>        name<br>      }<br>    }<br>   }<br> } <br>}</pre><p>How cool is that?!</p><p>Now you can go through and clean up some of the imported data. You can either roll your own script like we’ve done above or you can use the interface. Here’s a gif showing some basic data editing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*slGzl5Khj1Kqc7DD.gif" /></figure><p>With the exception of the WineClass model, the display name is correct for the visualization we will be creating. And with only 9 entries, we’ll just clean those up quickly by hand.</p><h3>Adding the design</h3><p>Let’s look at the chart again. What’s the best way to ask for this data in a meaningful and structured way? It appears that our Y Axis will be comprised of Food Classes and our X Axis will be comprised of Wine Classes. Where the two meet we have a variable for either No Pairing, Pairing or Perfect Pairing.</p><p>So, for each Food Class I want the Wine Class pairings and the nested food. I want to group the Food Classes by Food Category. Here’s how that Looks:</p><pre>{<br>  foodClasses(orderBy: foodCategory_ASC) {<br>    name<br>    foodCategory<br>    foods {<br>      name<br>    }<br>    wineClassPairings(orderBy: slug_ASC) {<br>      name<br>      slug<br>      wines {<br>        name<br>        wineClass {<br>          name<br>        }<br>      }<br>    }<br>    wineClassWFPPs(orderBy: slug_ASC) {<br>      name<br>      slug<br>      wines {<br>        name<br>        wineClass {<br>          name<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>Because this is an inforgraphic, we are going to use the defacto D3 library. It’s relatively straight forward and quite powerful. I’ll be providing all code if you don’t know D3, but the project itself will be heavily documented if you’d like to learn more about what’s going on!</p><p>We will be using the awesome online service <a href="https://beta.observablehq.com/">Observable HQ</a> for our visualization. It allows us to put together code and text in a meaningful way without having to set up our own servers. Think of it as a code playground.</p><p>One thing to note right away is that the infographic was not programmatically generated. The data PRESENTATION is not structured according to any kind of easily derived logic. Wine Classes are sorted according to taste and Food Categories seem to be sorted more or less at random. The Food Classes themselves don’t follow any logic except for perhaps the more common items are at the top of the list. To start with, we will use simple logic, so our order of the data will be misaligned with the provided image, but structurally it should look quite similar.</p><p>I’ve also manipulated the data provided through various transforms when I needed to. This allows us to work with a single data query. The reality is, if you are ok making a handful of extra queries, GraphQL is perfectly suited for data visualizations!</p><p>With D3, we have access to scale functions that allow us to map data to defined outputs. As an example, I&#39;ve mapped the discrete input of our Food Classes (Red Meat, Cured Meat, etc) to the numeric range of 0 through ~1200. That means that if I pass a value of Alliums into the scale function, I&#39;d get a heigh readout roughly half way down the infographic! That&#39;s really cool!</p><p>The problem arises with our Food Category, such as Meat. We need a way to tell the rectangle to start at a given height and end at a given height, but our data isn&#39;t formatted for that! What we need is a new shape of our data, an array of objects that are bucketed by Food Category (so we can iterate over our roughly 7 Categories) but with access to their &quot;contained&quot; Food Classes so we can use our scale function to fetch the first and last item in the respective grouping and their respective positions. Confused yet?</p><p>Here’s how our master query from above provided the data:</p><pre>&quot;foodClasses&quot;: [<br>  {<br>  &quot;name&quot;: &quot;HARD CHEESE&quot;,<br>  &quot;foodCategory&quot;: &quot;Dairy&quot;,<br>  &quot;foods&quot;: [Object, Object, Object, Object, Object],<br>  &quot;wineClassPairings&quot;: [Object, Object, Object, Object, Object],<br>  &quot;wineClassWFPPs&quot;: [Object],<br>},<br>{<br>  &quot;name&quot;: &quot;PUNGENT CHEESE&quot;,<br>  &quot;foodCategory&quot;: &quot;Dairy&quot;,<br>  &quot;foods&quot;: [Object, Object, Object, Object],<br>  &quot;wineClassPairings&quot;: [Object, Object, Object, Object, Object, Object, Object],<br>  &quot;wineClassWFPPs&quot;: [Object, Object],<br>}<br>... ]</pre><p>But for the labels I need data shaped more like this:</p><pre>{<br> &quot;Dairy&quot;: [<br>  {<br>   &quot;name&quot;: &quot;HARD CHEESE&quot;<br>  }<br>  {<br>   &quot;name&quot;: &quot;PUNGENT CHEESE&quot;<br>  }<br>  ... ]}</pre><p>I used this function to format the data how I need:</p><pre>foodCategoryBuckets = () =&gt; {<br>// foodCategoryReduce is an already<br>// reduced array of Food Category Strings<br>  const data = foodCategoryReduce.reduce(<br>    (result, item, index) =&gt; {<br>      result[item] = [];<br>      return result<br>    }, {})<br>  <br>  // wineIsServed.foodClasses is the fetched master data<br>  for (let key of Object.keys(data)) {<br>    data[key] = wineIsServed<br>          .foodClasses<br>          .filter(d =&gt; d.foodCategory === key)<br>  }<br>  <br>  return data<br>}</pre><p>I could have also just written another GraphQL query like this:</p><pre>query getFoodPairing() {<br>  Vegetables: foodClasses (<br>    where:{<br>     foodCategory: Vegetables<br>  }) {<br>    name<br>  }<br>  Dairy: foodClasses(<br>    where: {<br>      foodCategory: Dairy<br>    }) {<br>     name<br>  }<br>  Meat: foodClasses(<br>    where: {<br>      foodCategory: Meat<br>    }) {<br>     name<br>  }<br>  ...<br>}</pre><p>This uses a feature called “Aliases” which allow us to map the data to new keys on the response. The flexibility of GraphQL really shines here! Because the size of our data is relatively small, it was a better cost-benefit to simply modify my data on the client. For more complex data munging, I recommend looking at libraries like <a href="https://github.com/crossfilter/crossfilter">Crossfilter</a> which are tailor made for these kinds of issues.</p><h3>Open the API Gates!</h3><p>The last thing we need to do is open up our API for public consumption. To do this, we need to enable the API for public read.</p><p><em>NOTE: You have limits on the number of READS for your project! If you turn this on, and share it with a bunch of friends, it’s possible you’ll run into rate limitation issues! For a small test, it’s likely not a problem, but this is not a good production pattern!”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/0*kCN3eXaRULcqmREB.gif" /></figure><p>And with that, we can move on to the project! The remainder of this tutorial can be found at Observable HQ.</p><p>For reference, this is the core of what we’ll be creating, plus some extras and few interactive charts as well!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TXfvFEWBeESHIFjP.png" /></figure><p><a href="https://beta.observablehq.com/@motleydev/the-wine-folly-food-pairing-guide-as-interpreted-by-graphcm">You can find the whole project here.</a></p><p>See you over at Observable HQ!</p><p><em>Originally published at </em><a href="https://graphcms.com/blog/wine-db/"><em>graphcms.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=306c9b82d098" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphCMS, ready for ]]></title>
            <link>https://medium.com/@motleydev/graphcms-ready-for-dd4417da5a9e?source=rss-41fd8c34bd4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd4417da5a9e</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[content-management]]></category>
            <category><![CDATA[headless-cms]]></category>
            <category><![CDATA[content-strategy]]></category>
            <dc:creator><![CDATA[Jesse Martin]]></dc:creator>
            <pubDate>Tue, 03 Jul 2018 07:08:32 GMT</pubDate>
            <atom:updated>2020-08-07T10:24:57.508Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1S69XXqwtEl3xoa4rg8Fug.png" /></figure><p>I am incredibly excited to announce that the revamped GraphCMS experience has left beta! With a fresh new set of features and performance enhancements, the next era of what a content management system can be, has begun.</p><p>It’s hard to imagine that the little CMS we launched just over a year ago has become the beloved headless CMS that it is today with indie developers and major enterprises jumping on the platform. Developers caught on to the promise of GraphQL nearly the moment it first hit the inter-webs as a humble spec. Businesses have been turning to the promise of headless CMSs over the course of the last decade. But now that we’ve combined the two, there’s simply no going back!</p><h3>A recap on some of the benefits of the Headless + GraphQL Paradigm</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W67ioE4N9QNJzseNJ-zJqA.png" /><figcaption>The Headless &lt;-&gt; GraphQL Paradigm</figcaption></figure><h4>The benefits of headless</h4><ul><li><strong>Any platform. Anywhere.<br></strong> No matter if you have a single website or multiple websites, apps and services — they can all be powered by a single-source-of-content-truth. Write once, deliver everywhere.</li><li><strong>Frontend freedom.<br></strong> You can choose whatever technology stack you want! If you like ruby, swift, python, PHP, java or javascript — we ❤️ your stack!</li><li><strong>Happy Developers!<br></strong> No, really! The cost of turn-over and on-boarding new developers and recruiting is expensive. Use the developers you’ve got, let them write code how they like to write code and at the same time, your writers, managers and stake-holders get their GUI-ey CMS!</li></ul><h4>The benefits of GraphQL</h4><ul><li><strong>An End to Endless Endpoints.<br></strong> Traditional REST API’s have massive lists of endpoints, both new and legacy, to support the many different content needs of a business. GraphQL has <strong>one</strong>, and it delivers all the content you ask for.</li><li><strong>Descriptive not Prescriptive API.<br></strong> The API is <strong>generated</strong> from your content structure. If you know your content, you know the API.</li><li><strong>Built-in Documentation.<br></strong> Because of the introspection query, you can explore the generated API in a tool like GraphiQL which is an incredible DX performance boost.</li><li><strong>Happy Developers.<br></strong> Once again, the increase in time to focus on coding and not on managing endpoints creates happy developers. Happy developers bring value.</li></ul><blockquote><em>GraphCMS brings 10x value to businesses and enterprises by creating the most developer friendly API on the planet.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*UR87-g4Nv0X7-mpm2sdafg.png" /><figcaption>A Happy Developer</figcaption></figure><p>At GraphCMS we’ve focused on adding “just-enough opinion.” Through our decades of experience in building custom CMSs or consulting companies on choosing the right CMS, we’ve learned a few things about what makes a good content manager. As developers, we’ve learned a few things about what get’s in the way. We leveraged this combined experience to create a tool that has enough helpful patterns to make a very powerful editor and interface for writers and editors while maintaining maximum flexibility for the dev-ops team.</p><blockquote><em>It’s so flexible, we should have called it Yogi CMS.</em></blockquote><h3>Features and the Future</h3><p>The revamped CMS is as beautiful on the inside as it is on the outside. A brand new user interface throughout the application has created a beautiful and quick experience for our users that is both intuitive and familiar. But the redesign is truly just the tip of the iceberg for us. The team has devoted countless hours to giving the internals a complete overhaul which has led to a drastically faster application, reduction in technical debt from the old architecture, and an ability to release features at a ⚡️ rate.</p><p>Check out the list of features ready to go! The remaining features are in the final phases of development and testing, so keep an eye on our twitter and blog!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*rGYOl6k4HVlln1lsLowWmA.png" /></figure><p><strong>🎉 Features launching today:</strong></p><ul><li>Completely new UI</li><li>Improved and unified GraphQL APIs</li><li>Staging for your schemas!</li><li>All new “global” web-hooks</li><li>Extended security features</li></ul><p><strong>🗓 Features launching within the next three months:</strong></p><ul><li>Revision history</li><li>Custom workflows</li><li>Custom roles and permissions</li><li>Powerful content views</li><li>Geo-Location</li></ul><p>Additionally, we are expanding a set of tools and services to help migrate your old content into the new platform.</p><p>Just imagine what your company content management system <strong>could</strong> be like? <a href="https://www.graphcms.com/">Check it out today!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd4417da5a9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with the Pushup Challenge]]></title>
            <link>https://medium.com/@motleydev/getting-started-with-the-pushup-challenge-89b53abcd4b5?source=rss-41fd8c34bd4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/89b53abcd4b5</guid>
            <category><![CDATA[push-ups]]></category>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Jesse Martin]]></dc:creator>
            <pubDate>Mon, 01 Jan 2018 13:03:59 GMT</pubDate>
            <atom:updated>2018-01-01T13:30:28.456Z</atom:updated>
            <content:encoded><![CDATA[<p>This article won’t make much sense without some history. Fortunately, you can read that <a href="https://medium.com/@motleydev/how-i-did-over-18-000-burpees-this-year-4cf1d2bbf5fe">here</a>.</p><p>This will be a simple step-by-step to get you down and logging some pushups. Congrats for taking on the challenge!</p><h3>Step 1</h3><p>You’ll need an Airtable account. In the future there will be an official app with fancy design and all that, but for now, you are joining the MVP-Ultra-BETA version of the challenge. You could do the same thing in excel. But don’t, do it in Airtable — it’s way more fun! <a href="https://airtable.com/invite/r/XnlFj7rs">Sign up for an account here.</a></p><h3>Step 2</h3><p>Clone a copy of the master “base.” It has a table for logging pushups and a table for defining what your target number is. There is also a table that acts as a reference for pushup variations, it’s not exhaustive and is <a href="https://greatist.com/fitness/bodyweight-push-up-variations">stolen directly from the Greatist</a>. Feel free to add some more, but as a word of caution, this list will be carried into the “real” app, so as your data is migrated in the future, only references to this list will be respected for the stats. <a href="https://airtable.com/universe/explitwm5QwJPJD2Q/pushup-app-template">Clone the base here.</a></p><h3>Step 3 (for mobile users)</h3><p>Download the Airtable App. <a href="https://play.google.com/store/apps/details?id=com.formagrid.airtable&amp;hl=en">Android</a> and <a href="https://itunes.apple.com/us/app/airtable/id914172636?mt=8">iOS</a>.</p><h3>Step 4</h3><p>Start doing pushups!</p><p>Here’s some screenshots for helpful reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*eebiAe8RTPTyS6E5fY0Zzw.png" /><figcaption>Choose the entries table and then click on the orange button to add a new record.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*6Ti-pRSaxOJt-8Gd17UfAA.png" /><figcaption>Fill out the data, be sure to scroll all the way to the end. Latitude and Longitude will be collected at a later time when I get the wrapper app created. You can also take a photo of your “turf” or whatever else you would like to attach to the entry.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*BtXWtKOJc7y-O9KYUe64Cw.png" /><figcaption>Close this box, it just gets in the way. Then click “+ Link to a record in the pushup_styles table”.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*ObMgIKxqNDLC8GvT1dkxew.png" /><figcaption>Search the list for the style you did. All the common ones should be present.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*ActdCUzpsHoZFo51qanwRA.png" /><figcaption>That’s it!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*7uM60dq-dDn1wowge7tApw.png" /><figcaption>You can view a list of the pushups at the pushup_types table.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*8JFPRKyKGvY2ggeVyjYoRA.png" /><figcaption>They are all linked to an example for reference.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*TSo9eW6lgw6Y6e0wfE-MGQ.png" /><figcaption>Lastly, and very important, set your pushup goal!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*5JBEt3vRESajIcWzq10dbQ.png" /><figcaption>That’s it!</figcaption></figure><p>Comment below or reach out to @motleydev on Twitter if you have any questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89b53abcd4b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I did over 18,000 burpees this year.]]></title>
            <link>https://medium.com/@motleydev/how-i-did-over-18-000-burpees-this-year-4cf1d2bbf5fe?source=rss-41fd8c34bd4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cf1d2bbf5fe</guid>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[fitness]]></category>
            <category><![CDATA[sit-ups]]></category>
            <category><![CDATA[burpees]]></category>
            <category><![CDATA[push-ups]]></category>
            <dc:creator><![CDATA[Jesse Martin]]></dc:creator>
            <pubDate>Sat, 30 Dec 2017 11:33:23 GMT</pubDate>
            <atom:updated>2017-12-30T11:33:23.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RXJjt0c8QCLQ2wzbpG3sEg.jpeg" /><figcaption>By John Schmidt @johnsch <a href="https://unsplash.com/photos/FQGW34aZb1I">https://unsplash.com/photos/FQGW34aZb1I</a></figcaption></figure><p>At the time of writing, I have crossed over 18,000 <a href="https://media.giphy.com/media/Po6x3sFsBZgYg/giphy.gif">burpees</a>, pushups, sit-ups and squats for the year (yes, 72,000 unique movements). I’ll save you the math, that is 50 of each, per day, for the whole year. Some quick backstory. Last year I set about doing a personal challenge, it was a simple creative exercise, but was my first foray into the yearly-challenge category. I was hooked. Looking back after completing a whole year of something is a rewarding feeling.</p><blockquote>While the challenge was simple, it did take time, every day.</blockquote><p>Another habit that takes significant time is planning, pursuing and maintaining a healthy lifestyle. For some of us, that’s a more involved battle than for others. In the interest of life optimisation, I decided to make my yearly challenge for 2017 be a fitness challenge.</p><p>If I was going to spend the time doing both, making the two goals align was an easy win on the time category.</p><p>This challenge has been brutal and time intensive. Assuming I complete the next few days, finishing this challenge will be extremely rewarding.</p><p>With two years behind me now, I want to take some time to outline some lessons I’ve learned and to announce my challenge for next year and an extend an invitation to join me.</p><h3>For a fitness challenge, set a weekly goal. Injury, sickness and the unforeseen will simply get in the way.</h3><p>I don’t think I made it three weeks into January before I had a significant muscle strain. Getting sidelined that early made me embrace the fact that I wasn’t going to be able to do them “every day” — just so long as I get them all done by the end of the week. Doing 300 burpees in a day sucks — let alone adding the other exercises.</p><h3>Create some variety, make special combinations and sets that allow you to get it done.</h3><p>I created multiple patterns for working through backlogs. I have custom timers for 50’s, 100’s, 200’s and more all depending on what kind of mood I was in. I would do 3x17 on some days (and just eat the extra burpee, pushup, etc. Or I would do 3x20 (and just take a pass on half of the last set.) For creating custom timers, <a href="http://www.runloop.com/seconds-pro">this is the best one you can get.</a></p><h3>Counting by 5’s and thinking in 3’s makes nearly any challenge easier.</h3><p>Here’s how I would break down a back log of 100 burpees, pushups, etc.</p><p>Group the exercises into 5 sets of 20, count three rounds out before you allow yourself to “feel tired” and you’re suddenly over half way and the last round is always easy.</p><h3>Burpees never get easier. Never. I’m in 18,000 for the year and they still suck. But I suck less at doing them.</h3><p>Enough said.</p><h3>It’s not really about health.</h3><p>Marathons aren’t healthy. Mountain climbing isn’t healthy. Over training is a real thing. At some point the body starts to switch into a survival mode and you stop seeing the gains like you used to. In all honesty, this program was too much. I’m not going to do it again. But it wasn’t about being healthy, it was about doing what I said I was going to do and finishing. Abs just don’t like daily exercise. There are fare more intentional programs for growth and performance.</p><h3>Pick a challenge you can do anywhere and everywhere.</h3><p>When you are about 6’3 (193cm) and right around 200lb (90kg), you can’t do burpees <em>subtly</em>. I’m fortunate enough to work with some extremely chill people at the office, but sometimes you have to read the room. Even tucked away in the printer room, the floors tend to <em>shake</em>.</p><h3>Collect the data.</h3><p>This was one point where I failed with this year. Tracking all the different exercises with reminders and periphery just didn’t happen. I didn’t have a plan going into the year and tried rolling various versions as I went along. The problem is that I was trying to track data on 4 different axis and nothing was really optimal for that. It was too much work with too little reward to track.</p><h3>Find a support system for accountability.</h3><p>Tell your friends, family, coworkers or the internet. It helps. Shame is a powerful motivator.</p><h3>Know what your reward will be.</h3><p>I’m slightly off. I know that. I like doing something hard because I know it’s hard. I’m running away from a weak default nature. Everything is a battle to be better. I don’t do temptation bundling or other tricks like that, though if that’s your thing, you do you.</p><p>My reward is the data and the ability to play with it later. Yes, I ruined my reward this year but I DO have a near 24/7 Fitbit data that I get to look at, including heart rate data. It’s enough. That I kept religiously. If you’re looking for a good tracker, I recommend the <a href="https://www.fitbit.com/charge2">Charge 2</a>.</p><h3>Next.</h3><p>All things holding constant and no injuries getting in the way, I will finish the year with 18,250 of each exercise. I’ve not gone more than 3 days in a row without some muscle or joint hurting. But I will have completed the challenge. That’s what this is really about. Finding the strength and discipline to complete a challenge for an entire year.</p><p>With that being said, I am announcing the fitness challenge for this year will be <strong>1,000 pushups per week.</strong> To address what I’ve learned, a weekly challenge gives opportunity to split up the exercises and provides days for healing or compensation for missed days. Pushups are also among <a href="https://greatist.com/fitness/bodyweight-push-up-variations">the most versatile exercise possible.</a> There are hundreds of variations and techniques, working out nearly the whole body. My rough plan is to do 200 per day for 5 days a week. With a little training, the body can quickly get to doing 50 pushups in a row. That leaves four sets throughout the day. Easy™. Pushups <strong>do</strong> get easier, and have progressively difficult variations — from a strength building perspective, they are nearly perfect. The program is still not entirely about health, but this program should at least keep me from sabotaging gains with over training — another win with having the option for rest days.</p><p>Here’s the best part, you can do pushups ANYWHERE. No excuses, no bothering the co-workers and you can do quite a few before breaking a sweat. We’ve come full circle to me being 6’3 and 200lb.</p><p>That leaves “collect the data.” There are a number of methods for tracking single axis goals like this. All requiring some sort of hodgepodge of tools and hacks to get the data just right. Having learned the ideal set of features and the ideal set of data to gather from this year’s challenge, I’ve decided to build my own tool to collect the data.</p><p>So, now I’ll have an optimised fitness challenge and a custom app to track it. That’s when I decided to take it to the next level and invite others to join me! The problem is, I hit on this idea rather late in the year. I had a crisis of identity and pivoted away from my other plan for the coming year. However it did result in more alignment of time, intention and personal branding — more on that at a later date. When the app launches, it will have opportunity to join for various intervals of length. Some as short as a week, all the way up to a year. I’m launching an ultra minified version of the app for tracking the data. It’s a small wrapper around the excellent <a href="https://airtable.com/invite/r/XnlFj7rs">Airtable product (referral link)</a>. The great thing about Airtable, is that even before launching the application, you can use their default data entry view to accomplish 90% of the same data collection (just no geo data). Eventually the database will pivot to something more traditional and the there will be a host of features to make it more fun. But with Airtable, it lets you get started at the start right away. For those interested in joining at the start of the year and are interested in joining me for the ride, <a href="https://airtable.com/shrvEwmNIbGXw4yvm">here’s a link to sign up for the beta.</a></p><p>There will be a follow-up platform to announce in the coming year that’s related to the challenge, but more on that later.</p><p>That’s it. That’s my <em>yay, I think I’m going to make it</em> and my next level of accountability for the challenge before me. If this sounds like your kind of jam, then I invite you to join me for a challenging but rewarding 2018!</p><p><a href="https://twitter.com/motleydev">Follow me on Twitter if that’s your thing.</a></p><p>Cheers and let’s finish the year strong!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cf1d2bbf5fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>