{
    "componentChunkName": "component---src-templates-blog-post-js",
    "path": "/graphql-concepts-explained-query/",
    "result": {"data":{"markdownRemark":{"html":"<div class=\"table-of-contents\">\n<ul>\n<li><a href=\"#syntax\">Syntax</a></li>\n<li><a href=\"#selection-set\">Selection set</a></li>\n<li><a href=\"#query-arguments\">Query Arguments</a></li>\n<li><a href=\"#parts-of-a-query\">Parts of a query</a></li>\n<li><a href=\"#fragments\">Fragments</a></li>\n</ul>\n</div>\n<p>There are three types of GraphQL operations: <strong>query</strong>, <strong>mutation</strong> &#x26; <strong>subscription</strong>.</p>\n<p>A query describes the data you want to fetch from a GraphQL server. It is written using the GraphQL query language and is sent to the server as a string inside a JSON object.</p>\n<h3 id=\"syntax\" style=\"position:relative;\"><a href=\"#syntax\" aria-label=\"syntax permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Syntax</h3>\n<ul>\n<li>We can write a query using a shorthand syntax where we omit the keyword query (<em>operation type</em>) and the name of the query (<em>operation name</em>).</li>\n</ul>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">{</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">  user {</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">   firstName</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">   age</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">  }</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">}</span></span></span></code></pre>\n<ul>\n<li>We can also write a query by using the keyword <del>query</del> but omitting the name of the query.</li>\n</ul>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">query {</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">  user {</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">    firstName</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">    age</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">  }</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">}</span></span></span></code></pre>\n<ul>\n<li>However, it’s always a good practice to write a query using both the keyword <del>query</del> and the name of the query. That way, we can easily identify a query - especially useful for debugging our code. Below, <del>fetchUsers</del> is the name of our query.</li>\n</ul>\n<pre class=\"grvsc-container synthwave-84\" data-language=\"sh\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">query fetchUsers {</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">   user {</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">     firstName</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">     age</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">   }</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-source\"><span class=\"mtk1\">}</span></span></span></code></pre>\n<h3 id=\"selection-set\" style=\"position:relative;\"><a href=\"#selection-set\" aria-label=\"selection set permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Selection set</h3>\n<p>When we write a query, we select the fields we need by encapsulating them in curly braces. These blocks are referred to as <del>selection sets</del>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 601px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/6b81c71c4b6e0ee89a4092a160cbe003/f6e13/selectionSet.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAC4jAAAuIwF4pT92AAABxElEQVQ4y4WT63LaMBSEef/X6q/MJG0ZCimkCQHbDVdzsWxZ0jm7HQlME5JJNPPNkW35eFde9VS1xmmIqgoIAfklaS3wjp6qWgBUVSpBrR39eE0/XtFP1gyzHcO0ZMj2Cf97RdnUBHl654oeABsnUSJJwAYgOwD5ASiOwMIg3K8Q8j2kOCA8bCDbOi6GqiZej4tC5z1qY+iCZ+Utj23Do7OsbE37uI4fTKo6ziLekRrGFbvpC+5v+ny4HXB212fRH/H59ief7oYsRxkRzrZEPrT63zJh1QXyYHFYzjm4+cZ8MuBm+cJqMUt69OioTt4oTJ67epnjvIdeKWUFuop/Hp84HI44zwuu82eqesreUtvYtKa2hmorqo/3aqprqMGdqkjXUIidgau2zLKc+7JkGvWOaraUxZKynFKyH5T5mb8jSvGLspxQFmOG2XeqePYUsHF/7GoHs82I9sioVJo9xWyiYeqx/cIyLvXSsClKSO2oxlFMm2qi8ZS1YXShXV4//SlAkyJgA9S4E/WZ7tr6N1nrstfl8DUxNi6dFL7N2QlQoAwqFDnR5e+zHG6gWqtqparmGtc6Yxtr2tYlRMQASM9iveYf0oj1KfH/zcUAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"GraphQL selection set\"\n        title=\"GraphQL selection set\"\n        src=\"/static/6b81c71c4b6e0ee89a4092a160cbe003/f6e13/selectionSet.png\"\n        srcset=\"/static/6b81c71c4b6e0ee89a4092a160cbe003/56d15/selectionSet.png 200w,\n/static/6b81c71c4b6e0ee89a4092a160cbe003/d9f49/selectionSet.png 400w,\n/static/6b81c71c4b6e0ee89a4092a160cbe003/f6e13/selectionSet.png 601w\"\n        sizes=\"(max-width: 601px) 100vw, 601px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>When a query gets executed successfully, the response becomes available as a JSON object as the value of the <del>data</del> key. The response has exactly the same shape as the query. The shape of the response data is exactly shaped after the structure of fields being requested in the query.</p>\n<h3 id=\"query-arguments\" style=\"position:relative;\"><a href=\"#query-arguments\" aria-label=\"query arguments permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Query Arguments</h3>\n<pre class=\"grvsc-container grvsc-has-line-highlighting synthwave-84\" data-language=\"sh\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"1\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">query fetchUsers {</span></span></span>\n<span class=\"grvsc-line grvsc-line-highlighted\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"2\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">   user (id: “30”) {</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"3\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">     firstName</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"4\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">     age</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"5\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">   }</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"6\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">}</span></span></span></code></pre>\n<p>We can filter the results of a GraphQL query by passing arguments to fields. An argument is a set of key-value pairs attached to a specific field. Arguments can appear on any field, even on fields nested deep inside an operation. Above, we want to fetch a user with an <del>id</del> of 30.</p>\n<h3 id=\"parts-of-a-query\" style=\"position:relative;\"><a href=\"#parts-of-a-query\" aria-label=\"parts of a query permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Parts of a query</h3>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 601px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/c6d8208e3e5dc19e58e7735f2d9d6ac4/f6e13/queryAnatomy.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAC4jAAAuIwF4pT92AAAB2UlEQVQ4y21Sa3MSQRDM//83lh+iVUFjTCJGMAEJHknxlMDlAmeRW24fNzNt7XKHB7pVXbOPmd7u3Tlh5q3sBjHzHodrOdivzuqxwgkzaxEBM8NHCACRMP+L6kxAzAH1Gh8rBEI/gUB0YaUR9+Q2HUtrPZIP8b3oIpd5znL2bKWdFvItLaSROHl1HG5jZqmPGqGIIYe38zbeLzp4t7jDVfLg5WKsCG8WFqexxafE4cVQUFupqrupW5a9DWZocphtV8icgWXBr5yxtgLLAPHuGZhLohppSRg2pCJjYXTnj/ja+47zYYSLn0PcRGPcRCNc9B4wXW3gBxMfqNy/YaWQ/S0+EUBWODxOhrhuXqN/eYvBlw7uzpqYDeYwIav8vxIV6f4Ng0IqQOsp6GUMvCag1RSj9iW6jVPcfz7HU6cFiTegfgLXXaKIErgfMYpJuic9JGQCrWegZRSIi9UE/eZHLActgC2YLBgCSnPQ0waUZKDnDPQ7/79lKS17EACVZTDbDOwMWLCDv/zI7rHlvPyh0FO+8f1CqUycc2Wbh44rERIDuIaq3hPaetcfdz4R/YP6+XGtJ1yJyJaZMy+MmZUxRmljlLVWGWOV1nq3p7XS2pRzo4hIVTU+evwB1iHv9lesAXAAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Anatomy of a GraphQL query\"\n        title=\"Anatomy of a GraphQL query\"\n        src=\"/static/c6d8208e3e5dc19e58e7735f2d9d6ac4/f6e13/queryAnatomy.png\"\n        srcset=\"/static/c6d8208e3e5dc19e58e7735f2d9d6ac4/56d15/queryAnatomy.png 200w,\n/static/c6d8208e3e5dc19e58e7735f2d9d6ac4/d9f49/queryAnatomy.png 400w,\n/static/c6d8208e3e5dc19e58e7735f2d9d6ac4/f6e13/queryAnatomy.png 601w\"\n        sizes=\"(max-width: 601px) 100vw, 601px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>A field is a unit of data you ask for. The field ends up as a field in the response data we receive from the server.</p>\n<h3 id=\"fragments\" style=\"position:relative;\"><a href=\"#fragments\" aria-label=\"fragments permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Fragments</h3>\n<p>Fragments are selection sets that can be used in multiple operations.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 601px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/7136d07e111d7d4fcf77de946f88a3b1/f6e13/fragment.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAC4jAAAuIwF4pT92AAABsElEQVQ4y4VT22rbQBDN//9GXvoW8l4ofQgECo5xrVZRLnZi3SrJSizrsqudmVNWlmTZGDJwmNnZ0dm56YqZKxERZiYLEaHB/gpDrNUDrpi5ERGwCDrNDAG+xhDb6wFHQmbpICztWy7610ZaNxG9iETPQ2n//hN1/y56Fkj7mHaxfWUylY6wf8k+fJCGgEIDtQE0A7kCwj2QNwe/9eGY4RRjhkQkcRwjTRJ8FJ/YhRnyVYTAWyNwXxH9XsHbFnhJtlj6MbJKXyQ9KTmKIjx5HpbOEg8/7zH7fofXuYuN8wzfWcMNtnD8BLMXH2mlumJM37uhl2PJltAG1HWNxWKBKI6QpSmMMZhKfnLsRzQZ0JihMUYsmVIKQRDg2FLBpyasS4O0IbiFwWpv4NeEpCF4hcGu5ZH0pIeWbBB7aYg6wj87g+s3hR9Ji9tQ49tG4ybQeCwM5h8GmaJTwmHK5ztlYQnfK4KzMwjrQ4bP+8OZ+vvzkuvpHg67Ndpd7ZdhY+jsO0uop1t//gcQEVpjOtiMppjGTdcmE5GKmfciUlowcynCna20LpumKZXSvV9GfQn/Ac9+9DfXearGAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"GraphQL fragment\"\n        title=\"GraphQL fragment\"\n        src=\"/static/7136d07e111d7d4fcf77de946f88a3b1/f6e13/fragment.png\"\n        srcset=\"/static/7136d07e111d7d4fcf77de946f88a3b1/56d15/fragment.png 200w,\n/static/7136d07e111d7d4fcf77de946f88a3b1/d9f49/fragment.png 400w,\n/static/7136d07e111d7d4fcf77de946f88a3b1/f6e13/fragment.png 601w\"\n        sizes=\"(max-width: 601px) 100vw, 601px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>We define fragments by using the <del>fragment</del> keyword followed by the name of the fragment. Fragments are selection sets on specific types. Therefore, in the definition, we must also specify the type associated with the fragment.</p>\n<pre class=\"grvsc-container grvsc-has-line-highlighting synthwave-84\" data-language=\"sh\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"1\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">query fetchUsers {</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"2\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">    user (id: </span><span class=\"mtk16\">&quot;40&quot;</span><span class=\"mtk1\">) {</span></span></span>\n<span class=\"grvsc-line grvsc-line-highlighted\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"3\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">        ...userDetails</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"4\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">    }</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"5\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">}</span></span></span>\n<span class=\"grvsc-line\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"6\"></span><span class=\"grvsc-source\"></span></span>\n<span class=\"grvsc-line grvsc-line-highlighted\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"7\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">fragment userDetails on User {</span></span></span>\n<span class=\"grvsc-line grvsc-line-highlighted\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"8\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">    firstName</span></span></span>\n<span class=\"grvsc-line grvsc-line-highlighted\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"9\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">    age</span></span></span>\n<span class=\"grvsc-line grvsc-line-highlighted\"><span class=\"grvsc-gutter-pad\"></span><span class=\"grvsc-gutter grvsc-line-number\" aria-hidden=\"true\" data-content=\"10\"></span><span class=\"grvsc-source\"><span class=\"mtk1\">}</span></span></span></code></pre>\n<p>Above, the fragment is a selection set on the User type.</p>\n<p>We can add a fragment in another selection set by using three dots(<del>...</del>) followed by the name of the fragment (<em>line 3</em>). The three dots instruct GraphQL to assign the fields from the fragment to the current selection set.</p>\n<p>The syntax is similar to the JavaScript spread operator.</p>\n<hr>\n<p><strong>Want to learn how to build an Express/GraphQL server?</strong></p>\n<p>Check out my 8-part blog series <a href=\"https://hemanta.io/how-to-build-an-express-graphql-server-part-one/\">here</a>.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    position: relative;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n    line-height: 1.4;\n  }\n  \n  .grvsc-code {\n    display: table;\n  }\n  \n  .grvsc-line {\n    display: table-row;\n    box-sizing: border-box;\n    width: 100%;\n    position: relative;\n  }\n  \n  .grvsc-line > * {\n    position: relative;\n  }\n  \n  .grvsc-gutter-pad {\n    display: table-cell;\n    padding-left: 0.75rem;\n    padding-left: calc(var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem)) / 2);\n  }\n  \n  .grvsc-gutter {\n    display: table-cell;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    user-select: none;\n  }\n  \n  .grvsc-gutter::before {\n    content: attr(data-content);\n  }\n  \n  .grvsc-source {\n    display: table-cell;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-source:empty::after {\n    content: ' ';\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    user-select: none;\n  }\n  \n  .grvsc-gutter + .grvsc-source {\n    padding-left: 0.75rem;\n    padding-left: calc(var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem)) / 2);\n  }\n  \n  /* Line transformer styles */\n  \n  .grvsc-has-line-highlighting > .grvsc-code > .grvsc-line::before {\n    content: ' ';\n    position: absolute;\n    width: 100%;\n  }\n  \n  .grvsc-line-diff-add::before {\n    background-color: var(--grvsc-line-diff-add-background-color, rgba(0, 255, 60, 0.2));\n  }\n  \n  .grvsc-line-diff-del::before {\n    background-color: var(--grvsc-line-diff-del-background-color, rgba(255, 0, 20, 0.2));\n  }\n  \n  .grvsc-line-number {\n    padding: 0 2px;\n    text-align: right;\n    opacity: 0.7;\n  }\n  \n  .synthwave-84 { background-color: #262335; }\n  .synthwave-84 .mtk1 { color: #FFFFFF; }\n  .synthwave-84 .mtk16 { color: #FF8B39; }\n  .synthwave-84 .grvsc-line-highlighted::before {\n    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));\n  }\n</style>","frontmatter":{"title":"GraphQL Concepts Explained - Query","date":"2021-06-12"}}},"pageContext":{"slug":"/graphql-concepts-explained-query/","prev":{"fields":{"slug":"/using-css-selectors-combinators/"},"frontmatter":{"modules":null}},"next":{"fields":{"slug":"/how-to-create-a-hamburger-menu-using-gsap-and-react/"},"frontmatter":{"modules":null}}}},
    "staticQueryHashes": ["3159585216"]}