CINXE.COM

GraphQL

<!DOCTYPE html> <!-- Built with spec-md --> <html><head><meta charset="utf-8"><title>GraphQL</title><style>body { color: #333333; font: 13pt/18pt Cambria, "Palatino Linotype", Palatino, "Liberation Serif", serif; margin: 6rem auto 3rem; max-width: 780px; } /* Links */ a { color: #3B5998; text-decoration: none; } a:hover { text-decoration: underline; } /* Section headers */ h1, h2, h3, h4, h5, h6, h7, h8 { margin: 3rem 0 1em; position: relative; } h1 { font-size: 1.5em; margin: 8rem 0 2em; } h2 { font-size: 1.45em; margin: 8rem 0 1em; } h3 { font-size: 1.30em; margin: 5rem 0 1em; } h4 { font-size: 1.20em; } h5 { font-size: 1.12em; } h6, h7, h8 { font-size: 1.1em; } section .spec-secid { margin-right: 1ex; position: absolute; right: 100%; text-align: right; white-space: nowrap; } footer { font-size: 75%; opacity: 0.5; text-align: center; margin-top: 12rem; } /* Table of contents */ .spec-toc { margin: 1rem 0 3rem; } .spec-toc .title { content: 'Contents'; display: block; font-weight: bold; margin: 3rem 0 1rem; } .spec-toc .spec-secid { margin-right: 1ex; } .spec-toc ol { list-style: none; padding-left: 0; } .spec-toc ol ol { list-style: none; padding-left: 2ex; } .spec-toc li { position: relative; padding: 5px 0 0 30px; margin: -5px 0 0 -30px; } .spec-toc a { color: #333333; } .spec-toc a:hover { text-decoration: none; } .spec-toc a .spec-secid { color: #3B5998; } .spec-toc a:hover .spec-secid { text-decoration: underline; } .spec-toc .toggle { display: none; } .spec-toc .toggle + label { cursor: pointer; left: 10px; opacity: 1; padding: 3px 5px 3px 6px; position: absolute; top: 8px; transform: rotate(0deg); transition: all 0.18s ease-in-out; } .spec-toc .toggle + label:after { border-color: transparent transparent transparent #bbc; border-style: solid; border-width: 6px 0 6px 7px; content: ' '; display: block; height: 0; width: 0; } .spec-toc .toggle:checked + label { transform: rotate(90deg); } .spec-toc li:not(:hover) > .toggle:checked + label { opacity: 0; } .spec-toc .toggle:not(:checked) ~ ol { max-height: 0; overflow: hidden; } /* Sidebar */ .spec-sidebar-toggle { display: none; } .spec-sidebar-toggle + label { position: fixed; right: 0; top: 0; padding: 10px 15px; font-size: 30px; color: rgba(0,0,0,0.7); z-index: 2; cursor: pointer; user-select: none; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; } .spec-sidebar { display: none; position: fixed; right: 0; top: 0; width: 320px; font-size: 80%; overflow-y: scroll; height: 100%; padding: 0 0 5rem 30px; box-sizing: border-box; background: #f0f0f0; } .spec-sidebar-toggle:checked ~ .spec-sidebar { display: block; box-shadow: -1px 0 rgba(0,0,0,0.12), -4px 0 8px -2px rgba(0,0,0,0.05); } .spec-sidebar .viewing > a:after { color: #8b9; content: '\2022'; margin-left: 1ex; } @media (min-width: 1240px) { .spec-sidebar-toggle + label { display: none; } .spec-sidebar { display: block; box-shadow: inset 1px 0 rgba(0,0,0,0.05), inset 4px 0 8px -2px rgba(0,0,0,0.08) !important; } body { padding-right: 300px; } } /* Notes */ .spec-note { background: #FEFEF3; border-left: solid 4px #F4E925; margin: 1em -1em; min-width: 416px; padding: 1ex 1em 1ex calc(1em - 4px); width: -moz-fit-content; width: -webkit-fit-content; width: fit-content; } .spec-note::before { color: #6C6613; content: 'Note'; display: block; font: italic 11pt/18pt Cambria, "Palatino Linotype", Palatino, "Liberation Serif", serif; opacity: 0.6; user-select: none; } /* Todos */ .spec-todo { color: #666666; margin: 1em 0 1em 5em; min-height: 1em; } .spec-todo::before { content: 'todo'; display: block; float: left; margin-left: -5em; text-transform: uppercase; } /* Index table */ .spec-index ol { list-style-type: none; margin: 0 0 0 2rem; padding: 0; column-width: 210px; column-gap: 2rem; } .spec-index ol li { width: min-content; } /* Code */ code { background: #FAFAFA; font-family: Consolas, Monaco, monospace; font-size: 85%; font-weight: inherit; margin: -2px -1px; padding: 3px 3px; white-space: pre; } pre code { background: none; font-weight: inherit; margin: 0; padding: 0; } pre { background: #FAFAFA; border-left: solid 4px #E9E9E9; margin: 1em -1em; min-width: 40ch; padding: 1ex 1em 1ex calc(1em - 4px); width: -moz-fit-content; width: -webkit-fit-content; width: fit-content; } .spec-example { background: #FAFAFF; border-left: solid 4px #BBBBFF; } .spec-counter-example { background: #FFFAFA; border-left: solid 4px #FFBBBB; } .spec-example > a, .spec-counter-example > a { display: block; font: italic 11pt/18pt Cambria, "Palatino Linotype", Palatino, "Liberation Serif", serif; opacity: 0.6; user-select: none; } .spec-counter-example > a { color: #98593b; } /* Tables */ table { border-collapse: collapse; } th { background-color: #F9F9F9; } td, th { border: 1px solid #D0D0D0; padding: 0.4em; vertical-align: baseline; } /* Edits */ ins { background-color: rgba(0, 200, 30, 0.08); text-decoration: none; } del { background-color: rgba(200, 0, 0, 0.08); } .spec-added, .spec-removed { border-left: 4px solid; margin-left: -18px; padding-left: 14px; } .spec-added { border-color: #396; } .spec-removed { border-color: #933; text-decoration: line-through; } /* Values */ .spec-keyword { font-weight: bold; } .spec-string { font-family: Consolas, Monaco, monospace; white-space: pre; } var { font-style: italic; } *[data-name] { transition: 0.15s background ease-out; border-radius: 2px; padding: 0 3px; margin: 0 -3px; } /* Grammar semantics, algorithms and calls */ .spec-semantic, .spec-algo { margin: 1rem 0 1rem 2rem; } .spec-semantic > .spec-rhs { display: inline-block; margin-left: 1ex; } .spec-semantic > .spec-nt::after, .spec-algo > .spec-call:first-child::after { content: ':'; font-style: normal; font-weight: bold; margin-left: 1ex; } .spec-semantic ol, .spec-semantic ol ol ol ol, .spec-algo ol, .spec-algo ol ol ol ol { list-style-type: decimal; } .spec-semantic ol ol, .spec-semantic ol ol ol ol ol, .spec-algo ol ol, .spec-algo ol ol ol ol ol { list-style-type: lower-alpha; } .spec-semantic ol ol ol, .spec-semantic ol ol ol ol ol ol, .spec-algo ol ol ol, .spec-algo ol ol ol ol ol ol { list-style-type: lower-roman; } .spec-call > a { color: inherit; } /* Grammar productions */ .spec-production { margin: 1rem 0 1rem 2rem; } .spec-production > .spec-nt::after { content: ':'; font-style: normal; font-weight: bold; margin: 0 1ex; } .spec-semantic.d2 > .spec-nt::after, .spec-production.d2 > .spec-nt::after { content: '::'; } .spec-semantic.d3 > .spec-nt::after, .spec-production.d3 > .spec-nt::after { content: ':::'; } .spec-rhs { margin-left: 2rem; } .spec-oneof { display: inline; } .spec-oneof::before { content: 'one of'; font-style: normal; font-weight: bold; } .spec-oneof > table { margin-left: 2rem; } .spec-oneof .spec-rhs { border: none; margin: 0; padding: 0 0.5em; vertical-align: baseline; } .spec-rhs .spec-constrained:not(:first-child), .spec-rhs .spec-quantified:not(:first-child), .spec-rhs .spec-nt:not(:first-child), .spec-rhs .spec-t:not(:first-child), .spec-rhs .spec-rx:not(:first-child), .spec-rhs .spec-prose:not(:first-child), .spec-rhs .spec-empty:not(:first-child), .spec-rhs .spec-lookahead:not(:first-child) { margin-left: 1ex; } .spec-condition { font-size: 85%; } .spec-condition::before { content: '[+' } .spec-condition.not::before { content: '[~' } .spec-condition::after { content: ']' } .spec-empty, .spec-prose { color: #666666; } .spec-nt { font-style: italic; } .spec-nt > a { color: inherit; } .spec-quantifiers, .spec-params { font-size: 65%; font-style: normal; vertical-align: sub; } .spec-quantifier.list { color: #3348D3; } .spec-quantifier.optional { color: #83238E; } .spec-params, .spec-condition { color: #1C7758; } .spec-params::before { content: '['; } .spec-params::after { content: ']'; } .spec-quantifier:not(:last-child)::after, .spec-param:not(:last-child)::after { color: #666666; content: ', '; } .spec-param.conditional::before { content: '?'; } .spec-t, .spec-rx { color: #333333; font-family: monospace; font-weight: bold; } .spec-butnot::before { color: #666666; content: 'but not'; font-family: Cambria, "Palatino Linotype", Palatino, "Liberation Serif", serif; font-weight: normal; margin-right: 1ex; } .spec-butnot > *:not(:first-child)::before { color: #666666; content: 'or'; font-family: Cambria, "Palatino Linotype", Palatino, "Liberation Serif", serif; font-weight: normal; margin-right: 1ex; } .spec-rhs .spec-oneof::before, .spec-rhs .spec-butnot::before { margin-left: 1ex; } .spec-lookahead > * { margin: 0 !important; } .spec-lookahead > *:not(:first-child)::before { color: #666666; content: ', '; font-family: Cambria, "Palatino Linotype", Palatino, "Liberation Serif", serif; font-style: normal; font-weight: normal; } .spec-lookahead::before { color: #666666; content: '[lookahead = '; font-family: Cambria, "Palatino Linotype", Palatino, "Liberation Serif", serif; font-style: normal; font-weight: normal; } .spec-lookahead.not::before { content: '[lookahead \2260 '; } .spec-lookahead.set::before { content: '[lookahead \2208 {'; margin-right: 0; } .spec-lookahead.set.not::before { content: '[lookahead \2209 {'; } .spec-lookahead::after { color: #666666; content: ']'; } .spec-lookahead.set::after { content: '}]'; } </style><style>/* Copied from node_modules/prismjs/themes/prism.css */ /** * prism.js default theme for JavaScript, CSS and HTML * Based on dabblet (http://dabblet.com) * @author Lea Verou */ code[class*="language-"], pre[class*="language-"] { color: black; background: none; text-shadow: 0 1px white; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; word-wrap: normal; line-height: 1.5; -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4; -webkit-hyphens: none; -moz-hyphens: none; -ms-hyphens: none; hyphens: none; } pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { text-shadow: none; background: #b3d4fc; } pre[class*="language-"]::selection, pre[class*="language-"] ::selection, code[class*="language-"]::selection, code[class*="language-"] ::selection { text-shadow: none; background: #b3d4fc; } @media print { code[class*="language-"], pre[class*="language-"] { text-shadow: none; } } /* Code blocks */ pre[class*="language-"] { padding: 1em; margin: .5em 0; overflow: auto; } :not(pre) > code[class*="language-"], pre[class*="language-"] { background: #f5f2f0; } /* Inline code */ :not(pre) > code[class*="language-"] { padding: .1em; border-radius: .3em; white-space: normal; } .token.comment, .token.prolog, .token.doctype, .token.cdata { color: slategray; } .token.punctuation { color: #999; } .namespace { opacity: .7; } .token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #905; } .token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #690; } .token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: #a67f59; background: hsla(0, 0%, 100%, .5); } .token.atrule, .token.attr-value, .token.keyword { color: #07a; } .token.function { color: #DD4A68; } .token.regex, .token.important, .token.variable { color: #e90; } .token.important, .token.bold { font-weight: bold; } .token.italic { font-style: italic; } .token.entity { cursor: help; } </style><script>(function (){ var styleSheet = document.getElementsByTagName('style')[0].sheet; var ruleIndex; function removeHighlight() { if (ruleIndex) { styleSheet.deleteRule(ruleIndex); ruleIndex = void 0; } } function highlightKeyword(name) { removeHighlight(); ruleIndex = styleSheet.insertRule( '*[data-name="' + name + '"] { background: #FBF8D0; }', styleSheet.cssRules.length ); } document.documentElement.addEventListener('mouseover', function (event) { var nameAttribute = event.target.attributes['data-name']; if (nameAttribute) { highlightKeyword(nameAttribute.value); } }); document.documentElement.addEventListener('mouseout', removeHighlight); })()</script></head><body><header><h1>GraphQL</h1><section id="intro"><p><em>June 2018 Edition</em></p><p><strong>Introduction</strong></p><p>This is the specification for GraphQL, a query language and execution engine originally created at Facebook in 2012 for describing the capabilities and requirements of data models for client&#8208;server applications. The development of this open standard started in 2015.</p><p>GraphQL has evolved and may continue to evolve in future editions of this specification. Previous editions of the GraphQL specification can be found at permalinks that match their <a href="https://github.com/facebook/graphql/releases">release tag</a>. The latest working draft release can be found at <a href="http://facebook.github.io/graphql/draft/">facebook.github.io/graphql/draft/</a>.</p><p><strong>Copyright notice</strong></p><p>Copyright © 2015&#8208;present, Facebook, Inc.</p><p>As of September 26, 2017, the following persons or entities have made this Specification available under the Open Web Foundation Final Specification Agreement (OWFa 1.0), which is available at <a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0">openwebfoundation.org</a>.</p><ul><li>Facebook, Inc.</li></ul><p>You can review the signed copies of the Open Web Foundation Final Specification Agreement Version 1.0 for this specification at <a href="https://github.com/facebook/graphql/tree/master/signed-agreements">github.com/facebook/graphql</a>, which may also include additional parties to those listed above.</p><p>Your use of this Specification may be subject to other third party rights. THIS SPECIFICATION IS PROVIDED &ldquo;AS IS.&rdquo; The contributors expressly disclaim any warranties (express, implied, or otherwise), including implied warranties of merchantability, non&#8208;infringement, fitness for a particular purpose, or title, related to the Specification. The entire risk as to implementing or otherwise using the Specification is assumed by the Specification implementer and user. IN NO EVENT WILL ANY PARTY BE LIABLE TO ANY OTHER PARTY FOR LOST PROFITS OR ANY FORM OF INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER FROM ANY CAUSES OF ACTION OF ANY KIND WITH RESPECT TO THIS SPECIFICATION OR ITS GOVERNING AGREEMENT, WHETHER BASED ON BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE, AND WHETHER OR NOT THE OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p><p><strong>Conformance</strong></p><p>A conforming implementation of GraphQL must fulfill all normative requirements. Conformance requirements are described in this document via both descriptive assertions and key words with clearly defined meanings.</p><p>The key words &ldquo;MUST&rdquo;, &ldquo;MUST NOT&rdquo;, &ldquo;REQUIRED&rdquo;, &ldquo;SHALL&rdquo;, &ldquo;SHALL NOT&rdquo;, &ldquo;SHOULD&rdquo;, &ldquo;SHOULD NOT&rdquo;, &ldquo;RECOMMENDED&rdquo;, &ldquo;MAY&rdquo;, and &ldquo;OPTIONAL&rdquo; in the normative portions of this document are to be interpreted as described in <a href="https://tools.ietf.org/html/rfc2119">IETF RFC 2119</a>. These key words may appear in lowercase and still retain their meaning unless explicitly declared as non&#8208;normative.</p><p>A conforming implementation of GraphQL may provide additional functionality, but must not where explicitly disallowed or would otherwise result in non&#8208;conformance.</p><p><strong>Conforming Algorithms</strong></p><p>Algorithm steps phrased in imperative grammar (e.g. &ldquo;Return the result of calling resolver&rdquo;) are to be interpreted with the same level of requirement as the algorithm it is contained within. Any algorithm referenced within an algorithm step (e.g. &ldquo;Let completedResult be the result of calling CompleteValue()&rdquo;) is to be interpreted as having at least the same level of requirement as the algorithm containing that step.</p><p>Conformance requirements expressed as algorithms can be fulfilled by an implementation of this specification in any way as long as the perceived result is equivalent. Algorithms described in this document are written to be easy to understand. Implementers are encouraged to include equivalent but optimized implementations.</p><p>See <a href="#sec-Appendix-Notation-Conventions">Appendix A</a> for more details about the definition of algorithms and other notational conventions used in this document.</p><p><strong>Non&#8208;Normative Portions</strong></p><p>All contents of this document are normative except portions explicitly declared as non&#8208;normative.</p><p>Examples in this document are non&#8208;normative, and are presented to aid understanding of introduced concepts and the behavior of normative portions of the specification. Examples are either introduced explicitly in prose (e.g. &ldquo;for example&rdquo;) or are set apart in example or counter&#8208;example blocks, like this:</p><pre id="example-fed99" class="spec-example"><a href="#example-fed99">Example № 1</a><code>This is an example of a non-normative example. </code></pre><pre id="example-881bd" class="spec-counter-example"><a href="#example-881bd">Counter Example № 2</a><code>This is an example of a non-normative counter-example. </code></pre><p>Notes in this document are non&#8208;normative, and are presented to clarify intent, draw attention to potential edge&#8208;cases and pit&#8208;falls, and answer common questions that arise during implementation. Notes are either introduced explicitly in prose (e.g. &ldquo;Note: &ldquo;) or are set apart in a note block, like this:</p><div class="spec-note">This is an example of a non&#8208;normative note.</div></section><nav class="spec-toc"><div class="title">Contents</div><ol><li><a href="#sec-Overview"><span class="spec-secid">1</span>Overview</a></li><li><a href="#sec-Language"><span class="spec-secid">2</span>Language</a><input hidden class="toggle" type="checkbox" checked id="_toggle_2" /><label for="_toggle_2"></label><ol><li><a href="#sec-Source-Text"><span class="spec-secid">2.1</span>Source Text</a><input hidden class="toggle" type="checkbox" checked id="_toggle_2.1" /><label for="_toggle_2.1"></label><ol><li><a href="#sec-Unicode"><span class="spec-secid">2.1.1</span>Unicode</a></li><li><a href="#sec-White-Space"><span class="spec-secid">2.1.2</span>White Space</a></li><li><a href="#sec-Line-Terminators"><span class="spec-secid">2.1.3</span>Line Terminators</a></li><li><a href="#sec-Comments"><span class="spec-secid">2.1.4</span>Comments</a></li><li><a href="#sec-Insignificant-Commas"><span class="spec-secid">2.1.5</span>Insignificant Commas</a></li><li><a href="#sec-Source-Text.Lexical-Tokens"><span class="spec-secid">2.1.6</span>Lexical Tokens</a></li><li><a href="#sec-Source-Text.Ignored-Tokens"><span class="spec-secid">2.1.7</span>Ignored Tokens</a></li><li><a href="#sec-Punctuators"><span class="spec-secid">2.1.8</span>Punctuators</a></li><li><a href="#sec-Names"><span class="spec-secid">2.1.9</span>Names</a></li></ol></li><li><a href="#sec-Language.Document"><span class="spec-secid">2.2</span>Document</a></li><li><a href="#sec-Language.Operations"><span class="spec-secid">2.3</span>Operations</a></li><li><a href="#sec-Selection-Sets"><span class="spec-secid">2.4</span>Selection Sets</a></li><li><a href="#sec-Language.Fields"><span class="spec-secid">2.5</span>Fields</a></li><li><a href="#sec-Language.Arguments"><span class="spec-secid">2.6</span>Arguments</a></li><li><a href="#sec-Field-Alias"><span class="spec-secid">2.7</span>Field Alias</a></li><li><a href="#sec-Language.Fragments"><span class="spec-secid">2.8</span>Fragments</a><input hidden class="toggle" type="checkbox" checked id="_toggle_2.8" /><label for="_toggle_2.8"></label><ol><li><a href="#sec-Type-Conditions"><span class="spec-secid">2.8.1</span>Type Conditions</a></li><li><a href="#sec-Inline-Fragments"><span class="spec-secid">2.8.2</span>Inline Fragments</a></li></ol></li><li><a href="#sec-Input-Values"><span class="spec-secid">2.9</span>Input Values</a><input hidden class="toggle" type="checkbox" checked id="_toggle_2.9" /><label for="_toggle_2.9"></label><ol><li><a href="#sec-Int-Value"><span class="spec-secid">2.9.1</span>Int Value</a></li><li><a href="#sec-Float-Value"><span class="spec-secid">2.9.2</span>Float Value</a></li><li><a href="#sec-Boolean-Value"><span class="spec-secid">2.9.3</span>Boolean Value</a></li><li><a href="#sec-String-Value"><span class="spec-secid">2.9.4</span>String Value</a></li><li><a href="#sec-Null-Value"><span class="spec-secid">2.9.5</span>Null Value</a></li><li><a href="#sec-Enum-Value"><span class="spec-secid">2.9.6</span>Enum Value</a></li><li><a href="#sec-List-Value"><span class="spec-secid">2.9.7</span>List Value</a></li><li><a href="#sec-Input-Object-Values"><span class="spec-secid">2.9.8</span>Input Object Values</a></li></ol></li><li><a href="#sec-Language.Variables"><span class="spec-secid">2.10</span>Variables</a></li><li><a href="#sec-Type-References"><span class="spec-secid">2.11</span>Type References</a></li><li><a href="#sec-Language.Directives"><span class="spec-secid">2.12</span>Directives</a></li></ol></li><li><a href="#sec-Type-System"><span class="spec-secid">3</span>Type System</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3" /><label for="_toggle_3"></label><ol><li><a href="#sec-Type-System-Extensions"><span class="spec-secid">3.1</span>Type System Extensions</a></li><li><a href="#sec-Schema"><span class="spec-secid">3.2</span>Schema</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.2" /><label for="_toggle_3.2"></label><ol><li><a href="#sec-Root-Operation-Types"><span class="spec-secid">3.2.1</span>Root Operation Types</a></li><li><a href="#sec-Schema-Extension"><span class="spec-secid">3.2.2</span>Schema Extension</a></li></ol></li><li><a href="#sec-Descriptions"><span class="spec-secid">3.3</span>Descriptions</a></li><li><a href="#sec-Types"><span class="spec-secid">3.4</span>Types</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.4" /><label for="_toggle_3.4"></label><ol><li><a href="#sec-Wrapping-Types"><span class="spec-secid">3.4.1</span>Wrapping Types</a></li><li><a href="#sec-Input-and-Output-Types"><span class="spec-secid">3.4.2</span>Input and Output Types</a></li><li><a href="#sec-Type-Extensions"><span class="spec-secid">3.4.3</span>Type Extensions</a></li></ol></li><li><a href="#sec-Scalars"><span class="spec-secid">3.5</span>Scalars</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.5" /><label for="_toggle_3.5"></label><ol><li><a href="#sec-Int"><span class="spec-secid">3.5.1</span>Int</a></li><li><a href="#sec-Float"><span class="spec-secid">3.5.2</span>Float</a></li><li><a href="#sec-String"><span class="spec-secid">3.5.3</span>String</a></li><li><a href="#sec-Boolean"><span class="spec-secid">3.5.4</span>Boolean</a></li><li><a href="#sec-ID"><span class="spec-secid">3.5.5</span>ID</a></li><li><a href="#sec-Scalar-Extensions"><span class="spec-secid">3.5.6</span>Scalar Extensions</a></li></ol></li><li><a href="#sec-Objects"><span class="spec-secid">3.6</span>Objects</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.6" /><label for="_toggle_3.6"></label><ol><li><a href="#sec-Field-Arguments"><span class="spec-secid">3.6.1</span>Field Arguments</a></li><li><a href="#sec-Field-Deprecation"><span class="spec-secid">3.6.2</span>Field Deprecation</a></li><li><a href="#sec-Object-Extensions"><span class="spec-secid">3.6.3</span>Object Extensions</a></li></ol></li><li><a href="#sec-Interfaces"><span class="spec-secid">3.7</span>Interfaces</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.7" /><label for="_toggle_3.7"></label><ol><li><a href="#sec-Interface-Extensions"><span class="spec-secid">3.7.1</span>Interface Extensions</a></li></ol></li><li><a href="#sec-Unions"><span class="spec-secid">3.8</span>Unions</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.8" /><label for="_toggle_3.8"></label><ol><li><a href="#sec-Union-Extensions"><span class="spec-secid">3.8.1</span>Union Extensions</a></li></ol></li><li><a href="#sec-Enums"><span class="spec-secid">3.9</span>Enums</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.9" /><label for="_toggle_3.9"></label><ol><li><a href="#sec-Enum-Extensions"><span class="spec-secid">3.9.1</span>Enum Extensions</a></li></ol></li><li><a href="#sec-Input-Objects"><span class="spec-secid">3.10</span>Input Objects</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.10" /><label for="_toggle_3.10"></label><ol><li><a href="#sec-Input-Object-Extensions"><span class="spec-secid">3.10.1</span>Input Object Extensions</a></li></ol></li><li><a href="#sec-Type-System.List"><span class="spec-secid">3.11</span>List</a></li><li><a href="#sec-Type-System.Non-Null"><span class="spec-secid">3.12</span>Non-Null</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.12" /><label for="_toggle_3.12"></label><ol><li><a href="#sec-Combining-List-and-Non-Null"><span class="spec-secid">3.12.1</span>Combining List and Non-Null</a></li></ol></li><li><a href="#sec-Type-System.Directives"><span class="spec-secid">3.13</span>Directives</a><input hidden class="toggle" type="checkbox" checked id="_toggle_3.13" /><label for="_toggle_3.13"></label><ol><li><a href="#sec--skip"><span class="spec-secid">3.13.1</span>@skip</a></li><li><a href="#sec--include"><span class="spec-secid">3.13.2</span>@include</a></li><li><a href="#sec--deprecated"><span class="spec-secid">3.13.3</span>@deprecated</a></li></ol></li></ol></li><li><a href="#sec-Introspection"><span class="spec-secid">4</span>Introspection</a><input hidden class="toggle" type="checkbox" checked id="_toggle_4" /><label for="_toggle_4"></label><ol><li><a href="#sec-Reserved-Names"><span class="spec-secid">4.1</span>Reserved Names</a></li><li><a href="#sec-Documentation"><span class="spec-secid">4.2</span>Documentation</a></li><li><a href="#sec-Deprecation"><span class="spec-secid">4.3</span>Deprecation</a></li><li><a href="#sec-Type-Name-Introspection"><span class="spec-secid">4.4</span>Type Name Introspection</a></li><li><a href="#sec-Schema-Introspection"><span class="spec-secid">4.5</span>Schema Introspection</a><input hidden class="toggle" type="checkbox" checked id="_toggle_4.5" /><label for="_toggle_4.5"></label><ol><li><a href="#sec-The-__Type-Type"><span class="spec-secid">4.5.1</span>The __Type Type</a></li><li><a href="#sec-Type-Kinds"><span class="spec-secid">4.5.2</span>Type Kinds</a><input hidden class="toggle" type="checkbox" checked id="_toggle_4.5.2" /><label for="_toggle_4.5.2"></label><ol><li><a href="#sec-Scalar"><span class="spec-secid">4.5.2.1</span>Scalar</a></li><li><a href="#sec-Object"><span class="spec-secid">4.5.2.2</span>Object</a></li><li><a href="#sec-Union"><span class="spec-secid">4.5.2.3</span>Union</a></li><li><a href="#sec-Interface"><span class="spec-secid">4.5.2.4</span>Interface</a></li><li><a href="#sec-Enum"><span class="spec-secid">4.5.2.5</span>Enum</a></li><li><a href="#sec-Input-Object"><span class="spec-secid">4.5.2.6</span>Input Object</a></li><li><a href="#sec-Type-Kinds.List"><span class="spec-secid">4.5.2.7</span>List</a></li><li><a href="#sec-Type-Kinds.Non-Null"><span class="spec-secid">4.5.2.8</span>Non-Null</a></li></ol></li><li><a href="#sec-The-__Field-Type"><span class="spec-secid">4.5.3</span>The __Field Type</a></li><li><a href="#sec-The-__InputValue-Type"><span class="spec-secid">4.5.4</span>The __InputValue Type</a></li><li><a href="#sec-The-__EnumValue-Type"><span class="spec-secid">4.5.5</span>The __EnumValue Type</a></li><li><a href="#sec-The-__Directive-Type"><span class="spec-secid">4.5.6</span>The __Directive Type</a></li></ol></li></ol></li><li><a href="#sec-Validation"><span class="spec-secid">5</span>Validation</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5" /><label for="_toggle_5"></label><ol><li><a href="#sec-Documents"><span class="spec-secid">5.1</span>Documents</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.1" /><label for="_toggle_5.1"></label><ol><li><a href="#sec-Executable-Definitions"><span class="spec-secid">5.1.1</span>Executable Definitions</a></li></ol></li><li><a href="#sec-Validation.Operations"><span class="spec-secid">5.2</span>Operations</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.2" /><label for="_toggle_5.2"></label><ol><li><a href="#sec-Named-Operation-Definitions"><span class="spec-secid">5.2.1</span>Named Operation Definitions</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.2.1" /><label for="_toggle_5.2.1"></label><ol><li><a href="#sec-Operation-Name-Uniqueness"><span class="spec-secid">5.2.1.1</span>Operation Name Uniqueness</a></li></ol></li><li><a href="#sec-Anonymous-Operation-Definitions"><span class="spec-secid">5.2.2</span>Anonymous Operation Definitions</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.2.2" /><label for="_toggle_5.2.2"></label><ol><li><a href="#sec-Lone-Anonymous-Operation"><span class="spec-secid">5.2.2.1</span>Lone Anonymous Operation</a></li></ol></li><li><a href="#sec-Subscription-Operation-Definitions"><span class="spec-secid">5.2.3</span>Subscription Operation Definitions</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.2.3" /><label for="_toggle_5.2.3"></label><ol><li><a href="#sec-Single-root-field"><span class="spec-secid">5.2.3.1</span>Single root field</a></li></ol></li></ol></li><li><a href="#sec-Validation.Fields"><span class="spec-secid">5.3</span>Fields</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.3" /><label for="_toggle_5.3"></label><ol><li><a href="#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types"><span class="spec-secid">5.3.1</span>Field Selections on Objects, Interfaces, and Unions Types</a></li><li><a href="#sec-Field-Selection-Merging"><span class="spec-secid">5.3.2</span>Field Selection Merging</a></li><li><a href="#sec-Leaf-Field-Selections"><span class="spec-secid">5.3.3</span>Leaf Field Selections</a></li></ol></li><li><a href="#sec-Validation.Arguments"><span class="spec-secid">5.4</span>Arguments</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.4" /><label for="_toggle_5.4"></label><ol><li><a href="#sec-Argument-Names"><span class="spec-secid">5.4.1</span>Argument Names</a></li><li><a href="#sec-Argument-Uniqueness"><span class="spec-secid">5.4.2</span>Argument Uniqueness</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.4.2" /><label for="_toggle_5.4.2"></label><ol><li><a href="#sec-Required-Arguments"><span class="spec-secid">5.4.2.1</span>Required Arguments</a></li></ol></li></ol></li><li><a href="#sec-Validation.Fragments"><span class="spec-secid">5.5</span>Fragments</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.5" /><label for="_toggle_5.5"></label><ol><li><a href="#sec-Fragment-Declarations"><span class="spec-secid">5.5.1</span>Fragment Declarations</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.5.1" /><label for="_toggle_5.5.1"></label><ol><li><a href="#sec-Fragment-Name-Uniqueness"><span class="spec-secid">5.5.1.1</span>Fragment Name Uniqueness</a></li><li><a href="#sec-Fragment-Spread-Type-Existence"><span class="spec-secid">5.5.1.2</span>Fragment Spread Type Existence</a></li><li><a href="#sec-Fragments-On-Composite-Types"><span class="spec-secid">5.5.1.3</span>Fragments On Composite Types</a></li><li><a href="#sec-Fragments-Must-Be-Used"><span class="spec-secid">5.5.1.4</span>Fragments Must Be Used</a></li></ol></li><li><a href="#sec-Fragment-Spreads"><span class="spec-secid">5.5.2</span>Fragment Spreads</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.5.2" /><label for="_toggle_5.5.2"></label><ol><li><a href="#sec-Fragment-spread-target-defined"><span class="spec-secid">5.5.2.1</span>Fragment spread target defined</a></li><li><a href="#sec-Fragment-spreads-must-not-form-cycles"><span class="spec-secid">5.5.2.2</span>Fragment spreads must not form cycles</a></li><li><a href="#sec-Fragment-spread-is-possible"><span class="spec-secid">5.5.2.3</span>Fragment spread is possible</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.5.2.3" /><label for="_toggle_5.5.2.3"></label><ol><li><a href="#sec-Object-Spreads-In-Object-Scope"><span class="spec-secid">5.5.2.3.1</span>Object Spreads In Object Scope</a></li><li><a href="#sec-Abstract-Spreads-in-Object-Scope"><span class="spec-secid">5.5.2.3.2</span>Abstract Spreads in Object Scope</a></li><li><a href="#sec-Object-Spreads-In-Abstract-Scope"><span class="spec-secid">5.5.2.3.3</span>Object Spreads In Abstract Scope</a></li><li><a href="#sec-Abstract-Spreads-in-Abstract-Scope"><span class="spec-secid">5.5.2.3.4</span>Abstract Spreads in Abstract Scope</a></li></ol></li></ol></li></ol></li><li><a href="#sec-Values"><span class="spec-secid">5.6</span>Values</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.6" /><label for="_toggle_5.6"></label><ol><li><a href="#sec-Values-of-Correct-Type"><span class="spec-secid">5.6.1</span>Values of Correct Type</a></li><li><a href="#sec-Input-Object-Field-Names"><span class="spec-secid">5.6.2</span>Input Object Field Names</a></li><li><a href="#sec-Input-Object-Field-Uniqueness"><span class="spec-secid">5.6.3</span>Input Object Field Uniqueness</a></li><li><a href="#sec-Input-Object-Required-Fields"><span class="spec-secid">5.6.4</span>Input Object Required Fields</a></li></ol></li><li><a href="#sec-Validation.Directives"><span class="spec-secid">5.7</span>Directives</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.7" /><label for="_toggle_5.7"></label><ol><li><a href="#sec-Directives-Are-Defined"><span class="spec-secid">5.7.1</span>Directives Are Defined</a></li><li><a href="#sec-Directives-Are-In-Valid-Locations"><span class="spec-secid">5.7.2</span>Directives Are In Valid Locations</a></li><li><a href="#sec-Directives-Are-Unique-Per-Location"><span class="spec-secid">5.7.3</span>Directives Are Unique Per Location</a></li></ol></li><li><a href="#sec-Validation.Variables"><span class="spec-secid">5.8</span>Variables</a><input hidden class="toggle" type="checkbox" checked id="_toggle_5.8" /><label for="_toggle_5.8"></label><ol><li><a href="#sec-Variable-Uniqueness"><span class="spec-secid">5.8.1</span>Variable Uniqueness</a></li><li><a href="#sec-Variables-Are-Input-Types"><span class="spec-secid">5.8.2</span>Variables Are Input Types</a></li><li><a href="#sec-All-Variable-Uses-Defined"><span class="spec-secid">5.8.3</span>All Variable Uses Defined</a></li><li><a href="#sec-All-Variables-Used"><span class="spec-secid">5.8.4</span>All Variables Used</a></li><li><a href="#sec-All-Variable-Usages-are-Allowed"><span class="spec-secid">5.8.5</span>All Variable Usages are Allowed</a></li></ol></li></ol></li><li><a href="#sec-Execution"><span class="spec-secid">6</span>Execution</a><input hidden class="toggle" type="checkbox" checked id="_toggle_6" /><label for="_toggle_6"></label><ol><li><a href="#sec-Executing-Requests"><span class="spec-secid">6.1</span>Executing Requests</a><input hidden class="toggle" type="checkbox" checked id="_toggle_6.1" /><label for="_toggle_6.1"></label><ol><li><a href="#sec-Validating-Requests"><span class="spec-secid">6.1.1</span>Validating Requests</a></li><li><a href="#sec-Coercing-Variable-Values"><span class="spec-secid">6.1.2</span>Coercing Variable Values</a></li></ol></li><li><a href="#sec-Executing-Operations"><span class="spec-secid">6.2</span>Executing Operations</a><input hidden class="toggle" type="checkbox" checked id="_toggle_6.2" /><label for="_toggle_6.2"></label><ol><li><a href="#sec-Query"><span class="spec-secid">6.2.1</span>Query</a></li><li><a href="#sec-Mutation"><span class="spec-secid">6.2.2</span>Mutation</a></li><li><a href="#sec-Subscription"><span class="spec-secid">6.2.3</span>Subscription</a><input hidden class="toggle" type="checkbox" checked id="_toggle_6.2.3" /><label for="_toggle_6.2.3"></label><ol><li><a href="#sec-Source-Stream"><span class="spec-secid">6.2.3.1</span>Source Stream</a></li><li><a href="#sec-Response-Stream"><span class="spec-secid">6.2.3.2</span>Response Stream</a></li><li><a href="#sec-Unsubscribe"><span class="spec-secid">6.2.3.3</span>Unsubscribe</a></li></ol></li></ol></li><li><a href="#sec-Executing-Selection-Sets"><span class="spec-secid">6.3</span>Executing Selection Sets</a><input hidden class="toggle" type="checkbox" checked id="_toggle_6.3" /><label for="_toggle_6.3"></label><ol><li><a href="#sec-Normal-and-Serial-Execution"><span class="spec-secid">6.3.1</span>Normal and Serial Execution</a></li><li><a href="#sec-Field-Collection"><span class="spec-secid">6.3.2</span>Field Collection</a></li></ol></li><li><a href="#sec-Executing-Fields"><span class="spec-secid">6.4</span>Executing Fields</a><input hidden class="toggle" type="checkbox" checked id="_toggle_6.4" /><label for="_toggle_6.4"></label><ol><li><a href="#sec-Coercing-Field-Arguments"><span class="spec-secid">6.4.1</span>Coercing Field Arguments</a></li><li><a href="#sec-Value-Resolution"><span class="spec-secid">6.4.2</span>Value Resolution</a></li><li><a href="#sec-Value-Completion"><span class="spec-secid">6.4.3</span>Value Completion</a></li><li><a href="#sec-Errors-and-Non-Nullability"><span class="spec-secid">6.4.4</span>Errors and Non-Nullability</a></li></ol></li></ol></li><li><a href="#sec-Response"><span class="spec-secid">7</span>Response</a><input hidden class="toggle" type="checkbox" checked id="_toggle_7" /><label for="_toggle_7"></label><ol><li><a href="#sec-Response-Format"><span class="spec-secid">7.1</span>Response Format</a><input hidden class="toggle" type="checkbox" checked id="_toggle_7.1" /><label for="_toggle_7.1"></label><ol><li><a href="#sec-Data"><span class="spec-secid">7.1.1</span>Data</a></li><li><a href="#sec-Errors"><span class="spec-secid">7.1.2</span>Errors</a></li></ol></li><li><a href="#sec-Serialization-Format"><span class="spec-secid">7.2</span>Serialization Format</a><input hidden class="toggle" type="checkbox" checked id="_toggle_7.2" /><label for="_toggle_7.2"></label><ol><li><a href="#sec-JSON-Serialization"><span class="spec-secid">7.2.1</span>JSON Serialization</a></li><li><a href="#sec-Serialized-Map-Ordering"><span class="spec-secid">7.2.2</span>Serialized Map Ordering</a></li></ol></li></ol></li><li><a href="#sec-Appendix-Notation-Conventions"><span class="spec-secid">A</span>Appendix: Notation Conventions</a><input hidden class="toggle" type="checkbox" checked id="_toggle_A" /><label for="_toggle_A"></label><ol><li><a href="#sec-Context-Free-Grammar"><span class="spec-secid">A.1</span>Context-Free Grammar</a></li><li><a href="#sec-Lexical-and-Syntactical-Grammar"><span class="spec-secid">A.2</span>Lexical and Syntactical Grammar</a></li><li><a href="#sec-Grammar-Notation"><span class="spec-secid">A.3</span>Grammar Notation</a></li><li><a href="#sec-Grammar-Semantics"><span class="spec-secid">A.4</span>Grammar Semantics</a></li><li><a href="#sec-Algorithms"><span class="spec-secid">A.5</span>Algorithms</a></li></ol></li><li><a href="#sec-Appendix-Grammar-Summary"><span class="spec-secid">B</span>Appendix: Grammar Summary</a><input hidden class="toggle" type="checkbox" checked id="_toggle_B" /><label for="_toggle_B"></label><ol><li><a href="#sec-Appendix-Grammar-Summary.Ignored-Tokens"><span class="spec-secid">B.1</span>Ignored Tokens</a></li><li><a href="#sec-Appendix-Grammar-Summary.Lexical-Tokens"><span class="spec-secid">B.2</span>Lexical Tokens</a></li><li><a href="#sec-Appendix-Grammar-Summary.Document"><span class="spec-secid">B.3</span>Document</a></li></ol></li><li><a href="#index"><span class="spec-secid">§</span>Index</a></li></ol></nav></header><section id="sec-Overview" secid="1"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Overview">1</a></span>Overview</h2><p>GraphQL is a query language designed to build client applications by providing an intuitive and flexible syntax and system for describing their data requirements and interactions.</p><p>For example, this GraphQL request will receive the name of the user with id 4 from the Facebook implementation of GraphQL.</p><pre id="example-85684" class="spec-example"><a href="#example-85684">Example № 3</a><code><span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Which produces the resulting data (in JSON):</p><pre id="example-90fe6" class="spec-example"><a href="#example-90fe6">Example № 4</a><code><span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Mark Zuckerberg"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>GraphQL is not a programming language capable of arbitrary computation, but is instead a language used to query application servers that have capabilities defined in this specification. GraphQL does not mandate a particular programming language or storage system for application servers that implement it. Instead, application servers take their capabilities and map them to a uniform language, type system, and philosophy that GraphQL encodes. This provides a unified interface friendly to product development and a powerful platform for tool&#8208;building.</p><p>GraphQL has a number of design principles:</p><ul><li><strong>Hierarchical</strong>: Most product development today involves the creation and manipulation of view hierarchies. To achieve congruence with the structure of these applications, a GraphQL query itself is structured hierarchically. The query is shaped just like the data it returns. It is a natural way for clients to describe data requirements.</li><li><strong>Product&#8208;centric</strong>: GraphQL is unapologetically driven by the requirements of views and the front&#8208;end engineers that write them. GraphQL starts with their way of thinking and requirements and builds the language and runtime necessary to enable that.</li><li><strong>Strong&#8208;typing</strong>: Every GraphQL server defines an application&#8208;specific type system. Queries are executed within the context of that type system. Given a query, tools can ensure that the query is both syntactically correct and valid within the GraphQL type system before execution, i.e. at development time, and the server can make certain guarantees about the shape and nature of the response.</li><li><strong>Client&#8208;specified queries</strong>: Through its type system, a GraphQL server publishes the capabilities that its clients are allowed to consume. It is the client that is responsible for specifying exactly how it will consume those published capabilities. These queries are specified at field&#8208;level granularity. In the majority of client&#8208;server applications written without GraphQL, the server determines the data returned in its various scripted endpoints. A GraphQL query, on the other hand, returns exactly what a client asks for and no more.</li><li><strong>Introspective</strong>: GraphQL is introspective. A GraphQL server&rsquo;s type system must be queryable by the GraphQL language itself, as will be described in this specification. GraphQL introspection serves as a powerful platform for building common tools and client software libraries.</li></ul><p>Because of these principles, GraphQL is a powerful and productive environment for building client applications. Product developers and designers building applications against working GraphQL servers -- supported with quality tools -- can quickly become productive without reading extensive documentation and with little or no formal training. To enable that experience, there must be those that build those servers and tools.</p><p>The following formal specification serves as a reference for those builders. It describes the language and its grammar, the type system and the introspection system used to query it, and the execution and validation engines with the algorithms to power them. The goal of this specification is to provide a foundation and framework for an ecosystem of GraphQL tools, client libraries, and server implementations -- spanning both organizations and platforms -- that has yet to be built. We look forward to working with the community in order to do that. </p></section><section id="sec-Language" secid="2"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Language">2</a></span>Language</h2><p>Clients use the GraphQL query language to make requests to a GraphQL service. We refer to these request sources as documents. A document may contain operations (queries, mutations, and subscriptions) as well as fragments, a common unit of composition allowing for query reuse.</p><p>A GraphQL document is defined as a syntactic grammar where terminal symbols are tokens (indivisible lexical units). These tokens are defined in a lexical grammar which matches patterns of source characters (defined by a double&#8208;colon <code>::</code>).</p><div class="spec-note">See <a href="#sec-Appendix-Notation-Conventions">Appendix A</a> for more details about the definition of lexical and syntactic grammar and other notational conventions used in this document.</div><section id="sec-Source-Text" secid="2.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Source-Text">2.1</a></span>Source Text</h3><div class="spec-production d2" id="SourceCharacter"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><div class="spec-rhs"><span class="spec-rx">/[\u0009\u000A\u000D\u0020-\uFFFF]/</span></div></div><p>GraphQL documents are expressed as a sequence of <a href="http://unicode.org/standard/standard.html">Unicode</a> characters. However, with few exceptions, most of GraphQL is expressed only in the original non&#8208;control ASCII range so as to be as widely compatible with as many existing tools, languages, and serialization formats as possible and avoid display issues in text editors and source control.</p><section id="sec-Unicode" secid="2.1.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Unicode">2.1.1</a></span>Unicode</h4><div class="spec-production d2" id="UnicodeBOM"><span class="spec-nt"><a href="#UnicodeBOM" data-name="UnicodeBOM">UnicodeBOM</a></span><div class="spec-rhs"><span class="spec-prose">Byte Order Mark (U+FEFF)</span></div></div><p>Non&#8208;ASCII Unicode characters may freely appear within <span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span> and <span class="spec-nt"><a href="#Comment" data-name="Comment">Comment</a></span> portions of GraphQL.</p><p>The &ldquo;Byte Order Mark&rdquo; is a special Unicode character which may appear at the beginning of a file containing Unicode which programs may use to determine the fact that the text stream is Unicode, what endianness the text stream is in, and which of several Unicode encodings to interpret.</p></section><section id="sec-White-Space" secid="2.1.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-White-Space">2.1.2</a></span>White Space</h4><div class="spec-production d2" id="WhiteSpace"><span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span><div class="spec-rhs"><span class="spec-prose">Horizontal Tab (U+0009)</span></div><div class="spec-rhs"><span class="spec-prose">Space (U+0020)</span></div></div><p>White space is used to improve legibility of source text and act as separation between tokens, and any amount of white space may appear before or after any token. White space between tokens is not significant to the semantic meaning of a GraphQL Document, however white space characters may appear within a <span class="spec-nt"><span data-name="String">String</span></span> or <span class="spec-nt"><a href="#Comment" data-name="Comment">Comment</a></span> token.</p><div class="spec-note">GraphQL intentionally does not consider Unicode &ldquo;Zs&rdquo; category characters as white&#8208;space, avoiding misinterpretation by text editors and source control tools.</div></section><section id="sec-Line-Terminators" secid="2.1.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Line-Terminators">2.1.3</a></span>Line Terminators</h4><div class="spec-production d2" id="LineTerminator"><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span><div class="spec-rhs"><span class="spec-prose">New Line (U+000A)</span></div><div class="spec-rhs"><span class="spec-prose">Carriage Return (U+000D)</span><span class="spec-lookahead not"><span class="spec-prose">New Line (U+000A)</span></span></div><div class="spec-rhs"><span class="spec-prose">Carriage Return (U+000D)</span><span class="spec-prose">New Line (U+000A)</span></div></div><p>Like white space, line terminators are used to improve the legibility of source text, any amount may appear before or after any other token and have no significance to the semantic meaning of a GraphQL Document. Line terminators are not found within any other token.</p><div class="spec-note">Any error reporting which provide the line number in the source of the offending syntax should use the preceding amount of <span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span> to produce the line number.</div></section><section id="sec-Comments" secid="2.1.4"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Comments">2.1.4</a></span>Comments</h4><div class="spec-production d2" id="Comment"><span class="spec-nt"><a href="#Comment" data-name="Comment">Comment</a></span><div class="spec-rhs"><span class="spec-t">#</span><span class="spec-quantified"><span class="spec-nt"><a href="#CommentChar" data-name="CommentChar">CommentChar</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production d2" id="CommentChar"><span class="spec-nt"><a href="#CommentChar" data-name="CommentChar">CommentChar</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span></span></span></div></div><p>GraphQL source documents may contain single&#8208;line comments, starting with the <span class="spec-t">#</span> marker.</p><p>A comment can contain any Unicode code point except <span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span> so a comment always consists of all code points starting with the <span class="spec-t">#</span> character up to but not including the line terminator.</p><p>Comments behave like white space and may appear after any token, or before a line terminator, and have no significance to the semantic meaning of a GraphQL Document.</p></section><section id="sec-Insignificant-Commas" secid="2.1.5"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Insignificant-Commas">2.1.5</a></span>Insignificant Commas</h4><div class="spec-production d2" id="Comma"><span class="spec-nt"><a href="#Comma" data-name="Comma">Comma</a></span><div class="spec-rhs"><span class="spec-t">,</span></div></div><p>Similar to white space and line terminators, commas (<span class="spec-t">,</span>) are used to improve the legibility of source text and separate lexical tokens but are otherwise syntactically and semantically insignificant within GraphQL Documents.</p><p>Non&#8208;significant comma characters ensure that the absence or presence of a comma does not meaningfully alter the interpreted syntax of the document, as this can be a common user&#8208;error in other languages. It also allows for the stylistic use of either trailing commas or line&#8208;terminators as list delimiters which are both often desired for legibility and maintainability of source code.</p></section><section id="sec-Source-Text.Lexical-Tokens" secid="2.1.6"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Source-Text.Lexical-Tokens">2.1.6</a></span>Lexical Tokens</h4><div class="spec-production d2" id="Token"><span class="spec-nt"><a href="#Token" data-name="Token">Token</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Punctuator" data-name="Punctuator">Punctuator</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntValue" data-name="IntValue">IntValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FloatValue" data-name="FloatValue">FloatValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span></div></div><p>A GraphQL document is comprised of several kinds of indivisible lexical tokens defined here in a lexical grammar by patterns of source Unicode characters.</p><p>Tokens are later used as terminal symbols in a GraphQL Document syntactic grammars.</p></section><section id="sec-Source-Text.Ignored-Tokens" secid="2.1.7"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Source-Text.Ignored-Tokens">2.1.7</a></span>Ignored Tokens</h4><div class="spec-production d2" id="Ignored"><span class="spec-nt"><a href="#Ignored" data-name="Ignored">Ignored</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#UnicodeBOM" data-name="UnicodeBOM">UnicodeBOM</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#Comment" data-name="Comment">Comment</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#Comma" data-name="Comma">Comma</a></span></div></div><p>Before and after every lexical token may be any amount of ignored tokens including <span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span> and <span class="spec-nt"><a href="#Comment" data-name="Comment">Comment</a></span>. No ignored regions of a source document are significant, however ignored source characters may appear within a lexical token in a significant way, for example a <span class="spec-nt"><span data-name="String">String</span></span> may contain white space characters.</p><p>No characters are ignored while parsing a given token, as an example no white space characters are permitted between the characters defining a <span class="spec-nt"><a href="#FloatValue" data-name="FloatValue">FloatValue</a></span>.</p></section><section id="sec-Punctuators" secid="2.1.8"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Punctuators">2.1.8</a></span>Punctuators</h4><div class="spec-production d2" id="Punctuator"><span class="spec-nt"><a href="#Punctuator" data-name="Punctuator">Punctuator</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">!</span></td><td class="spec-rhs"><span class="spec-t">$</span></td><td class="spec-rhs"><span class="spec-t">(</span></td><td class="spec-rhs"><span class="spec-t">)</span></td><td class="spec-rhs"><span class="spec-t">...</span></td><td class="spec-rhs"><span class="spec-t">:</span></td><td class="spec-rhs"><span class="spec-t">=</span></td><td class="spec-rhs"><span class="spec-t">@</span></td><td class="spec-rhs"><span class="spec-t">[</span></td><td class="spec-rhs"><span class="spec-t">]</span></td><td class="spec-rhs"><span class="spec-t">{</span></td><td class="spec-rhs"><span class="spec-t">|</span></td><td class="spec-rhs"><span class="spec-t">}</span></td></tr></table></div></div><p>GraphQL documents include punctuation in order to describe structure. GraphQL is a data description language and not a programming language, therefore GraphQL lacks the punctuation often used to describe mathematical expressions.</p></section><section id="sec-Names" secid="2.1.9"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Names">2.1.9</a></span>Names</h4><div class="spec-production d2" id="Name"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><div class="spec-rhs"><span class="spec-rx">/[_A-Za-z][_0-9A-Za-z]*/</span></div></div><p>GraphQL Documents are full of named things: operations, fields, arguments, types, directives, fragments, and variables. All names must follow the same grammatical form.</p><p>Names in GraphQL are case&#8208;sensitive. That is to say <code>name</code>, <code>Name</code>, and <code>NAME</code> all refer to different names. Underscores are significant, which means <code>other_name</code> and <code>othername</code> are two different names.</p><p>Names in GraphQL are limited to this <acronym>ASCII</acronym> subset of possible characters to support interoperation with as many other systems as possible.</p></section></section><section id="sec-Language.Document" secid="2.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Language.Document">2.2</a></span>Document</h3><div class="spec-production" id="Document"><span class="spec-nt"><a href="#Document" data-name="Document">Document</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Definition" data-name="Definition">Definition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production" id="Definition"><span class="spec-nt"><a href="#Definition" data-name="Definition">Definition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ExecutableDefinition" data-name="ExecutableDefinition">ExecutableDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeSystemExtension" data-name="TypeSystemExtension">TypeSystemExtension</a></span></div></div><div class="spec-production" id="ExecutableDefinition"><span class="spec-nt"><a href="#ExecutableDefinition" data-name="ExecutableDefinition">ExecutableDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FragmentDefinition" data-name="FragmentDefinition">FragmentDefinition</a></span></div></div><p>A GraphQL Document describes a complete file or request string operated on by a GraphQL service or client. A document contains multiple definitions, either executable or representative of a GraphQL type system.</p><p>Documents are only executable by a GraphQL service if they contain an <span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span> and otherwise only contain <span class="spec-nt"><a href="#ExecutableDefinition" data-name="ExecutableDefinition">ExecutableDefinition</a></span>. However documents which do not contain <span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span> or do contain <span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span> or <span class="spec-nt"><a href="#TypeSystemExtension" data-name="TypeSystemExtension">TypeSystemExtension</a></span> may still be parsed and validated to allow client tools to represent many GraphQL uses which may appear across many individual files.</p><p>If a Document contains only one operation, that operation may be unnamed or represented in the shorthand form, which omits both the query keyword and operation name. Otherwise, if a GraphQL Document contains multiple operations, each operation must be named. When submitting a Document with multiple operations to a GraphQL service, the name of the desired operation to be executed must also be provided.</p><p>GraphQL services which only seek to provide GraphQL query execution may choose to only include <span class="spec-nt"><a href="#ExecutableDefinition" data-name="ExecutableDefinition">ExecutableDefinition</a></span> and omit the <span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span> and <span class="spec-nt"><a href="#TypeSystemExtension" data-name="TypeSystemExtension">TypeSystemExtension</a></span> rules from <span class="spec-nt"><a href="#Definition" data-name="Definition">Definition</a></span>.</p></section><section id="sec-Language.Operations" secid="2.3"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Language.Operations">2.3</a></span>Operations</h3><div class="spec-production" id="OperationDefinition"><span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#OperationType" data-name="OperationType">OperationType</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#VariableDefinitions" data-name="VariableDefinitions">VariableDefinitions</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div></div><div class="spec-production" id="OperationType"><span class="spec-nt"><a href="#OperationType" data-name="OperationType">OperationType</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">query</span></td><td class="spec-rhs"><span class="spec-t">mutation</span></td><td class="spec-rhs"><span class="spec-t">subscription</span></td></tr></table></div></div><p>There are three types of operations that GraphQL models:</p><ul><li>query &ndash; a read&#8208;only fetch.</li><li>mutation &ndash; a write followed by a fetch.</li><li>subscription &ndash; a long&#8208;lived request that fetches data in response to source events.</li></ul><p>Each operation is represented by an optional operation name and a selection set.</p><p>For example, this mutation operation might &ldquo;like&rdquo; a story and then retrieve the new number of likes:</p><pre id="example-ed6a8" class="spec-example"><a href="#example-ed6a8">Example № 5</a><code><span class="token keyword">mutation</span> <span class="token punctuation">{</span> likeStory<span class="token punctuation">(</span><span class="token attr-name">storyID</span><span class="token punctuation">:</span> <span class="token number">12345</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> story <span class="token punctuation">{</span> likeCount <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p><strong>Query shorthand</strong></p><p>If a document contains only one query operation, and that query defines no variables and contains no directives, that operation may be represented in a short&#8208;hand form which omits the query keyword and query name.</p><p>For example, this unnamed query operation is written via query shorthand.</p><pre id="example-63b18" class="spec-example"><a href="#example-63b18">Example № 6</a><code><span class="token punctuation">{</span> field <span class="token punctuation">}</span> </code></pre><div class="spec-note">many examples below will use the query short&#8208;hand syntax.</div></section><section id="sec-Selection-Sets" secid="2.4"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Selection-Sets">2.4</a></span>Selection Sets</h3><div class="spec-production" id="SelectionSet"><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#Selection" data-name="Selection">Selection</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="Selection"><span class="spec-nt"><a href="#Selection" data-name="Selection">Selection</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Field" data-name="Field">Field</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FragmentSpread" data-name="FragmentSpread">FragmentSpread</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InlineFragment" data-name="InlineFragment">InlineFragment</a></span></div></div><p>An operation selects the set of information it needs, and will receive exactly that information and nothing more, avoiding over&#8208;fetching and under&#8208;fetching data.</p><pre id="example-21649" class="spec-example"><a href="#example-21649">Example № 7</a><code><span class="token punctuation">{</span> id firstName lastName <span class="token punctuation">}</span> </code></pre><p>In this query, the <code>id</code>, <code>firstName</code>, and <code>lastName</code> fields form a selection set. Selection sets may also contain fragment references.</p></section><section id="sec-Language.Fields" secid="2.5"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Language.Fields">2.5</a></span>Fields</h3><div class="spec-production" id="Field"><span class="spec-nt"><a href="#Field" data-name="Field">Field</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Alias" data-name="Alias">Alias</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Arguments" data-name="Arguments">Arguments</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>A selection set is primarily composed of fields. A field describes one discrete piece of information available to request within a selection set.</p><p>Some fields describe complex data or relationships to other data. In order to further explore this data, a field may itself contain a selection set, allowing for deeply nested requests. All GraphQL operations must specify their selections down to fields which return scalar values to ensure an unambiguously shaped response.</p><p>For example, this operation selects fields of complex data and relationships down to scalar values.</p><pre id="example-100a3" class="spec-example"><a href="#example-100a3">Example № 8</a><code><span class="token punctuation">{</span> me <span class="token punctuation">{</span> id firstName lastName birthday <span class="token punctuation">{</span> month day <span class="token punctuation">}</span> friends <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Fields in the top&#8208;level selection set of an operation often represent some information that is globally accessible to your application and its current viewer. Some typical examples of these top fields include references to a current logged&#8208;in viewer, or accessing certain types of data referenced by a unique identifier.</p><pre id="example-e1984" class="spec-example"><a href="#example-e1984">Example № 9</a><code><span class="token comment" spellcheck="true"># `me` could represent the currently logged in viewer.</span> <span class="token punctuation">{</span> me <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token comment" spellcheck="true"># `user` represents one of many users in a graph of data, referred to by a</span> <span class="token comment" spellcheck="true"># unique identifier.</span> <span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Language.Arguments" secid="2.6"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Language.Arguments">2.6</a></span>Arguments</h3><div class="spec-production" id="Arguments"><span class="spec-nt"><a href="#Arguments" data-name="Arguments">Arguments</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">(</span><span class="spec-quantified"><span class="spec-nt"><a href="#Argument" data-name="Argument">Argument</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">)</span></div></div><div class="spec-production" id="Argument"><span class="spec-nt"><a href="#Argument" data-name="Argument">Argument</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div></div><p>Fields are conceptually functions which return values, and occasionally accept arguments which alter their behavior. These arguments often map directly to function arguments within a GraphQL server&rsquo;s implementation.</p><p>In this example, we want to query a specific user (requested via the <code>id</code> argument) and their profile picture of a specific <code>size</code>:</p><pre id="example-1a865" class="spec-example"><a href="#example-1a865">Example № 10</a><code><span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">100</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Many arguments can exist for a given field:</p><pre id="example-34b2d" class="spec-example"><a href="#example-34b2d">Example № 11</a><code><span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name profilePic<span class="token punctuation">(</span><span class="token attr-name">width</span><span class="token punctuation">:</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token attr-name">height</span><span class="token punctuation">:</span> <span class="token number">50</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p><strong>Arguments are unordered</strong></p><p>Arguments may be provided in any syntactic order and maintain identical semantic meaning.</p><p>These two queries are semantically identical:</p><pre id="example-7eba7" class="spec-example"><a href="#example-7eba7">Example № 12</a><code><span class="token punctuation">{</span> picture<span class="token punctuation">(</span><span class="token attr-name">width</span><span class="token punctuation">:</span> <span class="token number">200</span><span class="token punctuation">,</span> <span class="token attr-name">height</span><span class="token punctuation">:</span> <span class="token number">100</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><pre id="example-c93a3" class="spec-example"><a href="#example-c93a3">Example № 13</a><code><span class="token punctuation">{</span> picture<span class="token punctuation">(</span><span class="token attr-name">height</span><span class="token punctuation">:</span> <span class="token number">100</span><span class="token punctuation">,</span> <span class="token attr-name">width</span><span class="token punctuation">:</span> <span class="token number">200</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Field-Alias" secid="2.7"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Field-Alias">2.7</a></span>Field Alias</h3><div class="spec-production" id="Alias"><span class="spec-nt"><a href="#Alias" data-name="Alias">Alias</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span></div></div><p>By default, the key in the response object will use the field name queried. However, you can define a different name by specifying an alias.</p><p>In this example, we can fetch two profile pictures of different sizes and ensure the resulting object will not have duplicate keys:</p><pre id="example-34435" class="spec-example"><a href="#example-34435">Example № 14</a><code><span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name <span class="token attr-name">smallPic</span><span class="token punctuation">:</span> profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">64</span><span class="token punctuation">)</span> <span class="token attr-name">bigPic</span><span class="token punctuation">:</span> profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">1024</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Which returns the result:</p><pre id="example-6e98a" class="spec-example"><a href="#example-6e98a">Example № 15</a><code><span class="token punctuation">{</span> <span class="token property">"user"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Mark Zuckerberg"</span><span class="token punctuation">,</span> <span class="token property">"smallPic"</span><span class="token operator">:</span> <span class="token string">"https://cdn.site.io/pic-4-64.jpg"</span><span class="token punctuation">,</span> <span class="token property">"bigPic"</span><span class="token operator">:</span> <span class="token string">"https://cdn.site.io/pic-4-1024.jpg"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Since the top level of a query is a field, it also can be given an alias:</p><pre id="example-27d2f" class="spec-example"><a href="#example-27d2f">Example № 16</a><code><span class="token punctuation">{</span> <span class="token attr-name">zuck</span><span class="token punctuation">:</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Returns the result:</p><pre id="example-768a2" class="spec-example"><a href="#example-768a2">Example № 17</a><code><span class="token punctuation">{</span> <span class="token property">"zuck"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"id"</span><span class="token operator">:</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Mark Zuckerberg"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>A field&rsquo;s response key is its alias if an alias is provided, and it is otherwise the field&rsquo;s name.</p></section><section id="sec-Language.Fragments" secid="2.8"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Language.Fragments">2.8</a></span>Fragments</h3><div class="spec-production" id="FragmentSpread"><span class="spec-nt"><a href="#FragmentSpread" data-name="FragmentSpread">FragmentSpread</a></span><div class="spec-rhs"><span class="spec-t">...</span><span class="spec-nt"><a href="#FragmentName" data-name="FragmentName">FragmentName</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="FragmentDefinition"><span class="spec-nt"><a href="#FragmentDefinition" data-name="FragmentDefinition">FragmentDefinition</a></span><div class="spec-rhs"><span class="spec-t">fragment</span><span class="spec-nt"><a href="#FragmentName" data-name="FragmentName">FragmentName</a></span><span class="spec-nt"><a href="#TypeCondition" data-name="TypeCondition">TypeCondition</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div></div><div class="spec-production" id="FragmentName"><span class="spec-nt"><a href="#FragmentName" data-name="FragmentName">FragmentName</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-butnot"><span class="spec-t">on</span></span></span></div></div><p>Fragments are the primary unit of composition in GraphQL.</p><p>Fragments allow for the reuse of common repeated selections of fields, reducing duplicated text in the document. Inline Fragments can be used directly within a selection to condition upon a type condition when querying against an interface or union.</p><p>For example, if we wanted to fetch some common information about mutual friends as well as friends of some user:</p><pre id="example-bcf38" class="spec-example"><a href="#example-bcf38">Example № 18</a><code><span class="token keyword">query</span> noFragments <span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> friends<span class="token punctuation">(</span><span class="token attr-name">first</span><span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">50</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> mutualFriends<span class="token punctuation">(</span><span class="token attr-name">first</span><span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">50</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>The repeated fields could be extracted into a fragment and composed by a parent fragment or query.</p><pre id="example-72b4e" class="spec-example"><a href="#example-72b4e">Example № 19</a><code><span class="token keyword">query</span> withFragments <span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> friends<span class="token punctuation">(</span><span class="token attr-name">first</span><span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token operator">...</span>friendFields <span class="token punctuation">}</span> mutualFriends<span class="token punctuation">(</span><span class="token attr-name">first</span><span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token operator">...</span>friendFields <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> friendFields <span class="token keyword">on</span> User <span class="token punctuation">{</span> id name profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">50</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>Fragments are consumed by using the spread operator (<code>...</code>). All fields selected by the fragment will be added to the query field selection at the same level as the fragment invocation. This happens through multiple levels of fragment spreads.</p><p>For example:</p><pre id="example-fb6c3" class="spec-example"><a href="#example-fb6c3">Example № 20</a><code><span class="token keyword">query</span> withNestedFragments <span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> friends<span class="token punctuation">(</span><span class="token attr-name">first</span><span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token operator">...</span>friendFields <span class="token punctuation">}</span> mutualFriends<span class="token punctuation">(</span><span class="token attr-name">first</span><span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token operator">...</span>friendFields <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> friendFields <span class="token keyword">on</span> User <span class="token punctuation">{</span> id name <span class="token operator">...</span>standardProfilePic <span class="token punctuation">}</span> <span class="token keyword">fragment</span> standardProfilePic <span class="token keyword">on</span> User <span class="token punctuation">{</span> profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">50</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>The queries <code>noFragments</code>, <code>withFragments</code>, and <code>withNestedFragments</code> all produce the same response object.</p><section id="sec-Type-Conditions" secid="2.8.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Type-Conditions">2.8.1</a></span>Type Conditions</h4><div class="spec-production" id="TypeCondition"><span class="spec-nt"><a href="#TypeCondition" data-name="TypeCondition">TypeCondition</a></span><div class="spec-rhs"><span class="spec-t">on</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><p>Fragments must specify the type they apply to. In this example, <code>friendFields</code> can be used in the context of querying a <code>User</code>.</p><p>Fragments cannot be specified on any input value (scalar, enumeration, or input object).</p><p>Fragments can be specified on object types, interfaces, and unions.</p><p>Selections within fragments only return values when concrete type of the object it is operating on matches the type of the fragment.</p><p>For example in this query on the Facebook data model:</p><pre id="example-6ce0d" class="spec-example"><a href="#example-6ce0d">Example № 21</a><code><span class="token keyword">query</span> FragmentTyping <span class="token punctuation">{</span> profiles<span class="token punctuation">(</span><span class="token attr-name">handles</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">"zuck"</span><span class="token punctuation">,</span> <span class="token string">"cocacola"</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> handle <span class="token operator">...</span>userFragment <span class="token operator">...</span>pageFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> userFragment <span class="token keyword">on</span> User <span class="token punctuation">{</span> friends <span class="token punctuation">{</span> count <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> pageFragment <span class="token keyword">on</span> Page <span class="token punctuation">{</span> likers <span class="token punctuation">{</span> count <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>The <code>profiles</code> root field returns a list where each element could be a <code>Page</code> or a <code>User</code>. When the object in the <code>profiles</code> result is a <code>User</code>, <code>friends</code> will be present and <code>likers</code> will not. Conversely when the result is a <code>Page</code>, <code>likers</code> will be present and <code>friends</code> will not.</p><pre id="example-71e35" class="spec-example"><a href="#example-71e35">Example № 22</a><code><span class="token punctuation">{</span> <span class="token property">"profiles"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"handle"</span><span class="token operator">:</span> <span class="token string">"zuck"</span><span class="token punctuation">,</span> <span class="token property">"friends"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"count"</span> <span class="token operator">:</span> <span class="token number">1234</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token property">"handle"</span><span class="token operator">:</span> <span class="token string">"cocacola"</span><span class="token punctuation">,</span> <span class="token property">"likers"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"count"</span> <span class="token operator">:</span> <span class="token number">90234512</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Inline-Fragments" secid="2.8.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Inline-Fragments">2.8.2</a></span>Inline Fragments</h4><div class="spec-production" id="InlineFragment"><span class="spec-nt"><a href="#InlineFragment" data-name="InlineFragment">InlineFragment</a></span><div class="spec-rhs"><span class="spec-t">...</span><span class="spec-quantified"><span class="spec-nt"><a href="#TypeCondition" data-name="TypeCondition">TypeCondition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div></div><p>Fragments can be defined inline within a selection set. This is done to conditionally include fields based on their runtime type. This feature of standard fragment inclusion was demonstrated in the <code>query FragmentTyping</code> example. We could accomplish the same thing using inline fragments.</p><pre id="example-a6b78" class="spec-example"><a href="#example-a6b78">Example № 23</a><code><span class="token keyword">query</span> inlineFragmentTyping <span class="token punctuation">{</span> profiles<span class="token punctuation">(</span><span class="token attr-name">handles</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">"zuck"</span><span class="token punctuation">,</span> <span class="token string">"cocacola"</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> handle <span class="token operator">...</span> <span class="token keyword">on</span> User <span class="token punctuation">{</span> friends <span class="token punctuation">{</span> count <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token operator">...</span> <span class="token keyword">on</span> Page <span class="token punctuation">{</span> likers <span class="token punctuation">{</span> count <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Inline fragments may also be used to apply a directive to a group of fields. If the TypeCondition is omitted, an inline fragment is considered to be of the same type as the enclosing context.</p><pre id="example-77377" class="spec-example"><a href="#example-77377">Example № 24</a><code><span class="token keyword">query</span> inlineFragmentNoType<span class="token punctuation">(</span><span class="token variable">$expandedInfo</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">handle</span><span class="token punctuation">:</span> <span class="token string">"zuck"</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name <span class="token operator">...</span> <span class="token directive function">@include</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$expandedInfo</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> firstName lastName birthday <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Input-Values" secid="2.9"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Input-Values">2.9</a></span>Input Values</h3><div class="spec-production" id="Value"><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-condition not">Const</span><span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntValue" data-name="IntValue">IntValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FloatValue" data-name="FloatValue">FloatValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#BooleanValue" data-name="BooleanValue">BooleanValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#NullValue" data-name="NullValue">NullValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#EnumValue" data-name="EnumValue">EnumValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ListValue" data-name="ListValue">ListValue</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ObjectValue" data-name="ObjectValue">ObjectValue</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div></div><p>Field and directive arguments accept input values of various literal primitives; input values can be scalars, enumeration values, lists, or input objects.</p><p>If not defined as constant (for example, in <span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span>), input values can be specified as a variable. List and inputs objects may also contain variables (unless defined to be constant).</p><section id="sec-Int-Value" secid="2.9.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Int-Value">2.9.1</a></span>Int Value</h4><div class="spec-production d2" id="IntValue"><span class="spec-nt"><a href="#IntValue" data-name="IntValue">IntValue</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span></div></div><div class="spec-production d2" id="IntegerPart"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#NegativeSign" data-name="NegativeSign">NegativeSign</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">0</span></div><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#NegativeSign" data-name="NegativeSign">NegativeSign</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#NonZeroDigit" data-name="NonZeroDigit">NonZeroDigit</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production d2" id="NegativeSign"><span class="spec-nt"><a href="#NegativeSign" data-name="NegativeSign">NegativeSign</a></span><div class="spec-rhs"><span class="spec-t">-</span></div></div><div class="spec-production d2" id="Digit"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">0</span></td><td class="spec-rhs"><span class="spec-t">1</span></td><td class="spec-rhs"><span class="spec-t">2</span></td><td class="spec-rhs"><span class="spec-t">3</span></td><td class="spec-rhs"><span class="spec-t">4</span></td><td class="spec-rhs"><span class="spec-t">5</span></td><td class="spec-rhs"><span class="spec-t">6</span></td><td class="spec-rhs"><span class="spec-t">7</span></td><td class="spec-rhs"><span class="spec-t">8</span></td><td class="spec-rhs"><span class="spec-t">9</span></td></tr></table></div></div><div class="spec-production d2" id="NonZeroDigit"><span class="spec-nt"><a href="#NonZeroDigit" data-name="NonZeroDigit">NonZeroDigit</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-butnot"><span class="spec-t">0</span></span></span></div></div><p>An Int number is specified without a decimal point or exponent (ex. <code>1</code>).</p></section><section id="sec-Float-Value" secid="2.9.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Float-Value">2.9.2</a></span>Float Value</h4><div class="spec-production d2" id="FloatValue"><span class="spec-nt"><a href="#FloatValue" data-name="FloatValue">FloatValue</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><span class="spec-nt"><a href="#FractionalPart" data-name="FractionalPart">FractionalPart</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><span class="spec-nt"><a href="#ExponentPart" data-name="ExponentPart">ExponentPart</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><span class="spec-nt"><a href="#FractionalPart" data-name="FractionalPart">FractionalPart</a></span><span class="spec-nt"><a href="#ExponentPart" data-name="ExponentPart">ExponentPart</a></span></div></div><div class="spec-production d2" id="FractionalPart"><span class="spec-nt"><a href="#FractionalPart" data-name="FractionalPart">FractionalPart</a></span><div class="spec-rhs"><span class="spec-t">.</span><span class="spec-quantified"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production d2" id="ExponentPart"><span class="spec-nt"><a href="#ExponentPart" data-name="ExponentPart">ExponentPart</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ExponentIndicator" data-name="ExponentIndicator">ExponentIndicator</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Sign" data-name="Sign">Sign</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production d2" id="ExponentIndicator"><span class="spec-nt"><a href="#ExponentIndicator" data-name="ExponentIndicator">ExponentIndicator</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">e</span></td><td class="spec-rhs"><span class="spec-t">E</span></td></tr></table></div></div><div class="spec-production d2" id="Sign"><span class="spec-nt"><a href="#Sign" data-name="Sign">Sign</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">+</span></td><td class="spec-rhs"><span class="spec-t">-</span></td></tr></table></div></div><p>A Float number includes either a decimal point (ex. <code>1.0</code>) or an exponent (ex. <code>1e50</code>) or both (ex. <code>6.0221413e23</code>).</p></section><section id="sec-Boolean-Value" secid="2.9.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Boolean-Value">2.9.3</a></span>Boolean Value</h4><div class="spec-production" id="BooleanValue"><span class="spec-nt"><a href="#BooleanValue" data-name="BooleanValue">BooleanValue</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">true</span></td><td class="spec-rhs"><span class="spec-t">false</span></td></tr></table></div></div><p>The two keywords <code>true</code> and <code>false</code> represent the two boolean values.</p></section><section id="sec-String-Value" secid="2.9.4"><h4><span class="spec-secid" title="link to this section"><a href="#sec-String-Value">2.9.4</a></span>String Value</h4><div class="spec-production d2" id="StringValue"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span><div class="spec-rhs"><span class="spec-t">&quot;</span><span class="spec-quantified"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">&quot;</span></div><div class="spec-rhs"><span class="spec-t">&quot;&quot;&quot;</span><span class="spec-quantified"><span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">&quot;&quot;&quot;</span></div></div><div class="spec-production d2" id="StringCharacter"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-t">&quot;</span><span class="spec-t">\</span><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span></span></span></div><div class="spec-rhs"><span class="spec-t">\u</span><span class="spec-nt"><a href="#EscapedUnicode" data-name="EscapedUnicode">EscapedUnicode</a></span></div><div class="spec-rhs"><span class="spec-t">\</span><span class="spec-nt"><a href="#EscapedCharacter" data-name="EscapedCharacter">EscapedCharacter</a></span></div></div><div class="spec-production d2" id="EscapedUnicode"><span class="spec-nt"><a href="#EscapedUnicode" data-name="EscapedUnicode">EscapedUnicode</a></span><div class="spec-rhs"><span class="spec-rx">/[0-9A-Fa-f]{4}/</span></div></div><div class="spec-production d2" id="EscapedCharacter"><span class="spec-nt"><a href="#EscapedCharacter" data-name="EscapedCharacter">EscapedCharacter</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">&quot;</span></td><td class="spec-rhs"><span class="spec-t">\</span></td><td class="spec-rhs"><span class="spec-t">/</span></td><td class="spec-rhs"><span class="spec-t">b</span></td><td class="spec-rhs"><span class="spec-t">f</span></td><td class="spec-rhs"><span class="spec-t">n</span></td><td class="spec-rhs"><span class="spec-t">r</span></td><td class="spec-rhs"><span class="spec-t">t</span></td></tr></table></div></div><div class="spec-production d2" id="BlockStringCharacter"><span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-t">&quot;&quot;&quot;</span><span class="spec-t">\&quot;&quot;&quot;</span></span></span></div><div class="spec-rhs"><span class="spec-t">\&quot;&quot;&quot;</span></div></div><p>Strings are sequences of characters wrapped in double&#8208;quotes (<code>&quot;</code>). (ex. <code>&quot;Hello World&quot;</code>). White space and other otherwise&#8208;ignored characters are significant within a string value.</p><div class="spec-note">Unicode characters are allowed within String value literals, however <span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span> must not contain some ASCII control characters so escape sequences must be used to represent these characters.</div><p><strong>Block Strings</strong></p><p>Block strings are sequences of characters wrapped in triple&#8208;quotes (<code>&quot;&quot;&quot;</code>). White space, line terminators, quote, and backslash characters may all be used unescaped to enable verbatim text. Characters must all be valid <span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span>.</p><p>Since block strings represent freeform text often used in indented positions, the string value semantics of a block string excludes uniform indentation and blank initial and trailing lines via <span class="spec-call"><a href="#BlockStringValue()" data-name="BlockStringValue">BlockStringValue</a>()</span>.</p><p>For example, the following operation containing a block string:</p><pre id="example-fe73f" class="spec-example"><a href="#example-fe73f">Example № 25</a><code><span class="token keyword">mutation</span> <span class="token punctuation">{</span> sendEmail<span class="token punctuation">(</span><span class="token attr-name">message</span><span class="token punctuation">:</span> <span class="token string">""</span><span class="token string">" Hello, World! Yours, GraphQL. "</span><span class="token string">""</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>Is identical to the standard quoted string:</p><pre id="example-c6521" class="spec-example"><a href="#example-c6521">Example № 26</a><code><span class="token keyword">mutation</span> <span class="token punctuation">{</span> sendEmail<span class="token punctuation">(</span><span class="token attr-name">message</span><span class="token punctuation">:</span> <span class="token string">"Hello,\n World!\n\nYours,\n GraphQL."</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>Since block string values strip leading and trailing empty lines, there is no single canonical printed block string for a given value. Because block strings typically represent freeform text, it is considered easier to read if they begin and end with an empty line.</p><pre id="example-8e831" class="spec-example"><a href="#example-8e831">Example № 27</a><code><span class="token string">""</span><span class="token string">" This starts with and ends with an empty line, which makes it easier to read. "</span><span class="token string">""</span> </code></pre><pre id="example-b874e" class="spec-counter-example"><a href="#example-b874e">Counter Example № 28</a><code><span class="token string">""</span><span class="token string">"This does not start with or end with any empty lines, which makes it a little harder to read."</span><span class="token string">""</span> </code></pre><div class="spec-note">If non&#8208;printable ASCII characters are needed in a string value, a standard quoted string with appropriate escape sequences must be used instead of a block string.</div><p><strong>Semantics</strong></p><div class="spec-semantic d2"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span><div class="spec-rhs"><span class="spec-t">&quot;</span><span class="spec-quantified"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">&quot;</span></div><ol><li>Return the Unicode character sequence of all <span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span> Unicode character values (which may be an empty sequence).</li></ol></div><div class="spec-semantic d2"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-t">&quot;</span><span class="spec-t">\</span><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span></span></span></div><ol><li>Return the character value of <span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span>.</li></ol></div><div class="spec-semantic d2"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><div class="spec-rhs"><span class="spec-t">\u</span><span class="spec-nt"><a href="#EscapedUnicode" data-name="EscapedUnicode">EscapedUnicode</a></span></div><ol><li>Return the character whose code unit value in the Unicode Basic Multilingual Plane is the 16&#8208;bit hexadecimal value <span class="spec-nt"><a href="#EscapedUnicode" data-name="EscapedUnicode">EscapedUnicode</a></span>.</li></ol></div><div class="spec-semantic d2"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><div class="spec-rhs"><span class="spec-t">\</span><span class="spec-nt"><a href="#EscapedCharacter" data-name="EscapedCharacter">EscapedCharacter</a></span></div><ol><li>Return the character value of <span class="spec-nt"><a href="#EscapedCharacter" data-name="EscapedCharacter">EscapedCharacter</a></span> according to the table below.</li></ol></div><table><thead><tr><th>Escaped Character </th><th>Code Unit Value </th><th>Character Name </th></tr></thead><tbody><tr><td><code>&quot;</code> </td><td>U+0022 </td><td>double quote </td></tr><tr><td><code>\</code> </td><td>U+005C </td><td>reverse solidus (back slash) </td></tr><tr><td><code>/</code> </td><td>U+002F </td><td>solidus (forward slash) </td></tr><tr><td><code>b</code> </td><td>U+0008 </td><td>backspace </td></tr><tr><td><code>f</code> </td><td>U+000C </td><td>form feed </td></tr><tr><td><code>n</code> </td><td>U+000A </td><td>line feed (new line) </td></tr><tr><td><code>r</code> </td><td>U+000D </td><td>carriage return </td></tr><tr><td><code>t</code> </td><td>U+0009 </td><td>horizontal tab </td></tr></tbody></table><div class="spec-semantic d2"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span><div class="spec-rhs"><span class="spec-t">&quot;&quot;&quot;</span><span class="spec-quantified"><span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">&quot;&quot;&quot;</span></div><ol><li>Let <var data-name="rawValue">rawValue</var> be the Unicode character sequence of all <span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span> Unicode character values (which may be an empty sequence).</li><li>Return the result of <span class="spec-call"><a href="#BlockStringValue()" data-name="BlockStringValue">BlockStringValue</a>(<var data-name="rawValue">rawValue</var>)</span>.</li></ol></div><div class="spec-semantic d2"><span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-t">&quot;&quot;&quot;</span><span class="spec-t">\&quot;&quot;&quot;</span></span></span></div><ol><li>Return the character value of <span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span>.</li></ol></div><div class="spec-semantic d2"><span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span><div class="spec-rhs"><span class="spec-t">\&quot;&quot;&quot;</span></div><ol><li>Return the character sequence <code>&quot;&quot;&quot;</code>.</li></ol></div><div class="spec-algo" id="BlockStringValue()"><span class="spec-call"><a href="#BlockStringValue()" data-name="BlockStringValue">BlockStringValue</a>(<var data-name="rawValue">rawValue</var>)</span><ol><li>Let <var data-name="lines">lines</var> be the result of splitting <var data-name="rawValue">rawValue</var> by <span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span>.</li><li>Let <var data-name="commonIndent">commonIndent</var> be <span class="spec-keyword">null</span>.</li><li>For each <var data-name="line">line</var> in <var data-name="lines">lines</var>:<ol><li>If <var data-name="line">line</var> is the first item in <var data-name="lines">lines</var>, continue to the next line.</li><li>Let <var data-name="length">length</var> be the number of characters in <var data-name="line">line</var>.</li><li>Let <var data-name="indent">indent</var> be the number of leading consecutive <span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span> characters in <var data-name="line">line</var>.</li><li>If <var data-name="indent">indent</var> is less than <var data-name="length">length</var>:<ol><li>If <var data-name="commonIndent">commonIndent</var> is <span class="spec-keyword">null</span> or <var data-name="indent">indent</var> is less than <var data-name="commonIndent">commonIndent</var>:<ol><li>Let <var data-name="commonIndent">commonIndent</var> be <var data-name="indent">indent</var>.</li></ol></li></ol></li></ol></li><li>If <var data-name="commonIndent">commonIndent</var> is not <span class="spec-keyword">null</span>:<ol><li>For each <var data-name="line">line</var> in <var data-name="lines">lines</var>:<ol><li>If <var data-name="line">line</var> is the first item in <var data-name="lines">lines</var>, continue to the next line.</li><li>Remove <var data-name="commonIndent">commonIndent</var> characters from the beginning of <var data-name="line">line</var>.</li></ol></li></ol></li><li>While the first item <var data-name="line">line</var> in <var data-name="lines">lines</var> contains only <span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span>:<ol><li>Remove the first item from <var data-name="lines">lines</var>.</li></ol></li><li>While the last item <var data-name="line">line</var> in <var data-name="lines">lines</var> contains only <span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span>:<ol><li>Remove the last item from <var data-name="lines">lines</var>.</li></ol></li><li>Let <var data-name="formatted">formatted</var> be the empty character sequence.</li><li>For each <var data-name="line">line</var> in <var data-name="lines">lines</var>:<ol><li>If <var data-name="line">line</var> is the first item in <var data-name="lines">lines</var>:<ol><li>Append <var data-name="formatted">formatted</var> with <var data-name="line">line</var>.</li></ol></li><li>Otherwise:<ol><li>Append <var data-name="formatted">formatted</var> with a line feed character (U+000A).</li><li>Append <var data-name="formatted">formatted</var> with <var data-name="line">line</var>.</li></ol></li></ol></li><li>Return <var data-name="formatted">formatted</var>.</li></ol></div></section><section id="sec-Null-Value" secid="2.9.5"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Null-Value">2.9.5</a></span>Null Value</h4><div class="spec-production" id="NullValue"><span class="spec-nt"><a href="#NullValue" data-name="NullValue">NullValue</a></span><div class="spec-rhs"><span class="spec-t">null</span></div></div><p>Null values are represented as the keyword <span class="spec-keyword">null</span>.</p><p>GraphQL has two semantically different ways to represent the lack of a value:</p><ul><li>Explicitly providing the literal value: <span class="spec-keyword">null</span>.</li><li>Implicitly not providing a value at all.</li></ul><p>For example, these two field calls are similar, but are not identical:</p><pre id="example-1c7eb" class="spec-example"><a href="#example-1c7eb">Example № 29</a><code><span class="token punctuation">{</span> field<span class="token punctuation">(</span><span class="token attr-name">arg</span><span class="token punctuation">:</span> null<span class="token punctuation">)</span> field <span class="token punctuation">}</span> </code></pre><p>The first has explictly provided <span class="spec-keyword">null</span> to the argument &ldquo;arg&rdquo;, while the second has implicitly not provided a value to the argument &ldquo;arg&rdquo;. These two forms may be interpreted differently. For example, a mutation representing deleting a field vs not altering a field, respectively. Neither form may be used for an input expecting a Non&#8208;Null type.</p><div class="spec-note">The same two methods of representing the lack of a value are possible via variables by either providing the a variable value as <span class="spec-keyword">null</span> and not providing a variable value at all.</div></section><section id="sec-Enum-Value" secid="2.9.6"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Enum-Value">2.9.6</a></span>Enum Value</h4><div class="spec-production" id="EnumValue"><span class="spec-nt"><a href="#EnumValue" data-name="EnumValue">EnumValue</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-butnot"><span class="spec-t">true</span><span class="spec-t">false</span><span class="spec-t">null</span></span></span></div></div><p>Enum values are represented as unquoted names (ex. <code>MOBILE_WEB</code>). It is recommended that Enum values be &ldquo;all caps&rdquo;. Enum values are only used in contexts where the precise enumeration type is known. Therefore it&rsquo;s not necessary to supply an enumeration type name in the literal.</p></section><section id="sec-List-Value" secid="2.9.7"><h4><span class="spec-secid" title="link to this section"><a href="#sec-List-Value">2.9.7</a></span>List Value</h4><div class="spec-production" id="ListValue"><span class="spec-nt"><a href="#ListValue" data-name="ListValue">ListValue</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-t">]</span></div><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-quantified"><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">]</span></div></div><p>Lists are ordered sequences of values wrapped in square&#8208;brackets <code>[ ]</code>. The values of a List literal may be any value literal or variable (ex. <code>[1, 2, 3]</code>).</p><p>Commas are optional throughout GraphQL so trailing commas are allowed and repeated commas do not represent missing values.</p><p><strong>Semantics</strong></p><div class="spec-semantic"><span class="spec-nt"><a href="#ListValue" data-name="ListValue">ListValue</a></span><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-t">]</span></div><ol><li>Return a new empty list value.</li></ol></div><div class="spec-semantic"><span class="spec-nt"><a href="#ListValue" data-name="ListValue">ListValue</a></span><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-quantified"><span class="spec-nt"><a href="#Value" data-name="Value">Value</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">]</span></div><ol><li>Let <var data-name="inputList">inputList</var> be a new empty list value.</li><li>For each <span class="spec-quantified"><span class="spec-nt"><a href="#Value" data-name="Value">Value</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><ol><li>Let <var data-name="value">value</var> be the result of evaluating <span class="spec-nt"><a href="#Value" data-name="Value">Value</a></span>.</li><li>Append <var data-name="value">value</var> to <var data-name="inputList">inputList</var>.</li></ol></li><li>Return <var data-name="inputList">inputList</var></li></ol></div></section><section id="sec-Input-Object-Values" secid="2.9.8"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Input-Object-Values">2.9.8</a></span>Input Object Values</h4><div class="spec-production" id="ObjectValue"><span class="spec-nt"><a href="#ObjectValue" data-name="ObjectValue">ObjectValue</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-t">}</span></div><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="ObjectField"><span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div></div><p>Input object literal values are unordered lists of keyed input values wrapped in curly&#8208;braces <code>{ }</code>. The values of an object literal may be any input value literal or variable (ex. <code>{ name: &quot;Hello world&quot;, score: 1.0 }</code>). We refer to literal representation of input objects as &ldquo;object literals.&rdquo;</p><p><strong>Input object fields are unordered</strong></p><p>Input object fields may be provided in any syntactic order and maintain identical semantic meaning.</p><p>These two queries are semantically identical:</p><pre id="example-09646" class="spec-example"><a href="#example-09646">Example № 30</a><code><span class="token punctuation">{</span> nearestThing<span class="token punctuation">(</span><span class="token attr-name">location</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token attr-name">lon</span><span class="token punctuation">:</span> <span class="token number">12.43</span><span class="token punctuation">,</span> <span class="token attr-name">lat</span><span class="token punctuation">:</span> <span class="token number">-53.211</span> <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><pre id="example-6ebee" class="spec-example"><a href="#example-6ebee">Example № 31</a><code><span class="token punctuation">{</span> nearestThing<span class="token punctuation">(</span><span class="token attr-name">location</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token attr-name">lat</span><span class="token punctuation">:</span> <span class="token number">-53.211</span><span class="token punctuation">,</span> <span class="token attr-name">lon</span><span class="token punctuation">:</span> <span class="token number">12.43</span> <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p><strong>Semantics</strong></p><div class="spec-semantic"><span class="spec-nt"><a href="#ObjectValue" data-name="ObjectValue">ObjectValue</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-t">}</span></div><ol><li>Return a new input object value with no fields.</li></ol></div><div class="spec-semantic"><span class="spec-nt"><a href="#ObjectValue" data-name="ObjectValue">ObjectValue</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div><ol><li>Let <var data-name="inputObject">inputObject</var> be a new input object value with no fields.</li><li>For each <var data-name="field">field</var> in <span class="spec-quantified"><span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><ol><li>Let <var data-name="name">name</var> be <span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span> in <var data-name="field">field</var>.</li><li>Let <var data-name="value">value</var> be the result of evaluating <span class="spec-nt"><a href="#Value" data-name="Value">Value</a></span> in <var data-name="field">field</var>.</li><li>Add a field to <var data-name="inputObject">inputObject</var> of name <var data-name="name">name</var> containing value <var data-name="value">value</var>.</li></ol></li><li>Return <var data-name="inputObject">inputObject</var></li></ol></div></section></section><section id="sec-Language.Variables" secid="2.10"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Language.Variables">2.10</a></span>Variables</h3><div class="spec-production" id="Variable"><span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span><div class="spec-rhs"><span class="spec-t">$</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></div></div><div class="spec-production" id="VariableDefinitions"><span class="spec-nt"><a href="#VariableDefinitions" data-name="VariableDefinitions">VariableDefinitions</a></span><div class="spec-rhs"><span class="spec-t">(</span><span class="spec-quantified"><span class="spec-nt"><a href="#VariableDefinition" data-name="VariableDefinition">VariableDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">)</span></div></div><div class="spec-production" id="VariableDefinition"><span class="spec-nt"><a href="#VariableDefinition" data-name="VariableDefinition">VariableDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="DefaultValue"><span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span><div class="spec-rhs"><span class="spec-t">=</span><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><p>A GraphQL query can be parameterized with variables, maximizing query reuse, and avoiding costly string building in clients at runtime.</p><p>If not defined as constant (for example, in <span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span>), a <span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span> can be supplied for an input value.</p><p>Variables must be defined at the top of an operation and are in scope throughout the execution of that operation.</p><p>In this example, we want to fetch a profile picture size based on the size of a particular device:</p><pre id="example-7f690" class="spec-example"><a href="#example-7f690">Example № 32</a><code><span class="token keyword">query</span> getZuckProfile<span class="token punctuation">(</span><span class="token variable">$devicePicSize</span><span class="token punctuation">:</span> Int<span class="token punctuation">)</span> <span class="token punctuation">{</span> user<span class="token punctuation">(</span><span class="token attr-name">id</span><span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> id name profilePic<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token variable">$devicePicSize</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Values for those variables are provided to a GraphQL service along with a request so they may be substituted during execution. If providing JSON for the variables&rsquo; values, we could run this query and request profilePic of size <code>60</code> width:</p><pre id="example-98958" class="spec-example"><a href="#example-98958">Example № 33</a><code><span class="token punctuation">{</span> <span class="token property">"devicePicSize"</span><span class="token operator">:</span> <span class="token number">60</span> <span class="token punctuation">}</span> </code></pre><p><strong>Variable use within Fragments</strong></p><p>Query variables can be used within fragments. Query variables have global scope with a given operation, so a variable used within a fragment must be declared in any top&#8208;level operation that transitively consumes that fragment. If a variable is referenced in a fragment and is included by an operation that does not define that variable, the operation cannot be executed.</p></section><section id="sec-Type-References" secid="2.11"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Type-References">2.11</a></span>Type References</h3><div class="spec-production" id="Type"><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ListType" data-name="ListType">ListType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#NonNullType" data-name="NonNullType">NonNullType</a></span></div></div><div class="spec-production" id="NamedType"><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></div></div><div class="spec-production" id="ListType"><span class="spec-nt"><a href="#ListType" data-name="ListType">ListType</a></span><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-t">]</span></div></div><div class="spec-production" id="NonNullType"><span class="spec-nt"><a href="#NonNullType" data-name="NonNullType">NonNullType</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span><span class="spec-t">!</span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ListType" data-name="ListType">ListType</a></span><span class="spec-t">!</span></div></div><p>GraphQL describes the types of data expected by query variables. Input types may be lists of another input type, or a non&#8208;null variant of any other input type.</p><p><strong>Semantics</strong></p><div class="spec-semantic"><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></div><ol><li>Let <var data-name="name">name</var> be the string value of <span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></li><li>Let <var data-name="type">type</var> be the type defined in the Schema named <var data-name="name">name</var></li><li><var data-name="type">type</var> must not be <span class="spec-keyword">null</span></li><li>Return <var data-name="type">type</var></li></ol></div><div class="spec-semantic"><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-t">]</span></div><ol><li>Let <var data-name="itemType">itemType</var> be the result of evaluating <span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span></li><li>Let <var data-name="type">type</var> be a List type where <var data-name="itemType">itemType</var> is the contained type.</li><li>Return <var data-name="type">type</var></li></ol></div><div class="spec-semantic"><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-t">!</span></div><ol><li>Let <var data-name="nullableType">nullableType</var> be the result of evaluating <span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span></li><li>Let <var data-name="type">type</var> be a Non&#8208;Null type where <var data-name="nullableType">nullableType</var> is the contained type.</li><li>Return <var data-name="type">type</var></li></ol></div></section><section id="sec-Language.Directives" secid="2.12"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Language.Directives">2.12</a></span>Directives</h3><div class="spec-production" id="Directives"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Directive" data-name="Directive">Directive</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production" id="Directive"><span class="spec-nt"><a href="#Directive" data-name="Directive">Directive</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">@</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Arguments" data-name="Arguments">Arguments</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>Directives provide a way to describe alternate runtime execution and type validation behavior in a GraphQL document.</p><p>In some cases, you need to provide options to alter GraphQL&rsquo;s execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.</p><p>Directives have a name along with a list of arguments which may accept values of any input type.</p><p>Directives can be used to describe additional information for types, fields, fragments and operations.</p><p>As future versions of GraphQL adopt new configurable execution capabilities, they may be exposed via directives. </p></section></section><section id="sec-Type-System" secid="3"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Type-System">3</a></span>Type System</h2><p>The GraphQL Type system describes the capabilities of a GraphQL server and is used to determine if a query is valid. The type system also describes the input types of query variables to determine if values provided at runtime are valid.</p><div class="spec-production" id="TypeSystemDefinition"><span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#SchemaDefinition" data-name="SchemaDefinition">SchemaDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeDefinition" data-name="TypeDefinition">TypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#DirectiveDefinition" data-name="DirectiveDefinition">DirectiveDefinition</a></span></div></div><p>The GraphQL language includes an <a href="https://en.wikipedia.org/wiki/Interface_description_language">IDL</a> used to describe a GraphQL service&rsquo;s type system. Tools may use this definition language to provide utilities such as client code generation or service boot&#8208;strapping.</p><p>GraphQL tools which only seek to provide GraphQL query execution may choose not to parse <span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span>.</p><p>A GraphQL Document which contains <span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span> must not be executed; GraphQL execution services which receive a GraphQL Document containing type system definitions should return a descriptive error.</p><div class="spec-note">The type system definition language is used throughout the remainder of this specification document when illustrating example type systems.</div><section id="sec-Type-System-Extensions" secid="3.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Type-System-Extensions">3.1</a></span>Type System Extensions</h3><div class="spec-production" id="TypeSystemExtension"><span class="spec-nt"><a href="#TypeSystemExtension" data-name="TypeSystemExtension">TypeSystemExtension</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#SchemaExtension" data-name="SchemaExtension">SchemaExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeExtension" data-name="TypeExtension">TypeExtension</a></span></div></div><p>Type system extensions are used to represent a GraphQL type system which has been extended from some original type system. For example, this might be used by a local service to represent data a GraphQL client only accesses locally, or by a GraphQL service which is itself an extension of another GraphQL service.</p></section><section id="sec-Schema" secid="3.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Schema">3.2</a></span>Schema</h3><div class="spec-production" id="SchemaDefinition"><span class="spec-nt"><a href="#SchemaDefinition" data-name="SchemaDefinition">SchemaDefinition</a></span><div class="spec-rhs"><span class="spec-t">schema</span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#RootOperationTypeDefinition" data-name="RootOperationTypeDefinition">RootOperationTypeDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="RootOperationTypeDefinition"><span class="spec-nt"><a href="#RootOperationTypeDefinition" data-name="RootOperationTypeDefinition">RootOperationTypeDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#OperationType" data-name="OperationType">OperationType</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><p>A GraphQL service&rsquo;s collective type system capabilities are referred to as that service&rsquo;s &ldquo;schema&rdquo;. A schema is defined in terms of the types and directives it supports as well as the root operation types for each kind of operation: query, mutation, and subscription; this determines the place in the type system where those operations begin.</p><p>A GraphQL schema must itself be internally valid. This section describes the rules for this validation process where relevant.</p><p>All types within a GraphQL schema must have unique names. No two provided types may have the same name. No provided type may have a name which conflicts with any built in types (including Scalar and Introspection types).</p><p>All directives within a GraphQL schema must have unique names.</p><p>All types and directives defined within a schema must not have a name which begins with <span class="spec-string">"__"</span> (two underscores), as this is used exclusively by GraphQL&rsquo;s introspection system.</p><section id="sec-Root-Operation-Types" secid="3.2.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Root-Operation-Types">3.2.1</a></span>Root Operation Types</h4><p>A schema defines the initial root operation type for each kind of operation it supports: query, mutation, and subscription; this determines the place in the type system where those operations begin.</p><p>The <code>query</code> root operation type must be provided and must be an Object type.</p><p>The <code>mutation</code> root operation type is optional; if it is not provided, the service does not support mutations. If it is provided, it must be an Object type.</p><p>Similarly, the <code>subscription</code> root operation type is also optional; if it is not provided, the service does not support subscriptions. If it is provided, it must be an Object type.</p><p>The fields on the <code>query</code> root operation type indicate what fields are available at the top level of a GraphQL query. For example, a basic GraphQL query like:</p><pre id="example-081b4" class="spec-example"><a href="#example-081b4">Example № 34</a><code><span class="token keyword">query</span> <span class="token punctuation">{</span> myName <span class="token punctuation">}</span> </code></pre><p>Is valid when the <code>query</code> root operation type has a field named &ldquo;myName&rdquo;.</p><pre id="example-50137" class="spec-example"><a href="#example-50137">Example № 35</a><code>type Query <span class="token punctuation">{</span> <span class="token attr-name">myName</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> </code></pre><p>Similarly, the following mutation is valid if a <code>mutation</code> root operation type has a field named &ldquo;setName&rdquo;. Note that the <code>query</code> and <code>mutation</code> root types must be different types.</p><pre id="example-d1ed8" class="spec-example"><a href="#example-d1ed8">Example № 36</a><code><span class="token keyword">mutation</span> <span class="token punctuation">{</span> setName<span class="token punctuation">(</span><span class="token attr-name">name</span><span class="token punctuation">:</span> <span class="token string">"Zuck"</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> newName <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>When using the type system definition language, a document must include at most one <code>schema</code> definition.</p><p>In this example, a GraphQL schema is defined with both query and mutation root types:</p><pre id="example-e2969" class="spec-example"><a href="#example-e2969">Example № 37</a><code>schema <span class="token punctuation">{</span> <span class="token attr-name">query</span><span class="token punctuation">:</span> MyQueryRootType <span class="token attr-name">mutation</span><span class="token punctuation">:</span> MyMutationRootType <span class="token punctuation">}</span> type MyQueryRootType <span class="token punctuation">{</span> <span class="token attr-name">someField</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> type MyMutationRootType <span class="token punctuation">{</span> setSomeField<span class="token punctuation">(</span><span class="token attr-name">to</span><span class="token punctuation">:</span> String<span class="token punctuation">)</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> </code></pre><p><strong>Default Root Operation Type Names</strong></p><p>While any type can be the root operation type for a GraphQL operation, the type system definition language can omit the schema definition when the <code>query</code>, <code>mutation</code>, and <code>subscription</code> root types are named <code>Query</code>, <code>Mutation</code>, and <code>Subscription</code> respectively.</p><p>Likewise, when representing a GraphQL schema using the type system definition language, a schema definition should be omitted if it only uses the default root operation type names.</p><p>This example describes a valid complete GraphQL schema, despite not explicitly including a <code>schema</code> definition. The <code>Query</code> type is presumed to be the <code>query</code> root operation type of the schema.</p><pre id="example-9d70f" class="spec-example"><a href="#example-9d70f">Example № 38</a><code>type Query <span class="token punctuation">{</span> <span class="token attr-name">someField</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> </code></pre></section><section id="sec-Schema-Extension" secid="3.2.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Schema-Extension">3.2.2</a></span>Schema Extension</h4><div class="spec-production" id="SchemaExtension"><span class="spec-nt"><a href="#SchemaExtension" data-name="SchemaExtension">SchemaExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">schema</span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#OperationTypeDefinition" data-name="OperationTypeDefinition">OperationTypeDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">schema</span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><p>Schema extensions are used to represent a schema which has been extended from an original schema. For example, this might be used by a GraphQL service which adds additional operation types, or additional directives to an existing schema.</p><p><strong>Schema Validation</strong></p><p>Schema extensions have the potential to be invalid if incorrectly defined.</p><ol><li>The Schema must already be defined.</li><li>Any directives provided must not already apply to the original Schema.</li></ol></section></section><section id="sec-Descriptions" secid="3.3"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Descriptions">3.3</a></span>Descriptions</h3><div class="spec-production" id="Description"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span></div></div><p>Documentation is first&#8208;class feature of GraphQL type systems. To ensure the documentation of a GraphQL service remains consistent with its capabilities, descriptions of GraphQL definitions are provided alongside their definitions and made available via introspection.</p><p>To allow GraphQL service designers to easily publish documentation alongside the capabilities of a GraphQL service, GraphQL descriptions are defined using the Markdown syntax (as specified by <a href="http://commonmark.org/">CommonMark</a>). In the type system definition language, these description strings (often <span class="spec-nt"><span data-name="BlockString">BlockString</span></span>) occur immediately before the definition they describe.</p><p>All GraphQL types, fields, arguments and other definitions which can be described should provide a <span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span> unless they are considered self descriptive.</p><p>As an example, this simple GraphQL schema is well described:</p><pre id="example-64e5a" class="spec-example"><a href="#example-64e5a">Example № 39</a><code><span class="token string">""</span><span class="token string">" A simple GraphQL schema which is well described. "</span><span class="token string">""</span> type Query <span class="token punctuation">{</span> <span class="token string">""</span><span class="token string">" Translates a string from a given language into a different language. "</span><span class="token string">""</span> translate<span class="token punctuation">(</span> <span class="token string">"The original language that `text` is provided in."</span> <span class="token attr-name">fromLanguage</span><span class="token punctuation">:</span> Language <span class="token string">"The translated language to be returned."</span> <span class="token attr-name">toLanguage</span><span class="token punctuation">:</span> Language <span class="token string">"The text to be translated."</span> <span class="token attr-name">text</span><span class="token punctuation">:</span> String <span class="token punctuation">)</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> <span class="token string">""</span><span class="token string">" The set of languages supported by `translate`. "</span><span class="token string">""</span> enum Language <span class="token punctuation">{</span> <span class="token string">"English"</span> EN <span class="token string">"French"</span> FR <span class="token string">"Chinese"</span> CH <span class="token punctuation">}</span> </code></pre></section><section id="sec-Types" secid="3.4"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Types">3.4</a></span>Types</h3><div class="spec-production" id="TypeDefinition"><span class="spec-nt"><a href="#TypeDefinition" data-name="TypeDefinition">TypeDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ScalarTypeDefinition" data-name="ScalarTypeDefinition">ScalarTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ObjectTypeDefinition" data-name="ObjectTypeDefinition">ObjectTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InterfaceTypeDefinition" data-name="InterfaceTypeDefinition">InterfaceTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#UnionTypeDefinition" data-name="UnionTypeDefinition">UnionTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#EnumTypeDefinition" data-name="EnumTypeDefinition">EnumTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InputObjectTypeDefinition" data-name="InputObjectTypeDefinition">InputObjectTypeDefinition</a></span></div></div><p>The fundamental unit of any GraphQL Schema is the type. There are six kinds of named type definitions in GraphQL, and two wrapping types.</p><p>The most basic type is a <code>Scalar</code>. A scalar represents a primitive value, like a string or an integer. Oftentimes, the possible responses for a scalar field are enumerable. GraphQL offers an <code>Enum</code> type in those cases, where the type specifies the space of valid responses.</p><p>Scalars and Enums form the leaves in response trees; the intermediate levels are <code>Object</code> types, which define a set of fields, where each field is another type in the system, allowing the definition of arbitrary type hierarchies.</p><p>GraphQL supports two abstract types: interfaces and unions.</p><p>An <code>Interface</code> defines a list of fields; <code>Object</code> types that implement that interface are guaranteed to implement those fields. Whenever the type system claims it will return an interface, it will return a valid implementing type.</p><p>A <code>Union</code> defines a list of possible types; similar to interfaces, whenever the type system claims a union will be returned, one of the possible types will be returned.</p><p>Finally, oftentimes it is useful to provide complex structs as inputs to GraphQL field arguments or variables; the <code>Input Object</code> type allows the schema to define exactly what data is expected.</p><section id="sec-Wrapping-Types" secid="3.4.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Wrapping-Types">3.4.1</a></span>Wrapping Types</h4><p>All of the types so far are assumed to be both nullable and singular: e.g. a scalar string returns either null or a singular string.</p><p>A GraphQL schema may describe that a field represents list of another types; the <code>List</code> type is provided for this reason, and wraps another type.</p><p>Similarly, the <code>Non-Null</code> type wraps another type, and denotes that the resulting value will never be <span class="spec-keyword">null</span> (and that an error cannot result in a <span class="spec-keyword">null</span> value).</p><p>These two types are referred to as &ldquo;wrapping types&rdquo;; non&#8208;wrapping types are referred to as &ldquo;named types&rdquo;. A wrapping type has an underlying named type, found by continually unwrapping the type until a named type is found.</p></section><section id="sec-Input-and-Output-Types" secid="3.4.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Input-and-Output-Types">3.4.2</a></span>Input and Output Types</h4><p>Types are used throughout GraphQL to describe both the values accepted as input to arguments and variables as well as the values output by fields. These two uses categorize types as <em>input types</em> and <em>output types</em>. Some kinds of types, like Scalar and Enum types, can be used as both input types and output types; other kinds types can only be used in one or the other. Input Object types can only be used as input types. Object, Interface, and Union types can only be used as output types. Lists and Non&#8208;Null types may be used as input types or output types depending on how the wrapped type may be used.</p><div class="spec-algo" id="IsInputType()"><span class="spec-call"><a href="#IsInputType()" data-name="IsInputType">IsInputType</a>(<var data-name="type">type</var>)</span><ol><li>If <var data-name="type">type</var> is a List type or Non&#8208;Null type:<ol><li>Let <var data-name="unwrappedType">unwrappedType</var> be the unwrapped type of <var data-name="type">type</var>.</li><li>Return IsInputType(<var data-name="unwrappedType">unwrappedType</var>)</li></ol></li><li>If <var data-name="type">type</var> is a Scalar, Enum, or Input Object type:<ol><li>Return <span class="spec-keyword">true</span></li></ol></li><li>Return <span class="spec-keyword">false</span></li></ol></div><div class="spec-algo" id="IsOutputType()"><span class="spec-call"><a href="#IsOutputType()" data-name="IsOutputType">IsOutputType</a>(<var data-name="type">type</var>)</span><ol><li>If <var data-name="type">type</var> is a List type or Non&#8208;Null type:<ol><li>Let <var data-name="unwrappedType">unwrappedType</var> be the unwrapped type of <var data-name="type">type</var>.</li><li>Return IsOutputType(<var data-name="unwrappedType">unwrappedType</var>)</li></ol></li><li>If <var data-name="type">type</var> is a Scalar, Object, Interface, Union, or Enum type:<ol><li>Return <span class="spec-keyword">true</span></li></ol></li><li>Return <span class="spec-keyword">false</span></li></ol></div></section><section id="sec-Type-Extensions" secid="3.4.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Type-Extensions">3.4.3</a></span>Type Extensions</h4><div class="spec-production" id="TypeExtension"><span class="spec-nt"><a href="#TypeExtension" data-name="TypeExtension">TypeExtension</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ScalarTypeExtension" data-name="ScalarTypeExtension">ScalarTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ObjectTypeExtension" data-name="ObjectTypeExtension">ObjectTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InterfaceTypeExtension" data-name="InterfaceTypeExtension">InterfaceTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#UnionTypeExtension" data-name="UnionTypeExtension">UnionTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#EnumTypeExtension" data-name="EnumTypeExtension">EnumTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InputObjectTypeExtension" data-name="InputObjectTypeExtension">InputObjectTypeExtension</a></span></div></div><p>Type extensions are used to represent a GraphQL type which has been extended from some original type. For example, this might be used by a local service to represent additional fields a GraphQL client only accesses locally.</p></section></section><section id="sec-Scalars" secid="3.5"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Scalars">3.5</a></span>Scalars</h3><div class="spec-production" id="ScalarTypeDefinition"><span class="spec-nt"><a href="#ScalarTypeDefinition" data-name="ScalarTypeDefinition">ScalarTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">scalar</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>Scalar types represent primitive leaf values in a GraphQL type system. GraphQL responses take the form of a hierarchical tree; the leaves on these trees are GraphQL scalars.</p><p>All GraphQL scalars are representable as strings, though depending on the response format being used, there may be a more appropriate primitive for the given scalar type, and server should use those types when appropriate.</p><p>GraphQL provides a number of built&#8208;in scalars, but type systems can add additional scalars with semantic meaning. For example, a GraphQL system could define a scalar called <code>Time</code> which, while serialized as a string, promises to conform to ISO&#8208;8601. When querying a field of type <code>Time</code>, you can then rely on the ability to parse the result with an ISO&#8208;8601 parser and use a client&#8208;specific primitive for time. Another example of a potentially useful custom scalar is <code>Url</code>, which serializes as a string, but is guaranteed by the server to be a valid URL.</p><pre id="example-cb7e7" class="spec-example"><a href="#example-cb7e7">Example № 40</a><code>scalar Time scalar Url </code></pre><p>A server may omit any of the built&#8208;in scalars from its schema, for example if a schema does not refer to a floating&#8208;point number, then it must not include the <code>Float</code> type. However, if a schema includes a type with the name of one of the types described here, it must adhere to the behavior described. As an example, a server must not include a type called <code>Int</code> and use it to represent 128&#8208;bit numbers, internationalization information, or anything other than what is defined in this document.</p><p>When representing a GraphQL schema using the type system definition language, the built&#8208;in scalar types should be omitted for brevity.</p><p><strong>Result Coercion</strong></p><p>A GraphQL server, when preparing a field of a given scalar type, must uphold the contract the scalar type describes, either by coercing the value or producing a field error if a value cannot be coerced or if coercion may result in data loss.</p><p>A GraphQL service may decide to allow coercing different internal types to the expected return type. For example when coercing a field of type <code>Int</code> a boolean <code>true</code> value may produce <code>1</code> or a string value <code>&quot;123&quot;</code> may be parsed as base&#8208;10 <code>123</code>. However if internal type coercion cannot be reasonably performed without losing information, then it must raise a field error.</p><p>Since this coercion behavior is not observable to clients of the GraphQL server, the precise rules of coercion are left to the implementation. The only requirement is that the server must yield values which adhere to the expected Scalar type.</p><p><strong>Input Coercion</strong></p><p>If a GraphQL server expects a scalar type as input to an argument, coercion is observable and the rules must be well defined. If an input value does not match a coercion rule, a query error must be raised.</p><p>GraphQL has different constant literals to represent integer and floating&#8208;point input values, and coercion rules may apply differently depending on which type of input value is encountered. GraphQL may be parameterized by query variables, the values of which are often serialized when sent over a transport like HTTP. Since some common serializations (ex. JSON) do not discriminate between integer and floating&#8208;point values, they are interpreted as an integer input value if they have an empty fractional part (ex. <code>1.0</code>) and otherwise as floating&#8208;point input value.</p><p>For all types below, with the exception of Non&#8208;Null, if the explicit value <span class="spec-keyword">null</span> is provided, then the result of input coercion is <span class="spec-keyword">null</span>.</p><p><strong>Built&#8208;in Scalars</strong></p><p>GraphQL provides a basic set of well&#8208;defined Scalar types. A GraphQL server should support all of these types, and a GraphQL server which provide a type by these names must adhere to the behavior described below.</p><section id="sec-Int" secid="3.5.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Int">3.5.1</a></span>Int</h4><p>The Int scalar type represents a signed 32&#8208;bit numeric non&#8208;fractional value. Response formats that support a 32&#8208;bit integer or a number type should use that type to represent this scalar.</p><p><strong>Result Coercion</strong></p><p>Fields returning the type <code>Int</code> expect to encounter 32&#8208;bit integer internal values.</p><p>GraphQL servers may coerce non&#8208;integer internal values to integers when reasonable without losing information, otherwise they must raise a field error. Examples of this may include returning <code>1</code> for the floating&#8208;point number <code>1.0</code>, or returning <code>123</code> for the string <code>&quot;123&quot;</code>. In scenarios where coercion may lose data, raising a field error is more appropriate. For example, a floating&#8208;point number <code>1.2</code> should raise a field error instead of being truncated to <code>1</code>.</p><p>If the integer internal value represents a value less than -2<sup>31</sup> or greater than or equal to 2<sup>31</sup>, a field error should be raised.</p><p><strong>Input Coercion</strong></p><p>When expected as an input type, only integer input values are accepted. All other input values, including strings with numeric content, must raise a query error indicating an incorrect type. If the integer input value represents a value less than -2<sup>31</sup> or greater than or equal to 2<sup>31</sup>, a query error should be raised.</p><div class="spec-note">Numeric integer values larger than 32&#8208;bit should either use String or a custom&#8208;defined Scalar type, as not all platforms and transports support encoding integer numbers larger than 32&#8208;bit.</div></section><section id="sec-Float" secid="3.5.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Float">3.5.2</a></span>Float</h4><p>The Float scalar type represents signed double&#8208;precision fractional values as specified by <a href="http://en.wikipedia.org/wiki/IEEE_floating_point">IEEE 754</a>. Response formats that support an appropriate double&#8208;precision number type should use that type to represent this scalar.</p><p><strong>Result Coercion</strong></p><p>Fields returning the type <code>Float</code> expect to encounter double&#8208;precision floating&#8208;point internal values.</p><p>GraphQL servers may coerce non&#8208;floating&#8208;point internal values to <code>Float</code> when reasonable without losing information, otherwise they must raise a field error. Examples of this may include returning <code>1.0</code> for the integer number <code>1</code>, or <code>123.0</code> for the string <code>&quot;123&quot;</code>.</p><p><strong>Input Coercion</strong></p><p>When expected as an input type, both integer and float input values are accepted. Integer input values are coerced to Float by adding an empty fractional part, for example <code>1.0</code> for the integer input value <code>1</code>. All other input values, including strings with numeric content, must raise a query error indicating an incorrect type. If the integer input value represents a value not representable by IEEE 754, a query error should be raised.</p></section><section id="sec-String" secid="3.5.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-String">3.5.3</a></span>String</h4><p>The String scalar type represents textual data, represented as UTF&#8208;8 character sequences. The String type is most often used by GraphQL to represent free&#8208;form human&#8208;readable text. All response formats must support string representations, and that representation must be used here.</p><p><strong>Result Coercion</strong></p><p>Fields returning the type <code>String</code> expect to encounter UTF&#8208;8 string internal values.</p><p>GraphQL servers may coerce non&#8208;string raw values to <code>String</code> when reasonable without losing information, otherwise they must raise a field error. Examples of this may include returning the string <code>&quot;true&quot;</code> for a boolean true value, or the string <code>&quot;1&quot;</code> for the integer <code>1</code>.</p><p><strong>Input Coercion</strong></p><p>When expected as an input type, only valid UTF&#8208;8 string input values are accepted. All other input values must raise a query error indicating an incorrect type.</p></section><section id="sec-Boolean" secid="3.5.4"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Boolean">3.5.4</a></span>Boolean</h4><p>The Boolean scalar type represents <code>true</code> or <code>false</code>. Response formats should use a built&#8208;in boolean type if supported; otherwise, they should use their representation of the integers <code>1</code> and <code>0</code>.</p><p><strong>Result Coercion</strong></p><p>Fields returning the type <code>Boolean</code> expect to encounter boolean internal values.</p><p>GraphQL servers may coerce non&#8208;boolean raw values to <code>Boolean</code> when reasonable without losing information, otherwise they must raise a field error. Examples of this may include returning <code>true</code> for non&#8208;zero numbers.</p><p><strong>Input Coercion</strong></p><p>When expected as an input type, only boolean input values are accepted. All other input values must raise a query error indicating an incorrect type.</p></section><section id="sec-ID" secid="3.5.5"><h4><span class="spec-secid" title="link to this section"><a href="#sec-ID">3.5.5</a></span>ID</h4><p>The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a <code>String</code>; however, it is not intended to be human&#8208;readable. While it is often numeric, it should always serialize as a <code>String</code>.</p><p><strong>Result Coercion</strong></p><p>GraphQL is agnostic to ID format, and serializes to string to ensure consistency across many formats ID could represent, from small auto&#8208;increment numbers, to large 128&#8208;bit random numbers, to base64 encoded values, or string values of a format like <a href="http://en.wikipedia.org/wiki/Globally_unique_identifier">GUID</a>.</p><p>GraphQL servers should coerce as appropriate given the ID formats they expect. When coercion is not possible they must raise a field error.</p><p><strong>Input Coercion</strong></p><p>When expected as an input type, any string (such as <code>&quot;4&quot;</code>) or integer (such as <code>4</code>) input value should be coerced to ID as appropriate for the ID formats a given GraphQL server expects. Any other input value, including float input values (such as <code>4.0</code>), must raise a query error indicating an incorrect type.</p></section><section id="sec-Scalar-Extensions" secid="3.5.6"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Scalar-Extensions">3.5.6</a></span>Scalar Extensions</h4><div class="spec-production" id="ScalarTypeExtension"><span class="spec-nt"><a href="#ScalarTypeExtension" data-name="ScalarTypeExtension">ScalarTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">scalar</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><p>Scalar type extensions are used to represent a scalar type which has been extended from some original scalar type. For example, this might be used by a GraphQL tool or service which adds directives to an existing scalar.</p><p><strong>Type Validation</strong></p><p>Scalar type extensions have the potential to be invalid if incorrectly defined.</p><ol><li>The named type must already be defined and must be a Scalar type.</li><li>Any directives provided must not already apply to the original Scalar type.</li></ol></section></section><section id="sec-Objects" secid="3.6"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Objects">3.6</a></span>Objects</h3><div class="spec-production" id="ObjectTypeDefinition"><span class="spec-nt"><a href="#ObjectTypeDefinition" data-name="ObjectTypeDefinition">ObjectTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="ImplementsInterfaces"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><div class="spec-rhs"><span class="spec-t">implements</span><span class="spec-quantified"><span class="spec-t">&amp;</span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-t">&amp;</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><div class="spec-production" id="FieldsDefinition"><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#FieldDefinition" data-name="FieldDefinition">FieldDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="FieldDefinition"><span class="spec-nt"><a href="#FieldDefinition" data-name="FieldDefinition">FieldDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ArgumentsDefinition" data-name="ArgumentsDefinition">ArgumentsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>GraphQL queries are hierarchical and composed, describing a tree of information. While Scalar types describe the leaf values of these hierarchical queries, Objects describe the intermediate levels.</p><p>GraphQL Objects represent a list of named fields, each of which yield a value of a specific type. Object values should be serialized as ordered maps, where the queried field names (or aliases) are the keys and the result of evaluating the field is the value, ordered by the order in which they appear in the query.</p><p>All fields defined within an Object type must not have a name which begins with <span class="spec-string">"__"</span> (two underscores), as this is used exclusively by GraphQL&rsquo;s introspection system.</p><p>For example, a type <code>Person</code> could be described as:</p><pre id="example-ccb01" class="spec-example"><a href="#example-ccb01">Example № 41</a><code>type Person <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token attr-name">age</span><span class="token punctuation">:</span> Int <span class="token attr-name">picture</span><span class="token punctuation">:</span> Url <span class="token punctuation">}</span> </code></pre><p>Where <code>name</code> is a field that will yield a <code>String</code> value, and <code>age</code> is a field that will yield an <code>Int</code> value, and <code>picture</code> is a field that will yield a <code>Url</code> value.</p><p>A query of an object value must select at least one field. This selection of fields will yield an ordered map containing exactly the subset of the object queried, which should be represented in the order in which they were queried. Only fields that are declared on the object type may validly be queried on that object.</p><p>For example, selecting all the fields of <code>Person</code>:</p><pre id="example-1743a" class="spec-example"><a href="#example-1743a">Example № 42</a><code><span class="token punctuation">{</span> name age picture <span class="token punctuation">}</span> </code></pre><p>Would yield the object:</p><pre id="example-71184" class="spec-example"><a href="#example-71184">Example № 43</a><code><span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Mark Zuckerberg"</span><span class="token punctuation">,</span> <span class="token property">"age"</span><span class="token operator">:</span> <span class="token number">30</span><span class="token punctuation">,</span> <span class="token property">"picture"</span><span class="token operator">:</span> <span class="token string">"http://some.cdn/picture.jpg"</span> <span class="token punctuation">}</span> </code></pre><p>While selecting a subset of fields:</p><pre id="example-3964f" class="spec-example"><a href="#example-3964f">Example № 44</a><code><span class="token punctuation">{</span> age name <span class="token punctuation">}</span> </code></pre><p>Must only yield exactly that subset:</p><pre id="example-600a0" class="spec-example"><a href="#example-600a0">Example № 45</a><code><span class="token punctuation">{</span> <span class="token property">"age"</span><span class="token operator">:</span> <span class="token number">30</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Mark Zuckerberg"</span> <span class="token punctuation">}</span> </code></pre><p>A field of an Object type may be a Scalar, Enum, another Object type, an Interface, or a Union. Additionally, it may be any wrapping type whose underlying base type is one of those five.</p><p>For example, the <code>Person</code> type might include a <code>relationship</code>:</p><pre id="example-49198" class="spec-example"><a href="#example-49198">Example № 46</a><code>type Person <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token attr-name">age</span><span class="token punctuation">:</span> Int <span class="token attr-name">picture</span><span class="token punctuation">:</span> Url <span class="token attr-name">relationship</span><span class="token punctuation">:</span> Person <span class="token punctuation">}</span> </code></pre><p>Valid queries must supply a nested field set for a field that returns an object, so this query is not valid:</p><pre id="example-729a1" class="spec-counter-example"><a href="#example-729a1">Counter Example № 47</a><code><span class="token punctuation">{</span> name relationship <span class="token punctuation">}</span> </code></pre><p>However, this example is valid:</p><pre id="example-bb999" class="spec-example"><a href="#example-bb999">Example № 48</a><code><span class="token punctuation">{</span> name relationship <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>And will yield the subset of each object type queried:</p><pre id="example-352cc" class="spec-example"><a href="#example-352cc">Example № 49</a><code><span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Mark Zuckerberg"</span><span class="token punctuation">,</span> <span class="token property">"relationship"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Priscilla Chan"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p><strong>Field Ordering</strong></p><p>When querying an Object, the resulting mapping of fields are conceptually ordered in the same order in which they were encountered during query execution, excluding fragments for which the type does not apply and fields or fragments that are skipped via <code>@skip</code> or <code>@include</code> directives. This ordering is correctly produced when using the <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>()</span> algorithm.</p><p>Response serialization formats capable of representing ordered maps should maintain this ordering. Serialization formats which can only represent unordered maps (such as JSON) should retain this order textually. That is, if two fields <code>{foo, bar}</code> were queried in that order, the resulting JSON serialization should contain <code>{&quot;foo&quot;: &quot;...&quot;, &quot;bar&quot;: &quot;...&quot;}</code> in the same order.</p><p>Producing a response where fields are represented in the same order in which they appear in the request improves human readability during debugging and enables more efficient parsing of responses if the order of properties can be anticipated.</p><p>If a fragment is spread before other fields, the fields that fragment specifies occur in the response before the following fields.</p><pre id="example-7924b" class="spec-example"><a href="#example-7924b">Example № 50</a><code><span class="token punctuation">{</span> foo <span class="token operator">...</span>Frag qux <span class="token punctuation">}</span> <span class="token keyword">fragment</span> Frag on Query <span class="token punctuation">{</span> bar baz <span class="token punctuation">}</span> </code></pre><p>Produces the ordered result:</p><pre id="example-1455b" class="spec-example"><a href="#example-1455b">Example № 51</a><code><span class="token punctuation">{</span> <span class="token property">"foo"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token property">"bar"</span><span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token property">"baz"</span><span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token property">"qux"</span><span class="token operator">:</span> <span class="token number">4</span> <span class="token punctuation">}</span> </code></pre><p>If a field is queried multiple times in a selection, it is ordered by the first time it is encountered. However fragments for which the type does not apply does not affect ordering.</p><pre id="example-70ded" class="spec-example"><a href="#example-70ded">Example № 52</a><code><span class="token punctuation">{</span> foo <span class="token operator">...</span>Ignored <span class="token operator">...</span>Matching bar <span class="token punctuation">}</span> <span class="token keyword">fragment</span> Ignored on UnknownType <span class="token punctuation">{</span> qux baz <span class="token punctuation">}</span> <span class="token keyword">fragment</span> Matching on Query <span class="token punctuation">{</span> bar qux foo <span class="token punctuation">}</span> </code></pre><p>Produces the ordered result:</p><pre id="example-2e0e9" class="spec-example"><a href="#example-2e0e9">Example № 53</a><code><span class="token punctuation">{</span> <span class="token property">"foo"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token property">"bar"</span><span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token property">"qux"</span><span class="token operator">:</span> <span class="token number">3</span> <span class="token punctuation">}</span> </code></pre><p>Also, if directives result in fields being excluded, they are not considered in the ordering of fields.</p><pre id="example-50762" class="spec-example"><a href="#example-50762">Example № 54</a><code><span class="token punctuation">{</span> foo <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> bar foo <span class="token punctuation">}</span> </code></pre><p>Produces the ordered result:</p><pre id="example-dd904" class="spec-example"><a href="#example-dd904">Example № 55</a><code><span class="token punctuation">{</span> <span class="token property">"bar"</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token property">"foo"</span><span class="token operator">:</span> <span class="token number">2</span> <span class="token punctuation">}</span> </code></pre><p><strong>Result Coercion</strong></p><p>Determining the result of coercing an object is the heart of the GraphQL executor, so this is covered in that section of the spec.</p><p><strong>Input Coercion</strong></p><p>Objects are never valid inputs.</p><p><strong>Type Validation</strong></p><p>Object types have the potential to be invalid if incorrectly defined. This set of rules must be adhered to by every Object type in a GraphQL schema.</p><ol><li>An Object type must define one or more fields.</li><li>For each field of an Object type:<ol><li>The field must have a unique name within that Object type; no two fields may share the same name.</li><li>The field must not have a name which begins with the characters <span class="spec-string">"__"</span> (two underscores).</li><li>The field must return a type where <span class="spec-call"><a href="#IsOutputType()" data-name="IsOutputType">IsOutputType</a>(<var data-name="fieldType">fieldType</var>)</span> returns <span class="spec-keyword">true</span>.</li><li>For each argument of the field:<ol><li>The argument must not have a name which begins with the characters <span class="spec-string">"__"</span> (two underscores).</li><li>The argument must accept a type where <span class="spec-call"><a href="#IsInputType()" data-name="IsInputType">IsInputType</a>(<var data-name="argumentType">argumentType</var>)</span> returns <span class="spec-keyword">true</span>.</li></ol></li></ol></li><li>An object type may declare that it implements one or more unique interfaces.</li><li>An object type must be a super&#8208;set of all interfaces it implements:<ol><li>The object type must include a field of the same name for every field defined in an interface.<ol><li>The object field must be of a type which is equal to or a sub&#8208;type of the interface field (covariant).<ol><li>An object field type is a valid sub&#8208;type if it is equal to (the same type as) the interface field type.</li><li>An object field type is a valid sub&#8208;type if it is an Object type and the interface field type is either an Interface type or a Union type and the object field type is a possible type of the interface field type.</li><li>An object field type is a valid sub&#8208;type if it is a List type and the interface field type is also a List type and the list&#8208;item type of the object field type is a valid sub&#8208;type of the list&#8208;item type of the interface field type.</li><li>An object field type is a valid sub&#8208;type if it is a Non&#8208;Null variant of a valid sub&#8208;type of the interface field type.</li></ol></li><li>The object field must include an argument of the same name for every argument defined in the interface field.<ol><li>The object field argument must accept the same type (invariant) as the interface field argument.</li></ol></li><li>The object field may include additional arguments not defined in the interface field, but any additional argument must not be required, e.g. must not be of a non&#8208;nullable type.</li></ol></li></ol></li></ol><section id="sec-Field-Arguments" secid="3.6.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Field-Arguments">3.6.1</a></span>Field Arguments</h4><div class="spec-production" id="ArgumentsDefinition"><span class="spec-nt"><a href="#ArgumentsDefinition" data-name="ArgumentsDefinition">ArgumentsDefinition</a></span><div class="spec-rhs"><span class="spec-t">(</span><span class="spec-quantified"><span class="spec-nt"><a href="#InputValueDefinition" data-name="InputValueDefinition">InputValueDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">)</span></div></div><div class="spec-production" id="InputValueDefinition"><span class="spec-nt"><a href="#InputValueDefinition" data-name="InputValueDefinition">InputValueDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>Object fields are conceptually functions which yield values. Occasionally object fields can accept arguments to further specify the return value. Object field arguments are defined as a list of all possible argument names and their expected input types.</p><p>All arguments defined within a field must not have a name which begins with <span class="spec-string">"__"</span> (two underscores), as this is used exclusively by GraphQL&rsquo;s introspection system.</p><p>For example, a <code>Person</code> type with a <code>picture</code> field could accept an argument to determine what size of an image to return.</p><pre id="example-fb0d5" class="spec-example"><a href="#example-fb0d5">Example № 56</a><code>type Person <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String picture<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> Int<span class="token punctuation">)</span><span class="token punctuation">:</span> Url <span class="token punctuation">}</span> </code></pre><p>GraphQL queries can optionally specify arguments to their fields to provide these arguments.</p><p>This example query:</p><pre id="example-81f19" class="spec-example"><a href="#example-81f19">Example № 57</a><code><span class="token punctuation">{</span> name picture<span class="token punctuation">(</span><span class="token attr-name">size</span><span class="token punctuation">:</span> <span class="token number">600</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>May yield the result:</p><pre id="example-31f7a" class="spec-example"><a href="#example-31f7a">Example № 58</a><code><span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Mark Zuckerberg"</span><span class="token punctuation">,</span> <span class="token property">"picture"</span><span class="token operator">:</span> <span class="token string">"http://some.cdn/picture_600.jpg"</span> <span class="token punctuation">}</span> </code></pre><p>The type of an object field argument must be an input type (any type except an Object, Interface, or Union type).</p></section><section id="sec-Field-Deprecation" secid="3.6.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Field-Deprecation">3.6.2</a></span>Field Deprecation</h4><p>Fields in an object may be marked as deprecated as deemed necessary by the application. It is still legal to query for these fields (to ensure existing clients are not broken by the change), but the fields should be appropriately treated in documentation and tooling.</p><p>When using the type system definition language, <code>@deprecated</code> directives are used to indicate that a field is deprecated:</p><pre id="example-013ef" class="spec-example"><a href="#example-013ef">Example № 59</a><code>type ExampleType <span class="token punctuation">{</span> <span class="token attr-name">oldField</span><span class="token punctuation">:</span> String <span class="token directive function">@deprecated</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Object-Extensions" secid="3.6.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Object-Extensions">3.6.3</a></span>Object Extensions</h4><div class="spec-production" id="ObjectTypeExtension"><span class="spec-nt"><a href="#ObjectTypeExtension" data-name="ObjectTypeExtension">ObjectTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span></div></div><p>Object type extensions are used to represent a type which has been extended from some original type. For example, this might be used to represent local data, or by a GraphQL service which is itself an extension of another GraphQL service.</p><p>In this example, a local data field is added to a <code>Story</code> type:</p><pre id="example-8bda7" class="spec-example"><a href="#example-8bda7">Example № 60</a><code>extend type Story <span class="token punctuation">{</span> <span class="token attr-name">isHiddenLocally</span><span class="token punctuation">:</span> Boolean <span class="token punctuation">}</span> </code></pre><p>Object type extensions may choose not to add additional fields, instead only adding interfaces or directives.</p><p>In this example, a directive is added to a <code>User</code> type without adding fields:</p><pre id="example-605bd" class="spec-example"><a href="#example-605bd">Example № 61</a><code>extend type User <span class="token directive function">@addedDirective</span> </code></pre><p><strong>Type Validation</strong></p><p>Object type extensions have the potential to be invalid if incorrectly defined.</p><ol><li>The named type must already be defined and must be an Object type.</li><li>The fields of an Object type extension must have unique names; no two fields may share the same name.</li><li>Any fields of an Object type extension must not be already defined on the original Object type.</li><li>Any directives provided must not already apply to the original Object type.</li><li>Any interfaces provided must not be already implemented by the original Object type.</li><li>The resulting extended object type must be a super&#8208;set of all interfaces it implements.</li></ol></section></section><section id="sec-Interfaces" secid="3.7"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Interfaces">3.7</a></span>Interfaces</h3><div class="spec-production" id="InterfaceTypeDefinition"><span class="spec-nt"><a href="#InterfaceTypeDefinition" data-name="InterfaceTypeDefinition">InterfaceTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">interface</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>GraphQL interfaces represent a list of named fields and their arguments. GraphQL objects can then implement these interfaces which requires that the object type will define all fields defined by those interfaces.</p><p>Fields on a GraphQL interface have the same rules as fields on a GraphQL object; their type can be Scalar, Object, Enum, Interface, or Union, or any wrapping type whose base type is one of those five.</p><p>For example, an interface <code>NamedEntity</code> may describe a required field and types such as <code>Person</code> or <code>Business</code> may then implement this interface to guarantee this field will always exist.</p><p>Types may also implement multiple interfaces. For example, <code>Business</code> implements both the <code>NamedEntity</code> and <code>ValuedEntity</code> interfaces in the example below.</p><pre id="example-ab5e5" class="spec-example"><a href="#example-ab5e5">Example № 62</a><code>interface NamedEntity <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> interface ValuedEntity <span class="token punctuation">{</span> <span class="token attr-name">value</span><span class="token punctuation">:</span> Int <span class="token punctuation">}</span> type Person implements NamedEntity <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token attr-name">age</span><span class="token punctuation">:</span> Int <span class="token punctuation">}</span> type Business implements NamedEntity &amp; ValuedEntity <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token attr-name">value</span><span class="token punctuation">:</span> Int <span class="token attr-name">employeeCount</span><span class="token punctuation">:</span> Int <span class="token punctuation">}</span> </code></pre><p>Fields which yield an interface are useful when one of many Object types are expected, but some fields should be guaranteed.</p><p>To continue the example, a <code>Contact</code> might refer to <code>NamedEntity</code>.</p><pre id="example-00227" class="spec-example"><a href="#example-00227">Example № 63</a><code>type Contact <span class="token punctuation">{</span> <span class="token attr-name">entity</span><span class="token punctuation">:</span> NamedEntity <span class="token attr-name">phoneNumber</span><span class="token punctuation">:</span> String <span class="token attr-name">address</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> </code></pre><p>This allows us to write a query for a <code>Contact</code> that can select the common fields.</p><pre id="example-bc3fd" class="spec-example"><a href="#example-bc3fd">Example № 64</a><code><span class="token punctuation">{</span> entity <span class="token punctuation">{</span> name <span class="token punctuation">}</span> phoneNumber <span class="token punctuation">}</span> </code></pre><p>When querying for fields on an interface type, only those fields declared on the interface may be queried. In the above example, <code>entity</code> returns a <code>NamedEntity</code>, and <code>name</code> is defined on <code>NamedEntity</code>, so it is valid. However, the following would not be a valid query:</p><pre id="example-0c812" class="spec-counter-example"><a href="#example-0c812">Counter Example № 65</a><code><span class="token punctuation">{</span> entity <span class="token punctuation">{</span> name age <span class="token punctuation">}</span> phoneNumber <span class="token punctuation">}</span> </code></pre><p>because <code>entity</code> refers to a <code>NamedEntity</code>, and <code>age</code> is not defined on that interface. Querying for <code>age</code> is only valid when the result of <code>entity</code> is a <code>Person</code>; the query can express this using a fragment or an inline fragment:</p><pre id="example-5cc55" class="spec-example"><a href="#example-5cc55">Example № 66</a><code><span class="token punctuation">{</span> entity <span class="token punctuation">{</span> name <span class="token operator">...</span> <span class="token keyword">on</span> Person <span class="token punctuation">{</span> age <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> phoneNumber <span class="token punctuation">}</span> </code></pre><p><strong>Result Coercion</strong></p><p>The interface type should have some way of determining which object a given result corresponds to. Once it has done so, the result coercion of the interface is the same as the result coercion of the object.</p><p><strong>Input Coercion</strong></p><p>Interfaces are never valid inputs.</p><p><strong>Type Validation</strong></p><p>Interface types have the potential to be invalid if incorrectly defined.</p><ol><li>An Interface type must define one or more fields.</li><li>For each field of an Interface type:<ol><li>The field must have a unique name within that Interface type; no two fields may share the same name.</li><li>The field must not have a name which begins with the characters <span class="spec-string">"__"</span> (two underscores).</li><li>The field must return a type where <span class="spec-call"><a href="#IsOutputType()" data-name="IsOutputType">IsOutputType</a>(<var data-name="fieldType">fieldType</var>)</span> returns <span class="spec-keyword">true</span>.</li><li>For each argument of the field:<ol><li>The argument must not have a name which begins with the characters <span class="spec-string">"__"</span> (two underscores).</li><li>The argument must accept a type where <span class="spec-call"><a href="#IsInputType()" data-name="IsInputType">IsInputType</a>(<var data-name="argumentType">argumentType</var>)</span> returns <span class="spec-keyword">true</span>.</li></ol></li></ol></li></ol><section id="sec-Interface-Extensions" secid="3.7.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Interface-Extensions">3.7.1</a></span>Interface Extensions</h4><div class="spec-production" id="InterfaceTypeExtension"><span class="spec-nt"><a href="#InterfaceTypeExtension" data-name="InterfaceTypeExtension">InterfaceTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">interface</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">interface</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><p>Interface type extensions are used to represent an interface which has been extended from some original interface. For example, this might be used to represent common local data on many types, or by a GraphQL service which is itself an extension of another GraphQL service.</p><p>In this example, an extended data field is added to a <code>NamedEntity</code> type along with the types which implement it:</p><pre id="example-9d45f" class="spec-example"><a href="#example-9d45f">Example № 67</a><code>extend interface NamedEntity <span class="token punctuation">{</span> <span class="token attr-name">nickname</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> extend type Person <span class="token punctuation">{</span> <span class="token attr-name">nickname</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> extend type Business <span class="token punctuation">{</span> <span class="token attr-name">nickname</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> </code></pre><p>Interface type extensions may choose not to add additional fields, instead only adding directives.</p><p>In this example, a directive is added to a <code>NamedEntity</code> type without adding fields:</p><pre id="example-02d28" class="spec-example"><a href="#example-02d28">Example № 68</a><code>extend interface NamedEntity <span class="token directive function">@addedDirective</span> </code></pre><p><strong>Type Validation</strong></p><p>Interface type extensions have the potential to be invalid if incorrectly defined.</p><ol><li>The named type must already be defined and must be an Interface type.</li><li>The fields of an Interface type extension must have unique names; no two fields may share the same name.</li><li>Any fields of an Interface type extension must not be already defined on the original Interface type.</li><li>Any Object type which implemented the original Interface type must also be a super&#8208;set of the fields of the Interface type extension (which may be due to Object type extension).</li><li>Any directives provided must not already apply to the original Interface type.</li></ol></section></section><section id="sec-Unions" secid="3.8"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Unions">3.8</a></span>Unions</h3><div class="spec-production" id="UnionTypeDefinition"><span class="spec-nt"><a href="#UnionTypeDefinition" data-name="UnionTypeDefinition">UnionTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">union</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="UnionMemberTypes"><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span><div class="spec-rhs"><span class="spec-t">=</span><span class="spec-quantified"><span class="spec-t">|</span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span><span class="spec-t">|</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><p>GraphQL Unions represent an object that could be one of a list of GraphQL Object types, but provides for no guaranteed fields between those types. They also differ from interfaces in that Object types declare what interfaces they implement, but are not aware of what unions contain them.</p><p>With interfaces and objects, only those fields defined on the type can be queried directly; to query other fields on an interface, typed fragments must be used. This is the same as for unions, but unions do not define any fields, so <strong>no</strong> fields may be queried on this type without the use of type refining fragments or inline fragments.</p><p>For example, we might define the following types:</p><pre id="example-255de" class="spec-example"><a href="#example-255de">Example № 69</a><code>union SearchResult <span class="token operator">=</span> Photo | Person type Person <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token attr-name">age</span><span class="token punctuation">:</span> Int <span class="token punctuation">}</span> type Photo <span class="token punctuation">{</span> <span class="token attr-name">height</span><span class="token punctuation">:</span> Int <span class="token attr-name">width</span><span class="token punctuation">:</span> Int <span class="token punctuation">}</span> type SearchQuery <span class="token punctuation">{</span> <span class="token attr-name">firstSearchResult</span><span class="token punctuation">:</span> SearchResult <span class="token punctuation">}</span> </code></pre><p>When querying the <code>firstSearchResult</code> field of type <code>SearchQuery</code>, the query would ask for all fields inside of a fragment indicating the appropriate type. If the query wanted the name if the result was a Person, and the height if it was a photo, the following query is invalid, because the union itself defines no fields:</p><pre id="example-38dc1" class="spec-counter-example"><a href="#example-38dc1">Counter Example № 70</a><code><span class="token punctuation">{</span> firstSearchResult <span class="token punctuation">{</span> name height <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Instead, the query would be:</p><pre id="example-f8163" class="spec-example"><a href="#example-f8163">Example № 71</a><code><span class="token punctuation">{</span> firstSearchResult <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Person <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token operator">...</span> <span class="token keyword">on</span> Photo <span class="token punctuation">{</span> height <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Union members may be defined with an optional leading <code>|</code> character to aid formatting when representing a longer list of possible types:</p><pre id="example-0fbc6" class="spec-example"><a href="#example-0fbc6">Example № 72</a><code>union SearchResult <span class="token operator">=</span> | Photo | Person </code></pre><p><strong>Result Coercion</strong></p><p>The union type should have some way of determining which object a given result corresponds to. Once it has done so, the result coercion of the union is the same as the result coercion of the object.</p><p><strong>Input Coercion</strong></p><p>Unions are never valid inputs.</p><p><strong>Type Validation</strong></p><p>Union types have the potential to be invalid if incorrectly defined.</p><ol><li>A Union type must include one or more unique member types.</li><li>The member types of a Union type must all be Object base types; Scalar, Interface and Union types must not be member types of a Union. Similarly, wrapping types must not be member types of a Union.</li></ol><section id="sec-Union-Extensions" secid="3.8.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Union-Extensions">3.8.1</a></span>Union Extensions</h4><div class="spec-production" id="UnionTypeExtension"><span class="spec-nt"><a href="#UnionTypeExtension" data-name="UnionTypeExtension">UnionTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">union</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">union</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><p>Union type extensions are used to represent a union type which has been extended from some original union type. For example, this might be used to represent additional local data, or by a GraphQL service which is itself an extension of another GraphQL service.</p><p><strong>Type Validation</strong></p><p>Union type extensions have the potential to be invalid if incorrectly defined.</p><ol><li>The named type must already be defined and must be a Union type.</li><li>The member types of a Union type extension must all be Object base types; Scalar, Interface and Union types must not be member types of a Union. Similarly, wrapping types must not be member types of a Union.</li><li>All member types of a Union type extension must be unique.</li><li>All member types of a Union type extension must not already be a member of the original Union type.</li><li>Any directives provided must not already apply to the original Union type.</li></ol></section></section><section id="sec-Enums" secid="3.9"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Enums">3.9</a></span>Enums</h3><div class="spec-production" id="EnumTypeDefinition"><span class="spec-nt"><a href="#EnumTypeDefinition" data-name="EnumTypeDefinition">EnumTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">enum</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#EnumValuesDefinition" data-name="EnumValuesDefinition">EnumValuesDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="EnumValuesDefinition"><span class="spec-nt"><a href="#EnumValuesDefinition" data-name="EnumValuesDefinition">EnumValuesDefinition</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#EnumValueDefinition" data-name="EnumValueDefinition">EnumValueDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="EnumValueDefinition"><span class="spec-nt"><a href="#EnumValueDefinition" data-name="EnumValueDefinition">EnumValueDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#EnumValue" data-name="EnumValue">EnumValue</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>GraphQL Enum types, like scalar types, also represent leaf values in a GraphQL type system. However Enum types describe the set of possible values.</p><p>Enums are not references for a numeric value, but are unique values in their own right. They may serialize as a string: the name of the represented value.</p><p>In this example, an Enum type called <code>Direction</code> is defined:</p><pre id="example-36555" class="spec-example"><a href="#example-36555">Example № 73</a><code>enum Direction <span class="token punctuation">{</span> NORTH EAST SOUTH WEST <span class="token punctuation">}</span> </code></pre><p><strong>Result Coercion</strong></p><p>GraphQL servers must return one of the defined set of possible values. If a reasonable coercion is not possible they must raise a field error.</p><p><strong>Input Coercion</strong></p><p>GraphQL has a constant literal to represent enum input values. GraphQL string literals must not be accepted as an enum input and instead raise a query error.</p><p>Query variable transport serializations which have a different representation for non&#8208;string symbolic values (for example, <a href="https://github.com/edn-format/edn">EDN</a>) should only allow such values as enum input values. Otherwise, for most transport serializations that do not, strings may be interpreted as the enum input value with the same name.</p><p><strong>Type Validation</strong></p><p>Enum types have the potential to be invalid if incorrectly defined.</p><ol><li>An Enum type must define one or more unique enum values.</li></ol><section id="sec-Enum-Extensions" secid="3.9.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Enum-Extensions">3.9.1</a></span>Enum Extensions</h4><div class="spec-production" id="EnumTypeExtension"><span class="spec-nt"><a href="#EnumTypeExtension" data-name="EnumTypeExtension">EnumTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">enum</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#EnumValuesDefinition" data-name="EnumValuesDefinition">EnumValuesDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">enum</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><p>Enum type extensions are used to represent an enum type which has been extended from some original enum type. For example, this might be used to represent additional local data, or by a GraphQL service which is itself an extension of another GraphQL service.</p><p><strong>Type Validation</strong></p><p>Enum type extensions have the potential to be invalid if incorrectly defined.</p><ol><li>The named type must already be defined and must be an Enum type.</li><li>All values of an Enum type extension must be unique.</li><li>All values of an Enum type extension must not already be a value of the original Enum.</li><li>Any directives provided must not already apply to the original Enum type.</li></ol></section></section><section id="sec-Input-Objects" secid="3.10"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Input-Objects">3.10</a></span>Input Objects</h3><div class="spec-production" id="InputObjectTypeDefinition"><span class="spec-nt"><a href="#InputObjectTypeDefinition" data-name="InputObjectTypeDefinition">InputObjectTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">input</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#InputFieldsDefinition" data-name="InputFieldsDefinition">InputFieldsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="InputFieldsDefinition"><span class="spec-nt"><a href="#InputFieldsDefinition" data-name="InputFieldsDefinition">InputFieldsDefinition</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#InputValueDefinition" data-name="InputValueDefinition">InputValueDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><p>Fields may accept arguments to configure their behavior. These inputs are often scalars or enums, but they sometimes need to represent more complex values.</p><p>A GraphQL Input Object defines a set of input fields; the input fields are either scalars, enums, or other input objects. This allows arguments to accept arbitrarily complex structs.</p><p>In this example, an Input Object called <code>Point2D</code> describes <code>x</code> and <code>y</code> inputs:</p><pre id="example-45e4e" class="spec-example"><a href="#example-45e4e">Example № 74</a><code>input Point2D <span class="token punctuation">{</span> <span class="token attr-name">x</span><span class="token punctuation">:</span> Float <span class="token attr-name">y</span><span class="token punctuation">:</span> Float <span class="token punctuation">}</span> </code></pre><div class="spec-note">The GraphQL Object type (<span class="spec-nt"><a href="#ObjectTypeDefinition" data-name="ObjectTypeDefinition">ObjectTypeDefinition</a></span>) defined above is inappropriate for re&#8208;use here, because Object types can contain fields that define arguments or contain references to interfaces and unions, neither of which is appropriate for use as an input argument. For this reason, input objects have a separate type in the system.</div><p><strong>Result Coercion</strong></p><p>An input object is never a valid result. Input Object types cannot be the return type of an Object or Interface field.</p><p><strong>Input Coercion</strong></p><p>The value for an input object should be an input object literal or an unordered map supplied by a variable, otherwise a query error must be thrown. In either case, the input object literal or unordered map must not contain any entries with names not defined by a field of this input object type, otherwise an error must be thrown.</p><p>The result of coercion is an unordered map with an entry for each field both defined by the input object type and for which a value exists. The resulting map is constructed with the following rules:</p><ul><li>If no value is provided for a defined input object field and that field definition provides a default value, the default value should be used. If no default value is provided and the input object field&rsquo;s type is non&#8208;null, an error should be thrown. Otherwise, if the field is not required, then no entry is added to the coerced unordered map.</li><li>If the value <span class="spec-keyword">null</span> was provided for an input object field, and the field&rsquo;s type is not a non&#8208;null type, an entry in the coerced unordered map is given the value <span class="spec-keyword">null</span>. In other words, there is a semantic difference between the explicitly provided value <span class="spec-keyword">null</span> versus having not provided a value.</li><li>If a literal value is provided for an input object field, an entry in the coerced unordered map is given the result of coercing that value according to the input coercion rules for the type of that field.</li><li>If a variable is provided for an input object field, the runtime value of that variable must be used. If the runtime value is <span class="spec-keyword">null</span> and the field type is non&#8208;null, a field error must be thrown. If no runtime value is provided, the variable definition&rsquo;s default value should be used. If the variable definition does not provide a default value, the input object field definition&rsquo;s default value should be used.</li></ul><p>Following are examples of input coercion for an input object type with a <code>String</code> field <code>a</code> and a required (non&#8208;null) <code>Int!</code> field <code>b</code>:</p><pre id="example-704b8" class="spec-example"><a href="#example-704b8">Example № 75</a><code>input ExampleInputObject <span class="token punctuation">{</span> <span class="token attr-name">a</span><span class="token punctuation">:</span> String <span class="token attr-name">b</span><span class="token punctuation">:</span> Int<span class="token operator">!</span> <span class="token punctuation">}</span> </code></pre><table><thead><tr><th>Literal Value </th><th>Variables </th><th>Coerced Value</th></tr></thead><tbody><tr><td><code>{ a: &quot;abc&quot;, b: 123 }</code> </td><td><code>{}</code> </td><td><code>{ a: &quot;abc&quot;, b: 123 }</code></td></tr><tr><td><code>{ a: null, b: 123 }</code> </td><td><code>{}</code> </td><td><code>{ a: null, b: 123 }</code></td></tr><tr><td><code>{ b: 123 }</code> </td><td><code>{}</code> </td><td><code>{ b: 123 }</code></td></tr><tr><td><code>{ a: $var, b: 123 }</code> </td><td><code>{ var: null }</code> </td><td><code>{ a: null, b: 123 }</code></td></tr><tr><td><code>{ a: $var, b: 123 }</code> </td><td><code>{}</code> </td><td><code>{ b: 123 }</code></td></tr><tr><td><code>{ b: $var }</code> </td><td><code>{ var: 123 }</code> </td><td><code>{ b: 123 }</code></td></tr><tr><td><code>$var</code> </td><td><code>{ var: { b: 123 } }</code> </td><td><code>{ b: 123 }</code></td></tr><tr><td><code>&quot;abc123&quot;</code> </td><td><code>{}</code> </td><td>Error: Incorrect value</td></tr><tr><td><code>$var</code> </td><td><code>{ var: &quot;abc123&quot; } }</code> </td><td>Error: Incorrect value</td></tr><tr><td><code>{ a: &quot;abc&quot;, b: &quot;123&quot; }</code> </td><td><code>{}</code> </td><td>Error: Incorrect value for field <var data-name="b">b</var></td></tr><tr><td><code>{ a: &quot;abc&quot; }</code> </td><td><code>{}</code> </td><td>Error: Missing required field <var data-name="b">b</var></td></tr><tr><td><code>{ b: $var }</code> </td><td><code>{}</code> </td><td>Error: Missing required field <var data-name="b">b</var>.</td></tr><tr><td><code>$var</code> </td><td><code>{ var: { a: &quot;abc&quot; } }</code> </td><td>Error: Missing required field <var data-name="b">b</var></td></tr><tr><td><code>{ a: &quot;abc&quot;, b: null }</code> </td><td><code>{}</code> </td><td>Error: <var data-name="b">b</var> must be non&#8208;null.</td></tr><tr><td><code>{ b: $var }</code> </td><td><code>{ var: null }</code> </td><td>Error: <var data-name="b">b</var> must be non&#8208;null.</td></tr><tr><td><code>{ b: 123, c: &quot;xyz&quot; }</code> </td><td><code>{}</code> </td><td>Error: Unexpected field <var data-name="c">c</var></td></tr></tbody></table><p><strong>Type Validation</strong></p><ol><li>An Input Object type must define one or more input fields.</li><li>For each input field of an Input Object type:<ol><li>The input field must have a unique name within that Input Object type; no two input fields may share the same name.</li><li>The input field must not have a name which begins with the characters <span class="spec-string">"__"</span> (two underscores).</li><li>The input field must accept a type where <span class="spec-call"><a href="#IsInputType()" data-name="IsInputType">IsInputType</a>(<var data-name="inputFieldType">inputFieldType</var>)</span> returns <span class="spec-keyword">true</span>.</li></ol></li></ol><section id="sec-Input-Object-Extensions" secid="3.10.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Input-Object-Extensions">3.10.1</a></span>Input Object Extensions</h4><div class="spec-production" id="InputObjectTypeExtension"><span class="spec-nt"><a href="#InputObjectTypeExtension" data-name="InputObjectTypeExtension">InputObjectTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">input</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#InputFieldsDefinition" data-name="InputFieldsDefinition">InputFieldsDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">input</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><p>Input object type extensions are used to represent an input object type which has been extended from some original input object type. For example, this might be used by a GraphQL service which is itself an extension of another GraphQL service.</p><p><strong>Type Validation</strong></p><p>Input object type extensions have the potential to be invalid if incorrectly defined.</p><ol><li>The named type must already be defined and must be a Input Object type.</li><li>All fields of an Input Object type extension must have unique names.</li><li>All fields of an Input Object type extension must not already be a field of the original Input Object.</li><li>Any directives provided must not already apply to the original Input Object type.</li></ol></section></section><section id="sec-Type-System.List" secid="3.11"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Type-System.List">3.11</a></span>List</h3><p>A GraphQL list is a special collection type which declares the type of each item in the List (referred to as the <em>item type</em> of the list). List values are serialized as ordered lists, where each item in the list is serialized as per the item type. To denote that a field uses a List type the item type is wrapped in square brackets like this: <code>pets: [Pet]</code>.</p><p><strong>Result Coercion</strong></p><p>GraphQL servers must return an ordered list as the result of a list type. Each item in the list must be the result of a result coercion of the item type. If a reasonable coercion is not possible it must raise a field error. In particular, if a non&#8208;list is returned, the coercion should fail, as this indicates a mismatch in expectations between the type system and the implementation.</p><p>If a list&rsquo;s item type is nullable, then errors occuring during preparation or coercion of an individual item in the list must result in a the value <span class="spec-keyword">null</span> at that position in the list along with an error added to the response. If a list&rsquo;s item type is non&#8208;null, an error occuring at an individual item in the list must result in a field error for the entire list.</p><div class="spec-note">For more information on the error handling process, see &ldquo;Errors and Non&#8208;Nullability&rdquo; within the Execution section.</div><p><strong>Input Coercion</strong></p><p>When expected as an input, list values are accepted only when each item in the list can be accepted by the list&rsquo;s item type.</p><p>If the value passed as an input to a list type is <em>not</em> a list and not the <span class="spec-keyword">null</span> value, then the result of input coercion is a list of size one, where the single item value is the result of input coercion for the list&rsquo;s item type on the provided value (note this may apply recursively for nested lists).</p><p>This allow inputs which accept one or many arguments (sometimes referred to as &ldquo;var args&rdquo;) to declare their input type as a list while for the common case of a single value, a client can just pass that value directly rather than constructing the list.</p><p>Following are examples of input coercion with various list types and values:</p><table><thead><tr><th>Expected Type </th><th>Provided Value </th><th>Coerced Value</th></tr></thead><tbody><tr><td><code>[Int]</code> </td><td><code>[1, 2, 3]</code> </td><td><code>[1, 2, 3]</code></td></tr><tr><td><code>[Int]</code> </td><td><code>[1, &quot;b&quot;, true]</code> </td><td>Error: Incorrect item value</td></tr><tr><td><code>[Int]</code> </td><td><code>1</code> </td><td><code>[1]</code></td></tr><tr><td><code>[Int]</code> </td><td><code>null</code> </td><td><code>null</code></td></tr><tr><td><code>[[Int]]</code> </td><td><code>[[1], [2, 3]]</code> </td><td><code>[[1], [2, 3]</code></td></tr><tr><td><code>[[Int]]</code> </td><td><code>[1, 2, 3]</code> </td><td>Error: Incorrect item value</td></tr><tr><td><code>[[Int]]</code> </td><td><code>1</code> </td><td><code>[[1]]</code></td></tr><tr><td><code>[[Int]]</code> </td><td><code>null</code> </td><td><code>null</code></td></tr></tbody></table></section><section id="sec-Type-System.Non-Null" secid="3.12"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Type-System.Non-Null">3.12</a></span>Non-Null</h3><p>By default, all types in GraphQL are nullable; the <span class="spec-keyword">null</span> value is a valid response for all of the above types. To declare a type that disallows null, the GraphQL Non&#8208;Null type can be used. This type wraps an underlying type, and this type acts identically to that wrapped type, with the exception that <span class="spec-keyword">null</span> is not a valid response for the wrapping type. A trailing exclamation mark is used to denote a field that uses a Non&#8208;Null type like this: <code>name: String!</code>.</p><p><strong>Nullable vs. Optional</strong></p><p>Fields are <em>always</em> optional within the context of a query, a field may be omitted and the query is still valid. However fields that return Non&#8208;Null types will never return the value <span class="spec-keyword">null</span> if queried.</p><p>Inputs (such as field arguments), are always optional by default. However a non&#8208;null input type is required. In addition to not accepting the value <span class="spec-keyword">null</span>, it also does not accept omission. For the sake of simplicity nullable types are always optional and non&#8208;null types are always required.</p><p><strong>Result Coercion</strong></p><p>In all of the above result coercions, <span class="spec-keyword">null</span> was considered a valid value. To coerce the result of a Non&#8208;Null type, the coercion of the wrapped type should be performed. If that result was not <span class="spec-keyword">null</span>, then the result of coercing the Non&#8208;Null type is that result. If that result was <span class="spec-keyword">null</span>, then a field error must be raised.</p><div class="spec-note">When a field error is raised on a non&#8208;null value, the error propogates to the parent field. For more information on this process, see &ldquo;Errors and Non&#8208;Nullability&rdquo; within the Execution section.</div><p><strong>Input Coercion</strong></p><p>If an argument or input&#8208;object field of a Non&#8208;Null type is not provided, is provided with the literal value <span class="spec-keyword">null</span>, or is provided with a variable that was either not provided a value at runtime, or was provided the value <span class="spec-keyword">null</span>, then a query error must be raised.</p><p>If the value provided to the Non&#8208;Null type is provided with a literal value other than <span class="spec-keyword">null</span>, or a Non&#8208;Null variable value, it is coerced using the input coercion for the wrapped type.</p><p>A non&#8208;null argument cannot be omitted:</p><pre id="example-32bbf" class="spec-counter-example"><a href="#example-32bbf">Counter Example № 76</a><code><span class="token punctuation">{</span> fieldWithNonNullArg <span class="token punctuation">}</span> </code></pre><p>The value <span class="spec-keyword">null</span> cannot be provided to a non&#8208;null argument:</p><pre id="example-da489" class="spec-counter-example"><a href="#example-da489">Counter Example № 77</a><code><span class="token punctuation">{</span> fieldWithNonNullArg<span class="token punctuation">(</span><span class="token attr-name">nonNullArg</span><span class="token punctuation">:</span> null<span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>A variable of a nullable type cannot be provided to a non&#8208;null argument:</p><pre id="example-6d129" class="spec-example"><a href="#example-6d129">Example № 78</a><code><span class="token keyword">query</span> withNullableVariable<span class="token punctuation">(</span><span class="token variable">$var</span><span class="token punctuation">:</span> String<span class="token punctuation">)</span> <span class="token punctuation">{</span> fieldWithNonNullArg<span class="token punctuation">(</span><span class="token attr-name">nonNullArg</span><span class="token punctuation">:</span> <span class="token variable">$var</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><div class="spec-note">The Validation section defines providing a nullable variable type to a non&#8208;null input type as invalid.</div><p><strong>Type Validation</strong></p><ol><li>A Non&#8208;Null type must not wrap another Non&#8208;Null type.</li></ol><section id="sec-Combining-List-and-Non-Null" secid="3.12.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Combining-List-and-Non-Null">3.12.1</a></span>Combining List and Non-Null</h4><p>The List and Non&#8208;Null wrapping types can compose, representing more complex types. The rules for result coercion and input coercion of Lists and Non&#8208;Null types apply in a recursive fashion.</p><p>For example if the inner item type of a List is Non&#8208;Null (e.g. <code>[T!]</code>), then that List may not contain any <span class="spec-keyword">null</span> items. However if the inner type of a Non&#8208;Null is a List (e.g. <code>[T]!</code>), then <span class="spec-keyword">null</span> is not accepted however an empty list is accepted.</p><p>Following are examples of result coercion with various types and values:</p><table><thead><tr><th>Expected Type </th><th>Internal Value </th><th>Coerced Result</th></tr></thead><tbody><tr><td><code>[Int]</code> </td><td><code>[1, 2, 3]</code> </td><td><code>[1, 2, 3]</code></td></tr><tr><td><code>[Int]</code> </td><td><code>null</code> </td><td><code>null</code></td></tr><tr><td><code>[Int]</code> </td><td><code>[1, 2, null]</code> </td><td><code>[1, 2, null]</code></td></tr><tr><td><code>[Int]</code> </td><td><code>[1, 2, Error]</code> </td><td><code>[1, 2, null]</code> (With logged error)</td></tr><tr><td><code>[Int]!</code> </td><td><code>[1, 2, 3]</code> </td><td><code>[1, 2, 3]</code></td></tr><tr><td><code>[Int]!</code> </td><td><code>null</code> </td><td>Error: Value cannot be null</td></tr><tr><td><code>[Int]!</code> </td><td><code>[1, 2, null]</code> </td><td><code>[1, 2, null]</code></td></tr><tr><td><code>[Int]!</code> </td><td><code>[1, 2, Error]</code> </td><td><code>[1, 2, null]</code> (With logged error)</td></tr><tr><td><code>[Int!]</code> </td><td><code>[1, 2, 3]</code> </td><td><code>[1, 2, 3]</code></td></tr><tr><td><code>[Int!]</code> </td><td><code>null</code> </td><td><code>null</code></td></tr><tr><td><code>[Int!]</code> </td><td><code>[1, 2, null]</code> </td><td><code>null</code> (With logged coercion error)</td></tr><tr><td><code>[Int!]</code> </td><td><code>[1, 2, Error]</code> </td><td><code>null</code> (With logged error)</td></tr><tr><td><code>[Int!]!</code> </td><td><code>[1, 2, 3]</code> </td><td><code>[1, 2, 3]</code></td></tr><tr><td><code>[Int!]!</code> </td><td><code>null</code> </td><td>Error: Value cannot be null</td></tr><tr><td><code>[Int!]!</code> </td><td><code>[1, 2, null]</code> </td><td>Error: Item cannot be null</td></tr><tr><td><code>[Int!]!</code> </td><td><code>[1, 2, Error]</code> </td><td>Error: Error occurred in item</td></tr></tbody></table></section></section><section id="sec-Type-System.Directives" secid="3.13"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Type-System.Directives">3.13</a></span>Directives</h3><div class="spec-production" id="DirectiveDefinition"><span class="spec-nt"><a href="#DirectiveDefinition" data-name="DirectiveDefinition">DirectiveDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">directive</span><span class="spec-t">@</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ArgumentsDefinition" data-name="ArgumentsDefinition">ArgumentsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">on</span><span class="spec-nt"><a href="#DirectiveLocations" data-name="DirectiveLocations">DirectiveLocations</a></span></div></div><div class="spec-production" id="DirectiveLocations"><span class="spec-nt"><a href="#DirectiveLocations" data-name="DirectiveLocations">DirectiveLocations</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-t">|</span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#DirectiveLocation" data-name="DirectiveLocation">DirectiveLocation</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#DirectiveLocations" data-name="DirectiveLocations">DirectiveLocations</a></span><span class="spec-t">|</span><span class="spec-nt"><a href="#DirectiveLocation" data-name="DirectiveLocation">DirectiveLocation</a></span></div></div><div class="spec-production" id="DirectiveLocation"><span class="spec-nt"><a href="#DirectiveLocation" data-name="DirectiveLocation">DirectiveLocation</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ExecutableDirectiveLocation" data-name="ExecutableDirectiveLocation">ExecutableDirectiveLocation</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeSystemDirectiveLocation" data-name="TypeSystemDirectiveLocation">TypeSystemDirectiveLocation</a></span></div></div><div class="spec-production" id="ExecutableDirectiveLocation"><span class="spec-nt"><a href="#ExecutableDirectiveLocation" data-name="ExecutableDirectiveLocation">ExecutableDirectiveLocation</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">QUERY</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">MUTATION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">SUBSCRIPTION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FIELD</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FRAGMENT_DEFINITION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FRAGMENT_SPREAD</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INLINE_FRAGMENT</span></td></tr></table></div></div><div class="spec-production" id="TypeSystemDirectiveLocation"><span class="spec-nt"><a href="#TypeSystemDirectiveLocation" data-name="TypeSystemDirectiveLocation">TypeSystemDirectiveLocation</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">SCHEMA</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">SCALAR</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">OBJECT</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FIELD_DEFINITION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">ARGUMENT_DEFINITION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INTERFACE</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">UNION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">ENUM</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">ENUM_VALUE</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INPUT_OBJECT</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INPUT_FIELD_DEFINITION</span></td></tr></table></div></div><p>A GraphQL schema describes directives which are used to annotate various parts of a GraphQL document as an indicator that they should be evaluated differently by a validator, executor, or client tool such as a code generator.</p><p>GraphQL implementations should provide the <code>@skip</code> and <code>@include</code> directives.</p><p>GraphQL implementations that support the type system definition language must provide the <code>@deprecated</code> directive if representing deprecated portions of the schema.</p><p>Directives must only be used in the locations they are declared to belong in. In this example, a directive is defined which can be used to annotate a fragment definition:</p><pre id="example-060af" class="spec-example"><a href="#example-060af">Example № 79</a><code>directive <span class="token directive function">@example</span> on FIELD <span class="token keyword">fragment</span> SomeFragment on SomeType <span class="token punctuation">{</span> field <span class="token directive function">@example</span> <span class="token punctuation">}</span> </code></pre><p>Directive locations may be defined with an optional leading <code>|</code> character to aid formatting when representing a longer list of possible locations:</p><pre id="example-79697" class="spec-example"><a href="#example-79697">Example № 80</a><code>directive <span class="token directive function">@example</span> on | FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT </code></pre><p>Directives can also be used to annotate the type system definition language as well, which can be a useful tool for supplying additional metadata in order to generate GraphQL execution services, produce client generated runtime code, or many other useful extensions of the GraphQL semantics.</p><p>In this example, the directive <code>@example</code> annotates field and argument definitions:</p><pre id="example-c3a06" class="spec-example"><a href="#example-c3a06">Example № 81</a><code>directive <span class="token directive function">@example</span> on FIELD_DEFINITION | ARGUMENT_DEFINITION type SomeType <span class="token punctuation">{</span> field<span class="token punctuation">(</span><span class="token attr-name">arg</span><span class="token punctuation">:</span> Int <span class="token directive function">@example</span><span class="token punctuation">)</span><span class="token punctuation">:</span> String <span class="token directive function">@example</span> <span class="token punctuation">}</span> </code></pre><p>While defining a directive, it must not reference itself directly or indirectly:</p><pre id="example-79945" class="spec-counter-example"><a href="#example-79945">Counter Example № 82</a><code>directive <span class="token directive function">@invalidExample</span><span class="token punctuation">(</span><span class="token attr-name">arg</span><span class="token punctuation">:</span> String <span class="token directive function">@invalidExample</span><span class="token punctuation">)</span> on ARGUMENT_DEFINITION </code></pre><p><strong>Validation</strong></p><ol><li>A directive definition must not contain the use of a directive which references itself directly.</li><li>A directive definition must not contain the use of a directive which references itself indirectly by referencing a Type or Directive which transitively includes a reference to this directive.</li><li>The directive must not have a name which begins with the characters <span class="spec-string">"__"</span> (two underscores).</li><li>For each argument of the directive:<ol><li>The argument must not have a name which begins with the characters <span class="spec-string">"__"</span> (two underscores).</li><li>The argument must accept a type where <span class="spec-call"><a href="#IsInputType()" data-name="IsInputType">IsInputType</a>(<var data-name="argumentType">argumentType</var>)</span> returns <span class="spec-keyword">true</span>.</li></ol></li></ol><section id="sec--skip" secid="3.13.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec--skip">3.13.1</a></span>@skip</h4><pre><code>directive <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span><span class="token punctuation">)</span> on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT </code></pre><p>The <code>@skip</code> directive may be provided for fields, fragment spreads, and inline fragments, and allows for conditional exclusion during execution as described by the if argument.</p><p>In this example <code>experimentalField</code> will only be queried if the variable <code>$someTest</code> has the value <code>false</code>.</p><pre id="example-291f8" class="spec-example"><a href="#example-291f8">Example № 83</a><code><span class="token keyword">query</span> myQuery<span class="token punctuation">(</span><span class="token variable">$someTest</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> experimentalField <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$someTest</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec--include" secid="3.13.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec--include">3.13.2</a></span>@include</h4><pre><code>directive <span class="token directive function">@include</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span><span class="token punctuation">)</span> on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT </code></pre><p>The <code>@include</code> directive may be provided for fields, fragment spreads, and inline fragments, and allows for conditional inclusion during execution as described by the if argument.</p><p>In this example <code>experimentalField</code> will only be queried if the variable <code>$someTest</code> has the value <code>true</code></p><pre id="example-082ba" class="spec-example"><a href="#example-082ba">Example № 84</a><code><span class="token keyword">query</span> myQuery<span class="token punctuation">(</span><span class="token variable">$someTest</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> experimentalField <span class="token directive function">@include</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$someTest</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><div class="spec-note">Neither <code>@skip</code> nor <code>@include</code> has precedence over the other. In the case that both the <code>@skip</code> and <code>@include</code> directives are provided in on the same the field or fragment, it <em>must</em> be queried only if the <code>@skip</code> condition is false <em>and</em> the <code>@include</code> condition is true. Stated conversely, the field or fragment must <em>not</em> be queried if either the <code>@skip</code> condition is true <em>or</em> the <code>@include</code> condition is false.</div></section><section id="sec--deprecated" secid="3.13.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec--deprecated">3.13.3</a></span>@deprecated</h4><pre><code>directive <span class="token directive function">@deprecated</span><span class="token punctuation">(</span> <span class="token attr-name">reason</span><span class="token punctuation">:</span> String <span class="token operator">=</span> <span class="token string">"No longer supported"</span> <span class="token punctuation">)</span> on FIELD_DEFINITION | ENUM_VALUE </code></pre><p>The <code>@deprecated</code> directive is used within the type system definition language to indicate deprecated portions of a GraphQL service&rsquo;s schema, such as deprecated fields on a type or deprecated enum values.</p><p>Deprecations include a reason for why it is deprecated, which is formatted using Markdown syntax (as specified by <a href="http://commonmark.org/">CommonMark</a>).</p><p>In this example type definition, <code>oldField</code> is deprecated in favor of using <code>newField</code>.</p><pre id="example-d0cdc" class="spec-example"><a href="#example-d0cdc">Example № 85</a><code>type ExampleType <span class="token punctuation">{</span> <span class="token attr-name">newField</span><span class="token punctuation">:</span> String <span class="token attr-name">oldField</span><span class="token punctuation">:</span> String <span class="token directive function">@deprecated</span><span class="token punctuation">(</span><span class="token attr-name">reason</span><span class="token punctuation">:</span> <span class="token string">"Use `newField`."</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section></section></section><section id="sec-Introspection" secid="4"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Introspection">4</a></span>Introspection</h2><p>A GraphQL server supports introspection over its schema. This schema is queried using GraphQL itself, creating a powerful platform for tool&#8208;building.</p><p>Take an example query for a trivial app. In this case there is a User type with three fields: id, name, and birthday.</p><p>For example, given a server with the following type definition:</p><pre id="example-3005e" class="spec-example"><a href="#example-3005e">Example № 86</a><code>type User <span class="token punctuation">{</span> <span class="token attr-name">id</span><span class="token punctuation">:</span> String <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token attr-name">birthday</span><span class="token punctuation">:</span> Date <span class="token punctuation">}</span> </code></pre><p>The query</p><pre id="example-2efd3" class="spec-example"><a href="#example-2efd3">Example № 87</a><code><span class="token punctuation">{</span> __type<span class="token punctuation">(</span><span class="token attr-name">name</span><span class="token punctuation">:</span> <span class="token string">"User"</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> name fields <span class="token punctuation">{</span> name type <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>would return</p><pre id="example-00283" class="spec-example"><a href="#example-00283">Example № 88</a><code><span class="token punctuation">{</span> <span class="token property">"__type"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"User"</span><span class="token punctuation">,</span> <span class="token property">"fields"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"id"</span><span class="token punctuation">,</span> <span class="token property">"type"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"String"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"name"</span><span class="token punctuation">,</span> <span class="token property">"type"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"String"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"birthday"</span><span class="token punctuation">,</span> <span class="token property">"type"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Date"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><section id="sec-Reserved-Names" secid="4.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Reserved-Names">4.1</a></span>Reserved Names</h3><p>Types and fields required by the GraphQL introspection system that are used in the same context as user&#8208;defined types and fields are prefixed with <span class="spec-string">"__"</span> two underscores. This in order to avoid naming collisions with user&#8208;defined GraphQL types. Conversely, GraphQL type system authors must not define any types, fields, arguments, or any other type system artifact with two leading underscores.</p></section><section id="sec-Documentation" secid="4.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Documentation">4.2</a></span>Documentation</h3><p>All types in the introspection system provide a <code>description</code> field of type <code>String</code> to allow type designers to publish documentation in addition to capabilities. A GraphQL server may return the <code>description</code> field using Markdown syntax (as specified by <a href="http://commonmark.org/">CommonMark</a>). Therefore it is recommended that any tool that displays <code>description</code> use a CommonMark&#8208;compliant Markdown renderer.</p></section><section id="sec-Deprecation" secid="4.3"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Deprecation">4.3</a></span>Deprecation</h3><p>To support the management of backwards compatibility, GraphQL fields and enum values can indicate whether or not they are deprecated (<code>isDeprecated: Boolean</code>) and a description of why it is deprecated (<code>deprecationReason: String</code>).</p><p>Tools built using GraphQL introspection should respect deprecation by discouraging deprecated use through information hiding or developer&#8208;facing warnings.</p></section><section id="sec-Type-Name-Introspection" secid="4.4"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Type-Name-Introspection">4.4</a></span>Type Name Introspection</h3><p>GraphQL supports type name introspection at any point within a query by the meta&#8208;field <code>__typename: String!</code> when querying against any Object, Interface, or Union. It returns the name of the object type currently being queried.</p><p>This is most often used when querying against Interface or Union types to identify which actual type of the possible types has been returned.</p><p>This field is implicit and does not appear in the fields list in any defined type.</p></section><section id="sec-Schema-Introspection" secid="4.5"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Schema-Introspection">4.5</a></span>Schema Introspection</h3><p>The schema introspection system is accessible from the meta&#8208;fields <code>__schema</code> and <code>__type</code> which are accessible from the type of the root of a query operation.</p><pre><code><span class="token attr-name">__schema</span><span class="token punctuation">:</span> __Schema<span class="token operator">!</span> __type<span class="token punctuation">(</span><span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span><span class="token punctuation">)</span><span class="token punctuation">:</span> __Type </code></pre><p>These fields are implicit and do not appear in the fields list in the root type of the query operation.</p><p>The schema of the GraphQL schema introspection system:</p><pre><code>type __Schema <span class="token punctuation">{</span> <span class="token attr-name">types</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__Type<span class="token operator">!</span><span class="token punctuation">]</span><span class="token operator">!</span> <span class="token attr-name">queryType</span><span class="token punctuation">:</span> __Type<span class="token operator">!</span> <span class="token attr-name">mutationType</span><span class="token punctuation">:</span> __Type <span class="token attr-name">subscriptionType</span><span class="token punctuation">:</span> __Type <span class="token attr-name">directives</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__Directive<span class="token operator">!</span><span class="token punctuation">]</span><span class="token operator">!</span> <span class="token punctuation">}</span> type __Type <span class="token punctuation">{</span> <span class="token attr-name">kind</span><span class="token punctuation">:</span> __TypeKind<span class="token operator">!</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String <span class="token attr-name">description</span><span class="token punctuation">:</span> String <span class="token comment" spellcheck="true"># OBJECT and INTERFACE only</span> fields<span class="token punctuation">(</span><span class="token attr-name">includeDeprecated</span><span class="token punctuation">:</span> Boolean <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__Field<span class="token operator">!</span><span class="token punctuation">]</span> <span class="token comment" spellcheck="true"># OBJECT only</span> <span class="token attr-name">interfaces</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__Type<span class="token operator">!</span><span class="token punctuation">]</span> <span class="token comment" spellcheck="true"># INTERFACE and UNION only</span> <span class="token attr-name">possibleTypes</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__Type<span class="token operator">!</span><span class="token punctuation">]</span> <span class="token comment" spellcheck="true"># ENUM only</span> enumValues<span class="token punctuation">(</span><span class="token attr-name">includeDeprecated</span><span class="token punctuation">:</span> Boolean <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__EnumValue<span class="token operator">!</span><span class="token punctuation">]</span> <span class="token comment" spellcheck="true"># INPUT_OBJECT only</span> <span class="token attr-name">inputFields</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__InputValue<span class="token operator">!</span><span class="token punctuation">]</span> <span class="token comment" spellcheck="true"># NON_NULL and LIST only</span> <span class="token attr-name">ofType</span><span class="token punctuation">:</span> __Type <span class="token punctuation">}</span> type __Field <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token attr-name">description</span><span class="token punctuation">:</span> String <span class="token attr-name">args</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__InputValue<span class="token operator">!</span><span class="token punctuation">]</span><span class="token operator">!</span> <span class="token attr-name">type</span><span class="token punctuation">:</span> __Type<span class="token operator">!</span> <span class="token attr-name">isDeprecated</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> <span class="token attr-name">deprecationReason</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> type __InputValue <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token attr-name">description</span><span class="token punctuation">:</span> String <span class="token attr-name">type</span><span class="token punctuation">:</span> __Type<span class="token operator">!</span> <span class="token attr-name">defaultValue</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> type __EnumValue <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token attr-name">description</span><span class="token punctuation">:</span> String <span class="token attr-name">isDeprecated</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> <span class="token attr-name">deprecationReason</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> enum __TypeKind <span class="token punctuation">{</span> SCALAR OBJECT INTERFACE UNION ENUM INPUT_OBJECT LIST NON_NULL <span class="token punctuation">}</span> type __Directive <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token attr-name">description</span><span class="token punctuation">:</span> String <span class="token attr-name">locations</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__DirectiveLocation<span class="token operator">!</span><span class="token punctuation">]</span><span class="token operator">!</span> <span class="token attr-name">args</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>__InputValue<span class="token operator">!</span><span class="token punctuation">]</span><span class="token operator">!</span> <span class="token punctuation">}</span> enum __DirectiveLocation <span class="token punctuation">{</span> QUERY MUTATION SUBSCRIPTION FIELD FRAGMENT_DEFINITION FRAGMENT_SPREAD INLINE_FRAGMENT SCHEMA SCALAR OBJECT FIELD_DEFINITION ARGUMENT_DEFINITION INTERFACE UNION ENUM ENUM_VALUE INPUT_OBJECT INPUT_FIELD_DEFINITION <span class="token punctuation">}</span> </code></pre><section id="sec-The-__Type-Type" secid="4.5.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-The-__Type-Type">4.5.1</a></span>The __Type Type</h4><p><code>__Type</code> is at the core of the type introspection system. It represents scalars, interfaces, object types, unions, enums in the system.</p><p><code>__Type</code> also represents type modifiers, which are used to modify a type that it refers to (<code>ofType: __Type</code>). This is how we represent lists, non&#8208;nullable types, and the combinations thereof.</p></section><section id="sec-Type-Kinds" secid="4.5.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Type-Kinds">4.5.2</a></span>Type Kinds</h4><p>There are several different kinds of type. In each kind, different fields are actually valid. These kinds are listed in the <code>__TypeKind</code> enumeration.</p><section id="sec-Scalar" secid="4.5.2.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Scalar">4.5.2.1</a></span>Scalar</h5><p>Represents scalar types such as Int, String, and Boolean. Scalars cannot have fields.</p><p>A GraphQL type designer should describe the data format and scalar coercion rules in the description field of any scalar.</p><p>Fields</p><ul><li><code>kind</code> must return <code>__TypeKind.SCALAR</code>.</li><li><code>name</code> must return a String.</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span>.</li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-Object" secid="4.5.2.2"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Object">4.5.2.2</a></span>Object</h5><p>Object types represent concrete instantiations of sets of fields. The introspection types (e.g. <code>__Type</code>, <code>__Field</code>, etc) are examples of objects.</p><p>Fields</p><ul><li><code>kind</code> must return <code>__TypeKind.OBJECT</code>.</li><li><code>name</code> must return a String.</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span>.</li><li><code>fields</code>: The set of fields query&#8208;able on this type.<ul><li>Accepts the argument <code>includeDeprecated</code> which defaults to <span class="spec-keyword">false</span>. If <span class="spec-keyword">true</span>, deprecated fields are also returned.</li></ul></li><li><code>interfaces</code>: The set of interfaces that an object implements.</li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-Union" secid="4.5.2.3"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Union">4.5.2.3</a></span>Union</h5><p>Unions are an abstract type where no common fields are declared. The possible types of a union are explicitly listed out in <code>possibleTypes</code>. Types can be made parts of unions without modification of that type.</p><p>Fields</p><ul><li><code>kind</code> must return <code>__TypeKind.UNION</code>.</li><li><code>name</code> must return a String.</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span>.</li><li><code>possibleTypes</code> returns the list of types that can be represented within this union. They must be object types.</li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-Interface" secid="4.5.2.4"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Interface">4.5.2.4</a></span>Interface</h5><p>Interfaces are an abstract type where there are common fields declared. Any type that implements an interface must define all the fields with names and types exactly matching. The implementations of this interface are explicitly listed out in <code>possibleTypes</code>.</p><p>Fields</p><ul><li><code>kind</code> must return <code>__TypeKind.INTERFACE</code>.</li><li><code>name</code> must return a String.</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span>.</li><li><code>fields</code>: The set of fields required by this interface.<ul><li>Accepts the argument <code>includeDeprecated</code> which defaults to <span class="spec-keyword">false</span>. If <span class="spec-keyword">true</span>, deprecated fields are also returned.</li></ul></li><li><code>possibleTypes</code> returns the list of types that implement this interface. They must be object types.</li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-Enum" secid="4.5.2.5"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Enum">4.5.2.5</a></span>Enum</h5><p>Enums are special scalars that can only have a defined set of values.</p><p>Fields</p><ul><li><code>kind</code> must return <code>__TypeKind.ENUM</code>.</li><li><code>name</code> must return a String.</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span>.</li><li><code>enumValues</code>: The list of <code>EnumValue</code>. There must be at least one and they must have unique names.<ul><li>Accepts the argument <code>includeDeprecated</code> which defaults to <span class="spec-keyword">false</span>. If <span class="spec-keyword">true</span>, deprecated enum values are also returned.</li></ul></li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-Input-Object" secid="4.5.2.6"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Input-Object">4.5.2.6</a></span>Input Object</h5><p>Input objects are composite types used as inputs into queries defined as a list of named input values.</p><p>For example the input object <code>Point</code> could be defined as:</p><pre id="example-a0e6d" class="spec-example"><a href="#example-a0e6d">Example № 89</a><code>input Point <span class="token punctuation">{</span> <span class="token attr-name">x</span><span class="token punctuation">:</span> Int <span class="token attr-name">y</span><span class="token punctuation">:</span> Int <span class="token punctuation">}</span> </code></pre><p>Fields</p><ul><li><code>kind</code> must return <code>__TypeKind.INPUT_OBJECT</code>.</li><li><code>name</code> must return a String.</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span>.</li><li><code>inputFields</code>: a list of <code>InputValue</code>.</li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-Type-Kinds.List" secid="4.5.2.7"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Type-Kinds.List">4.5.2.7</a></span>List</h5><p>Lists represent sequences of values in GraphQL. A List type is a type modifier: it wraps another type instance in the <code>ofType</code> field, which defines the type of each item in the list.</p><p>Fields</p><ul><li><code>kind</code> must return <code>__TypeKind.LIST</code>.</li><li><code>ofType</code>: Any type.</li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-Type-Kinds.Non-Null" secid="4.5.2.8"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Type-Kinds.Non-Null">4.5.2.8</a></span>Non-Null</h5><p>GraphQL types are nullable. The value <span class="spec-keyword">null</span> is a valid response for field type.</p><p>A Non&#8208;null type is a type modifier: it wraps another type instance in the <code>ofType</code> field. Non&#8208;null types do not allow <span class="spec-keyword">null</span> as a response, and indicate required inputs for arguments and input object fields.</p><ul><li><code>kind</code> must return <code>__TypeKind.NON_NULL</code>.</li><li><code>ofType</code>: Any type except Non&#8208;null.</li><li>All other fields must return <span class="spec-keyword">null</span>.</li></ul></section></section><section id="sec-The-__Field-Type" secid="4.5.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-The-__Field-Type">4.5.3</a></span>The __Field Type</h4><p>The <code>__Field</code> type represents each field in an Object or Interface type.</p><p>Fields</p><ul><li><code>name</code> must return a String</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span></li><li><code>args</code> returns a List of <code>__InputValue</code> representing the arguments this field accepts.</li><li><code>type</code> must return a <code>__Type</code> that represents the type of value returned by this field.</li><li><code>isDeprecated</code> returns <span class="spec-keyword">true</span> if this field should no longer be used, otherwise <span class="spec-keyword">false</span>.</li><li><code>deprecationReason</code> optionally provides a reason why this field is deprecated.</li></ul></section><section id="sec-The-__InputValue-Type" secid="4.5.4"><h4><span class="spec-secid" title="link to this section"><a href="#sec-The-__InputValue-Type">4.5.4</a></span>The __InputValue Type</h4><p>The <code>__InputValue</code> type represents field and directive arguments as well as the <code>inputFields</code> of an input object.</p><p>Fields</p><ul><li><code>name</code> must return a String</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span></li><li><code>type</code> must return a <code>__Type</code> that represents the type this input value expects.</li><li><code>defaultValue</code> may return a String encoding (using the GraphQL language) of the default value used by this input value in the condition a value is not provided at runtime. If this input value has no default value, returns <span class="spec-keyword">null</span>.</li></ul></section><section id="sec-The-__EnumValue-Type" secid="4.5.5"><h4><span class="spec-secid" title="link to this section"><a href="#sec-The-__EnumValue-Type">4.5.5</a></span>The __EnumValue Type</h4><p>The <code>__EnumValue</code> type represents one of possible values of an enum.</p><p>Fields</p><ul><li><code>name</code> must return a String</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span></li><li><code>isDeprecated</code> returns <span class="spec-keyword">true</span> if this field should no longer be used, otherwise <span class="spec-keyword">false</span>.</li><li><code>deprecationReason</code> optionally provides a reason why this field is deprecated.</li></ul></section><section id="sec-The-__Directive-Type" secid="4.5.6"><h4><span class="spec-secid" title="link to this section"><a href="#sec-The-__Directive-Type">4.5.6</a></span>The __Directive Type</h4><p>The <code>__Directive</code> type represents a Directive that a server supports.</p><p>Fields</p><ul><li><code>name</code> must return a String</li><li><code>description</code> may return a String or <span class="spec-keyword">null</span></li><li><code>locations</code> returns a List of <code>__DirectiveLocation</code> representing the valid locations this directive may be placed.</li><li><code>args</code> returns a List of <code>__InputValue</code> representing the arguments this directive accepts. </li></ul></section></section></section><section id="sec-Validation" secid="5"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Validation">5</a></span>Validation</h2><p>GraphQL does not just verify if a request is syntactically correct, but also ensures that it is unambiguous and mistake&#8208;free in the context of a given GraphQL schema.</p><p>An invalid request is still technically executable, and will always produce a stable result as defined by the algorithms in the Execution section, however that result may be ambiguous, surprising, or unexpected relative to a request containing validation errors, so execution should only occur for valid requests.</p><p>Typically validation is performed in the context of a request immediately before execution, however a GraphQL service may execute a request without explicitly validating it if that exact same request is known to have been validated before. For example: the request may be validated during development, provided it does not later change, or a service may validate a request once and memoize the result to avoid validating the same request again in the future. Any client&#8208;side or development&#8208;time tool should report validation errors and not allow the formulation or execution of requests known to be invalid at that given point in time.</p><p><strong>Type system evolution</strong></p><p>As GraphQL type system schema evolve over time by adding new types and new fields, it is possible that a request which was previously valid could later become invalid. Any change that can cause a previously valid request to become invalid is considered a <em>breaking change</em>. GraphQL services and schema maintainers are encouraged to avoid breaking changes, however in order to be more resilient to these breaking changes, sophisticated GraphQL systems may still allow for the execution of requests which <em>at some point</em> were known to be free of any validation errors, and have not changed since.</p><p><strong>Examples</strong></p><p>For this section of this schema, we will assume the following type system in order to demonstrate examples:</p><pre id="example-26a9d" class="spec-example"><a href="#example-26a9d">Example № 90</a><code>type Query <span class="token punctuation">{</span> <span class="token attr-name">dog</span><span class="token punctuation">:</span> Dog <span class="token punctuation">}</span> enum DogCommand <span class="token punctuation">{</span> SIT<span class="token punctuation">,</span> DOWN<span class="token punctuation">,</span> HEEL <span class="token punctuation">}</span> type Dog implements Pet <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token attr-name">nickname</span><span class="token punctuation">:</span> String <span class="token attr-name">barkVolume</span><span class="token punctuation">:</span> Int doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> DogCommand<span class="token operator">!</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> <span class="token attr-name">owner</span><span class="token punctuation">:</span> Human <span class="token punctuation">}</span> interface Sentient <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token punctuation">}</span> interface Pet <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token punctuation">}</span> type Alien implements Sentient <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token attr-name">homePlanet</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> type Human implements Sentient <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token punctuation">}</span> enum CatCommand <span class="token punctuation">{</span> JUMP <span class="token punctuation">}</span> type Cat implements Pet <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token operator">!</span> <span class="token attr-name">nickname</span><span class="token punctuation">:</span> String doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">catCommand</span><span class="token punctuation">:</span> CatCommand<span class="token operator">!</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> <span class="token attr-name">meowVolume</span><span class="token punctuation">:</span> Int <span class="token punctuation">}</span> union CatOrDog <span class="token operator">=</span> Cat | Dog union DogOrHuman <span class="token operator">=</span> Dog | Human union HumanOrAlien <span class="token operator">=</span> Human | Alien </code></pre><section id="sec-Documents" secid="5.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Documents">5.1</a></span>Documents</h3><section id="sec-Executable-Definitions" secid="5.1.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Executable-Definitions">5.1.1</a></span>Executable Definitions</h4><p><strong>Formal Specification</strong></p><ul><li>For each definition <var data-name="definition">definition</var> in the document.</li><li><var data-name="definition">definition</var> must be <span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span> or <span class="spec-nt"><a href="#FragmentDefinition" data-name="FragmentDefinition">FragmentDefinition</a></span> (it must not be <span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span>).</li></ul><p><strong>Explanatory Text</strong></p><p>GraphQL execution will only consider the executable definitions Operation and Fragment. Type system definitions and extensions are not executable, and are not considered during execution.</p><p>To avoid ambiguity, a document containing <span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span> is invalid for execution.</p><p>GraphQL documents not intended to be directly executed may include <span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span>.</p><p>For example, the following document is invalid for execution since the original executing schema may not know about the provided type extension:</p><pre id="example-12752" class="spec-counter-example"><a href="#example-12752">Counter Example № 91</a><code><span class="token keyword">query</span> getDogName <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name color <span class="token punctuation">}</span> <span class="token punctuation">}</span> extend type Dog <span class="token punctuation">{</span> <span class="token attr-name">color</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Validation.Operations" secid="5.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Validation.Operations">5.2</a></span>Operations</h3><section id="sec-Named-Operation-Definitions" secid="5.2.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Named-Operation-Definitions">5.2.1</a></span>Named Operation Definitions</h4><section id="sec-Operation-Name-Uniqueness" secid="5.2.1.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Operation-Name-Uniqueness">5.2.1.1</a></span>Operation Name Uniqueness</h5><p><strong>Formal Specification</strong></p><ul><li>For each operation definition <var data-name="operation">operation</var> in the document.</li><li>Let <var data-name="operationName">operationName</var> be the name of <var data-name="operation">operation</var>.</li><li>If <var data-name="operationName">operationName</var> exists<ul><li>Let <var data-name="operations">operations</var> be all operation definitions in the document named <var data-name="operationName">operationName</var>.</li><li><var data-name="operations">operations</var> must be a set of one.</li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Each named operation definition must be unique within a document when referred to by its name.</p><p>For example the following document is valid:</p><pre id="example-069e1" class="spec-example"><a href="#example-069e1">Example № 92</a><code><span class="token keyword">query</span> getDogName <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> getOwnerName <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> owner <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>While this document is invalid:</p><pre id="example-5e409" class="spec-counter-example"><a href="#example-5e409">Counter Example № 93</a><code><span class="token keyword">query</span> getName <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> getName <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> owner <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>It is invalid even if the type of each operation is different:</p><pre id="example-77c2e" class="spec-counter-example"><a href="#example-77c2e">Counter Example № 94</a><code><span class="token keyword">query</span> dogOperation <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">mutation</span> dogOperation <span class="token punctuation">{</span> mutateDog <span class="token punctuation">{</span> id <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Anonymous-Operation-Definitions" secid="5.2.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Anonymous-Operation-Definitions">5.2.2</a></span>Anonymous Operation Definitions</h4><section id="sec-Lone-Anonymous-Operation" secid="5.2.2.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Lone-Anonymous-Operation">5.2.2.1</a></span>Lone Anonymous Operation</h5><p><strong>Formal Specification</strong></p><ul><li>Let <var data-name="operations">operations</var> be all operation definitions in the document.</li><li>Let <var data-name="anonymous">anonymous</var> be all anonymous operation definitions in the document.</li><li>If <var data-name="operations">operations</var> is a set of more than 1:<ul><li><var data-name="anonymous">anonymous</var> must be empty.</li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>GraphQL allows a short&#8208;hand form for defining query operations when only that one operation exists in the document.</p><p>For example the following document is valid:</p><pre id="example-be853" class="spec-example"><a href="#example-be853">Example № 95</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>While this document is invalid:</p><pre id="example-44b85" class="spec-counter-example"><a href="#example-44b85">Counter Example № 96</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> getName <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> owner <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Subscription-Operation-Definitions" secid="5.2.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Subscription-Operation-Definitions">5.2.3</a></span>Subscription Operation Definitions</h4><section id="sec-Single-root-field" secid="5.2.3.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Single-root-field">5.2.3.1</a></span>Single root field</h5><p><strong>Formal Specification</strong></p><ul><li>For each subscription operation definition <var data-name="subscription">subscription</var> in the document</li><li>Let <var data-name="subscriptionType">subscriptionType</var> be the root Subscription type in <var data-name="schema">schema</var>.</li><li>Let <var data-name="selectionSet">selectionSet</var> be the top level selection set on <var data-name="subscription">subscription</var>.</li><li>Let <var data-name="variableValues">variableValues</var> be the empty set.</li><li>Let <var data-name="groupedFieldSet">groupedFieldSet</var> be the result of <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>(<var data-name="subscriptionType">subscriptionType</var>, <var data-name="selectionSet">selectionSet</var>, <var data-name="variableValues">variableValues</var>)</span>.</li><li><var data-name="groupedFieldSet">groupedFieldSet</var> must have exactly one entry.</li></ul><p><strong>Explanatory Text</strong></p><p>Subscription operations must have exactly one root field.</p><p>Valid examples:</p><pre id="example-5bbc3" class="spec-example"><a href="#example-5bbc3">Example № 97</a><code>subscription sub <span class="token punctuation">{</span> newMessage <span class="token punctuation">{</span> body sender <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><pre id="example-13061" class="spec-example"><a href="#example-13061">Example № 98</a><code>subscription sub <span class="token punctuation">{</span> <span class="token operator">...</span>newMessageFields <span class="token punctuation">}</span> <span class="token keyword">fragment</span> newMessageFields <span class="token keyword">on</span> Subscription <span class="token punctuation">{</span> newMessage <span class="token punctuation">{</span> body sender <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Invalid:</p><pre id="example-3997d" class="spec-counter-example"><a href="#example-3997d">Counter Example № 99</a><code>subscription sub <span class="token punctuation">{</span> newMessage <span class="token punctuation">{</span> body sender <span class="token punctuation">}</span> disallowedSecondRootField <span class="token punctuation">}</span> </code></pre><pre id="example-18466" class="spec-counter-example"><a href="#example-18466">Counter Example № 100</a><code>subscription sub <span class="token punctuation">{</span> <span class="token operator">...</span>multipleSubscriptions <span class="token punctuation">}</span> <span class="token keyword">fragment</span> multipleSubscriptions <span class="token keyword">on</span> Subscription <span class="token punctuation">{</span> newMessage <span class="token punctuation">{</span> body sender <span class="token punctuation">}</span> disallowedSecondRootField <span class="token punctuation">}</span> </code></pre><p>Introspection fields are counted. The following example is also invalid:</p><pre id="example-2353b" class="spec-counter-example"><a href="#example-2353b">Counter Example № 101</a><code>subscription sub <span class="token punctuation">{</span> newMessage <span class="token punctuation">{</span> body sender <span class="token punctuation">}</span> __typename <span class="token punctuation">}</span> </code></pre><div class="spec-note">While each subscription must have exactly one root field, a document may contain any number of operations, each of which may contain different root fields. When executed, a document containing multiple subscription operations must provide the operation name as described in <span class="spec-call"><a href="#GetOperation()" data-name="GetOperation">GetOperation</a>()</span>.</div></section></section></section><section id="sec-Validation.Fields" secid="5.3"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Validation.Fields">5.3</a></span>Fields</h3><section id="sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types" secid="5.3.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types">5.3.1</a></span>Field Selections on Objects, Interfaces, and Unions Types</h4><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="selection">selection</var> in the document.</li><li>Let <var data-name="fieldName">fieldName</var> be the target field of <var data-name="selection">selection</var></li><li><var data-name="fieldName">fieldName</var> must be defined on type in scope</li></ul><p><strong>Explanatory Text</strong></p><p>The target field of a field selection must be defined on the scoped type of the selection set. There are no limitations on alias names.</p><p>For example the following fragment would not pass validation:</p><pre id="example-48706" class="spec-counter-example"><a href="#example-48706">Counter Example № 102</a><code><span class="token keyword">fragment</span> fieldNotDefined <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> meowVolume <span class="token punctuation">}</span> <span class="token keyword">fragment</span> aliasedLyingFieldTargetNotDefined <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token attr-name">barkVolume</span><span class="token punctuation">:</span> kawVolume <span class="token punctuation">}</span> </code></pre><p>For interfaces, direct field selection can only be done on fields. Fields of concrete implementors are not relevant to the validity of the given interface&#8208;typed selection set.</p><p>For example, the following is valid:</p><pre id="example-d34e0" class="spec-example"><a href="#example-d34e0">Example № 103</a><code><span class="token keyword">fragment</span> interfaceFieldSelection <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> name <span class="token punctuation">}</span> </code></pre><p>and the following is invalid:</p><pre id="example-db33b" class="spec-counter-example"><a href="#example-db33b">Counter Example № 104</a><code><span class="token keyword">fragment</span> definedOnImplementorsButNotInterface <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> nickname <span class="token punctuation">}</span> </code></pre><p>Because unions do not define fields, fields may not be directly selected from a union&#8208;typed selection set, with the exception of the meta&#8208;field <var data-name="__typename">__typename</var>. Fields from a union&#8208;typed selection set must only be queried indirectly via a fragment.</p><p>For example the following is valid:</p><pre id="example-245fa" class="spec-example"><a href="#example-245fa">Example № 105</a><code><span class="token keyword">fragment</span> inDirectFieldSelectionOnUnion <span class="token keyword">on</span> CatOrDog <span class="token punctuation">{</span> __typename <span class="token operator">...</span> <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>But the following is invalid:</p><pre id="example-252ad" class="spec-counter-example"><a href="#example-252ad">Counter Example № 106</a><code><span class="token keyword">fragment</span> directFieldSelectionOnUnion <span class="token keyword">on</span> CatOrDog <span class="token punctuation">{</span> name barkVolume <span class="token punctuation">}</span> </code></pre></section><section id="sec-Field-Selection-Merging" secid="5.3.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Field-Selection-Merging">5.3.2</a></span>Field Selection Merging</h4><p><strong>Formal Specification</strong></p><ul><li>Let <var data-name="set">set</var> be any selection set defined in the GraphQL document.</li><li><span class="spec-call"><a href="#FieldsInSetCanMerge()" data-name="FieldsInSetCanMerge">FieldsInSetCanMerge</a>(<var data-name="set">set</var>)</span> must be true.</li></ul><div class="spec-algo" id="FieldsInSetCanMerge()"><span class="spec-call"><a href="#FieldsInSetCanMerge()" data-name="FieldsInSetCanMerge">FieldsInSetCanMerge</a>(<var data-name="set">set</var>)</span><ol><li>Let <var data-name="fieldsForName">fieldsForName</var> be the set of selections with a given response name in <var data-name="set">set</var> including visiting fragments and inline fragments.</li><li>Given each pair of members <var data-name="fieldA">fieldA</var> and <var data-name="fieldB">fieldB</var> in <var data-name="fieldsForName">fieldsForName</var>:<ol><li><span class="spec-call"><a href="#SameResponseShape()" data-name="SameResponseShape">SameResponseShape</a>(<var data-name="fieldA">fieldA</var>, <var data-name="fieldB">fieldB</var>)</span> must be true.</li><li>If the parent types of <var data-name="fieldA">fieldA</var> and <var data-name="fieldB">fieldB</var> are equal or if either is not an Object Type:<ol><li><var data-name="fieldA">fieldA</var> and <var data-name="fieldB">fieldB</var> must have identical field names.</li><li><var data-name="fieldA">fieldA</var> and <var data-name="fieldB">fieldB</var> must have identical sets of arguments.</li><li>Let <var data-name="mergedSet">mergedSet</var> be the result of adding the selection set of <var data-name="fieldA">fieldA</var> and the selection set of <var data-name="fieldB">fieldB</var>.</li><li><span class="spec-call"><a href="#FieldsInSetCanMerge()" data-name="FieldsInSetCanMerge">FieldsInSetCanMerge</a>(<var data-name="mergedSet">mergedSet</var>)</span> must be true.</li></ol></li></ol></li></ol></div><div class="spec-algo" id="SameResponseShape()"><span class="spec-call"><a href="#SameResponseShape()" data-name="SameResponseShape">SameResponseShape</a>(<var data-name="fieldA">fieldA</var>, <var data-name="fieldB">fieldB</var>)</span><ol><li>Let <var data-name="typeA">typeA</var> be the return type of <var data-name="fieldA">fieldA</var>.</li><li>Let <var data-name="typeB">typeB</var> be the return type of <var data-name="fieldB">fieldB</var>.</li><li>If <var data-name="typeA">typeA</var> or <var data-name="typeB">typeB</var> is Non&#8208;Null.<ol><li>If <var data-name="typeA">typeA</var> or <var data-name="typeB">typeB</var> is nullable, return false.</li><li>Let <var data-name="typeA">typeA</var> be the nullable type of <var data-name="typeA">typeA</var></li><li>Let <var data-name="typeB">typeB</var> be the nullable type of <var data-name="typeB">typeB</var></li></ol></li><li>If <var data-name="typeA">typeA</var> or <var data-name="typeB">typeB</var> is List.<ol><li>If <var data-name="typeA">typeA</var> or <var data-name="typeB">typeB</var> is not List, return false.</li><li>Let <var data-name="typeA">typeA</var> be the item type of <var data-name="typeA">typeA</var></li><li>Let <var data-name="typeB">typeB</var> be the item type of <var data-name="typeB">typeB</var></li><li>Repeat from step 3.</li></ol></li><li>If <var data-name="typeA">typeA</var> or <var data-name="typeB">typeB</var> is Scalar or Enum.<ol><li>If <var data-name="typeA">typeA</var> and <var data-name="typeB">typeB</var> are the same type return true, otherwise return false.</li></ol></li><li>If <var data-name="typeA">typeA</var> or <var data-name="typeB">typeB</var> is not a composite type, return false.</li><li>Let <var data-name="mergedSet">mergedSet</var> be the result of adding the selection set of <var data-name="fieldA">fieldA</var> and the selection set of <var data-name="fieldB">fieldB</var>.</li><li>Let <var data-name="fieldsForName">fieldsForName</var> be the set of selections with a given response name in <var data-name="mergedSet">mergedSet</var> including visiting fragments and inline fragments.</li><li>Given each pair of members <var data-name="subfieldA">subfieldA</var> and <var data-name="subfieldB">subfieldB</var> in <var data-name="fieldsForName">fieldsForName</var>:<ol><li>If <span class="spec-call"><a href="#SameResponseShape()" data-name="SameResponseShape">SameResponseShape</a>(<var data-name="subfieldA">subfieldA</var>, <var data-name="subfieldB">subfieldB</var>)</span> is false, return false.</li></ol></li><li>Return true.</li></ol></div><p><strong>Explanatory Text</strong></p><p>If multiple field selections with the same response names are encountered during execution, the field and arguments to execute and the resulting value should be unambiguous. Therefore any two field selections which might both be encountered for the same object are only valid if they are equivalent.</p><p>During execution, the simultaneous execution of fields with the same response name is accomplished by <span class="spec-call"><a href="#MergeSelectionSets()" data-name="MergeSelectionSets">MergeSelectionSets</a>()</span> and <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>()</span>.</p><p>For simple hand&#8208;written GraphQL, this rule is obviously a clear developer error, however nested fragments can make this difficult to detect manually.</p><p>The following selections correctly merge:</p><pre id="example-4e10c" class="spec-example"><a href="#example-4e10c">Example № 107</a><code><span class="token keyword">fragment</span> mergeIdenticalFields <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> mergeIdenticalAliasesAndFields <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token attr-name">otherName</span><span class="token punctuation">:</span> name <span class="token attr-name">otherName</span><span class="token punctuation">:</span> name <span class="token punctuation">}</span> </code></pre><p>The following is not able to merge:</p><pre id="example-a2230" class="spec-counter-example"><a href="#example-a2230">Counter Example № 108</a><code><span class="token keyword">fragment</span> conflictingBecauseAlias <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> nickname name <span class="token punctuation">}</span> </code></pre><p>Identical arguments are also merged if they have identical arguments. Both values and variables can be correctly merged.</p><p>For example the following correctly merge:</p><pre id="example-b6369" class="spec-example"><a href="#example-b6369">Example № 109</a><code><span class="token keyword">fragment</span> mergeIdenticalFieldsWithIdenticalArgs <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> SIT<span class="token punctuation">)</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> SIT<span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> mergeIdenticalFieldsWithIdenticalValues <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> <span class="token variable">$dogCommand</span><span class="token punctuation">)</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> <span class="token variable">$dogCommand</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>The following do not correctly merge:</p><pre id="example-00fbf" class="spec-counter-example"><a href="#example-00fbf">Counter Example № 110</a><code><span class="token keyword">fragment</span> conflictingArgsOnValues <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> SIT<span class="token punctuation">)</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> HEEL<span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> conflictingArgsValueAndVar <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> SIT<span class="token punctuation">)</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> <span class="token variable">$dogCommand</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> conflictingArgsWithVars <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> <span class="token variable">$varOne</span><span class="token punctuation">)</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> <span class="token variable">$varTwo</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> differingArgs <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> SIT<span class="token punctuation">)</span> doesKnowCommand <span class="token punctuation">}</span> </code></pre><p>The following fields would not merge together, however both cannot be encountered against the same object, so they are safe:</p><pre id="example-a8406" class="spec-example"><a href="#example-a8406">Example № 111</a><code><span class="token keyword">fragment</span> safeDifferingFields <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token attr-name">volume</span><span class="token punctuation">:</span> barkVolume <span class="token punctuation">}</span> <span class="token operator">...</span> <span class="token keyword">on</span> Cat <span class="token punctuation">{</span> <span class="token attr-name">volume</span><span class="token punctuation">:</span> meowVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> safeDifferingArgs <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> SIT<span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token operator">...</span> <span class="token keyword">on</span> Cat <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">catCommand</span><span class="token punctuation">:</span> JUMP<span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>However, the field responses must be shapes which can be merged. For example, scalar values must not differ. In this example, <code>someValue</code> might be a <code>String</code> or an <code>Int</code>:</p><pre id="example-54e3d" class="spec-counter-example"><a href="#example-54e3d">Counter Example № 112</a><code><span class="token keyword">fragment</span> conflictingDifferingResponses <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token attr-name">someValue</span><span class="token punctuation">:</span> nickname <span class="token punctuation">}</span> <span class="token operator">...</span> <span class="token keyword">on</span> Cat <span class="token punctuation">{</span> <span class="token attr-name">someValue</span><span class="token punctuation">:</span> meowVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Leaf-Field-Selections" secid="5.3.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Leaf-Field-Selections">5.3.3</a></span>Leaf Field Selections</h4><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="selection">selection</var> in the document</li><li>Let <var data-name="selectionType">selectionType</var> be the result type of <var data-name="selection">selection</var></li><li>If <var data-name="selectionType">selectionType</var> is a scalar or enum:<ul><li>The subselection set of that selection must be empty</li></ul></li><li>If <var data-name="selectionType">selectionType</var> is an interface, union, or object<ul><li>The subselection set of that selection must NOT BE empty</li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Field selections on scalars or enums are never allowed, because they are the leaf nodes of any GraphQL query.</p><p>The following is valid.</p><pre id="example-e23c5" class="spec-example"><a href="#example-e23c5">Example № 113</a><code><span class="token keyword">fragment</span> scalarSelection <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token punctuation">}</span> </code></pre><p>The following is invalid.</p><pre id="example-13b69" class="spec-counter-example"><a href="#example-13b69">Counter Example № 114</a><code><span class="token keyword">fragment</span> scalarSelectionsNotAllowedOnInt <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token punctuation">{</span> sinceWhen <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Conversely the leaf field selections of GraphQL queries must be of type scalar or enum. Leaf selections on objects, interfaces, and unions without subfields are disallowed.</p><p>Let&rsquo;s assume the following additions to the query root type of the schema:</p><pre id="example-9bada" class="spec-example"><a href="#example-9bada">Example № 115</a><code>extend type Query <span class="token punctuation">{</span> <span class="token attr-name">human</span><span class="token punctuation">:</span> Human <span class="token attr-name">pet</span><span class="token punctuation">:</span> Pet <span class="token attr-name">catOrDog</span><span class="token punctuation">:</span> CatOrDog <span class="token punctuation">}</span> </code></pre><p>The following examples are invalid</p><pre id="example-d68ee" class="spec-counter-example"><a href="#example-d68ee">Counter Example № 116</a><code><span class="token keyword">query</span> directQueryOnObjectWithoutSubFields <span class="token punctuation">{</span> human <span class="token punctuation">}</span> <span class="token keyword">query</span> directQueryOnInterfaceWithoutSubFields <span class="token punctuation">{</span> pet <span class="token punctuation">}</span> <span class="token keyword">query</span> directQueryOnUnionWithoutSubFields <span class="token punctuation">{</span> catOrDog <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Validation.Arguments" secid="5.4"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Validation.Arguments">5.4</a></span>Arguments</h3><p>Arguments are provided to both fields and directives. The following validation rules apply in both cases.</p><section id="sec-Argument-Names" secid="5.4.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Argument-Names">5.4.1</a></span>Argument Names</h4><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="argument">argument</var> in the document</li><li>Let <var data-name="argumentName">argumentName</var> be the Name of <var data-name="argument">argument</var>.</li><li>Let <var data-name="argumentDefinition">argumentDefinition</var> be the argument definition provided by the parent field or definition named <var data-name="argumentName">argumentName</var>.</li><li><var data-name="argumentDefinition">argumentDefinition</var> must exist.</li></ul><p><strong>Explanatory Text</strong></p><p>Every argument provided to a field or directive must be defined in the set of possible arguments of that field or directive.</p><p>For example the following are valid:</p><pre id="example-760cb" class="spec-example"><a href="#example-760cb">Example № 117</a><code><span class="token keyword">fragment</span> argOnRequiredArg <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">dogCommand</span><span class="token punctuation">:</span> SIT<span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> argOnOptional <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token directive function">@include</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>the following is invalid since <code>command</code> is not defined on <code>DogCommand</code>.</p><pre id="example-d5639" class="spec-counter-example"><a href="#example-d5639">Counter Example № 118</a><code><span class="token keyword">fragment</span> invalidArgName <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> doesKnowCommand<span class="token punctuation">(</span><span class="token attr-name">command</span><span class="token punctuation">:</span> CLEAN_UP_HOUSE<span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>and this is also invalid as <code>unless</code> is not defined on <code>@include</code>.</p><pre id="example-4feee" class="spec-counter-example"><a href="#example-4feee">Counter Example № 119</a><code><span class="token keyword">fragment</span> invalidArgName <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token directive function">@include</span><span class="token punctuation">(</span><span class="token attr-name">unless</span><span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>In order to explore more complicated argument examples, let&rsquo;s add the following to our type system:</p><pre id="example-1891c" class="spec-example"><a href="#example-1891c">Example № 120</a><code>type Arguments <span class="token punctuation">{</span> multipleReqs<span class="token punctuation">(</span><span class="token attr-name">x</span><span class="token punctuation">:</span> Int<span class="token operator">!</span><span class="token punctuation">,</span> <span class="token attr-name">y</span><span class="token punctuation">:</span> Int<span class="token operator">!</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Int<span class="token operator">!</span> booleanArgField<span class="token punctuation">(</span><span class="token attr-name">booleanArg</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span><span class="token punctuation">:</span> Boolean floatArgField<span class="token punctuation">(</span><span class="token attr-name">floatArg</span><span class="token punctuation">:</span> Float<span class="token punctuation">)</span><span class="token punctuation">:</span> Float intArgField<span class="token punctuation">(</span><span class="token attr-name">intArg</span><span class="token punctuation">:</span> Int<span class="token punctuation">)</span><span class="token punctuation">:</span> Int nonNullBooleanArgField<span class="token punctuation">(</span><span class="token attr-name">nonNullBooleanArg</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> booleanListArgField<span class="token punctuation">(</span><span class="token attr-name">booleanListArg</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Boolean<span class="token punctuation">]</span><span class="token operator">!</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Boolean<span class="token punctuation">]</span> optionalNonNullBooleanArgField<span class="token punctuation">(</span><span class="token attr-name">optionalBooleanArg</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Boolean<span class="token operator">!</span> <span class="token punctuation">}</span> extend type Query <span class="token punctuation">{</span> <span class="token attr-name">arguments</span><span class="token punctuation">:</span> Arguments <span class="token punctuation">}</span> </code></pre><p>Order does not matter in arguments. Therefore both the following example are valid.</p><pre id="example-18fab" class="spec-example"><a href="#example-18fab">Example № 121</a><code><span class="token keyword">fragment</span> multipleArgs <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> multipleReqs<span class="token punctuation">(</span><span class="token attr-name">x</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token attr-name">y</span><span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> multipleArgsReverseOrder <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> multipleReqs<span class="token punctuation">(</span><span class="token attr-name">y</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token attr-name">x</span><span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Argument-Uniqueness" secid="5.4.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Argument-Uniqueness">5.4.2</a></span>Argument Uniqueness</h4><p>Fields and directives treat arguments as a mapping of argument name to value. More than one argument with the same name in an argument set is ambiguous and invalid.</p><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="argument">argument</var> in the Document.</li><li>Let <var data-name="argumentName">argumentName</var> be the Name of <var data-name="argument">argument</var>.</li><li>Let <var data-name="arguments">arguments</var> be all Arguments named <var data-name="argumentName">argumentName</var> in the Argument Set which contains <var data-name="argument">argument</var>.</li><li><var data-name="arguments">arguments</var> must be the set containing only <var data-name="argument">argument</var>.</li></ul><section id="sec-Required-Arguments" secid="5.4.2.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Required-Arguments">5.4.2.1</a></span>Required Arguments</h5><ul><li>For each Field or Directive in the document.</li><li>Let <var data-name="arguments">arguments</var> be the arguments provided by the Field or Directive.</li><li>Let <var data-name="argumentDefinitions">argumentDefinitions</var> be the set of argument definitions of that Field or Directive.</li><li>For each <var data-name="argumentDefinition">argumentDefinition</var> in <var data-name="argumentDefinitions">argumentDefinitions</var>:<ul><li>Let <var data-name="type">type</var> be the expected type of <var data-name="argumentDefinition">argumentDefinition</var>.</li><li>Let <var data-name="defaultValue">defaultValue</var> be the default value of <var data-name="argumentDefinition">argumentDefinition</var>.</li><li>If <var data-name="type">type</var> is Non&#8208;Null and <var data-name="defaultValue">defaultValue</var> does not exist:<ul><li>Let <var data-name="argumentName">argumentName</var> be the name of <var data-name="argumentDefinition">argumentDefinition</var>.</li><li>Let <var data-name="argument">argument</var> be the argument in <var data-name="arguments">arguments</var> named <var data-name="argumentName">argumentName</var></li><li><var data-name="argument">argument</var> must exist.</li><li>Let <var data-name="value">value</var> be the value of <var data-name="argument">argument</var>.</li><li><var data-name="value">value</var> must not be the <span class="spec-keyword">null</span> literal.</li></ul></li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Arguments can be required. An argument is required if the argument type is non&#8208;null and does not have a default value. Otherwise, the argument is optional.</p><p>For example the following are valid:</p><pre id="example-503bd" class="spec-example"><a href="#example-503bd">Example № 122</a><code><span class="token keyword">fragment</span> goodBooleanArg <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> booleanArgField<span class="token punctuation">(</span><span class="token attr-name">booleanArg</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> goodNonNullArg <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> nonNullBooleanArgField<span class="token punctuation">(</span><span class="token attr-name">nonNullBooleanArg</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>The argument can be omitted from a field with a nullable argument.</p><p>Therefore the following query is valid:</p><pre id="example-1f1d2" class="spec-example"><a href="#example-1f1d2">Example № 123</a><code><span class="token keyword">fragment</span> goodBooleanArgDefault <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> booleanArgField <span class="token punctuation">}</span> </code></pre><p>but this is not valid on a required argument.</p><pre id="example-f12a1" class="spec-counter-example"><a href="#example-f12a1">Counter Example № 124</a><code><span class="token keyword">fragment</span> missingRequiredArg <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> nonNullBooleanArgField <span class="token punctuation">}</span> </code></pre><p>Providing the explicit value <span class="spec-keyword">null</span> is also not valid since required arguments always have a non&#8208;null type.</p><pre id="example-0bc81" class="spec-counter-example"><a href="#example-0bc81">Counter Example № 125</a><code><span class="token keyword">fragment</span> missingRequiredArg <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> nonNullBooleanArgField<span class="token punctuation">(</span><span class="token attr-name">nonNullBooleanArg</span><span class="token punctuation">:</span> null<span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section></section></section><section id="sec-Validation.Fragments" secid="5.5"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Validation.Fragments">5.5</a></span>Fragments</h3><section id="sec-Fragment-Declarations" secid="5.5.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Fragment-Declarations">5.5.1</a></span>Fragment Declarations</h4><section id="sec-Fragment-Name-Uniqueness" secid="5.5.1.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Fragment-Name-Uniqueness">5.5.1.1</a></span>Fragment Name Uniqueness</h5><p><strong>Formal Specification</strong></p><ul><li>For each fragment definition <var data-name="fragment">fragment</var> in the document</li><li>Let <var data-name="fragmentName">fragmentName</var> be the name of <var data-name="fragment">fragment</var>.</li><li>Let <var data-name="fragments">fragments</var> be all fragment definitions in the document named <var data-name="fragmentName">fragmentName</var>.</li><li><var data-name="fragments">fragments</var> must be a set of one.</li></ul><p><strong>Explanatory Text</strong></p><p>Fragment definitions are referenced in fragment spreads by name. To avoid ambiguity, each fragment&rsquo;s name must be unique within a document.</p><p>Inline fragments are not considered fragment definitions, and are unaffected by this validation rule.</p><p>For example the following document is valid:</p><pre id="example-3703b" class="spec-example"><a href="#example-3703b">Example № 126</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>fragmentOne <span class="token operator">...</span>fragmentTwo <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> fragmentOne <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> fragmentTwo <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> owner <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>While this document is invalid:</p><pre id="example-2c3e3" class="spec-counter-example"><a href="#example-2c3e3">Counter Example № 127</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>fragmentOne <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> fragmentOne <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> fragmentOne <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> owner <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Fragment-Spread-Type-Existence" secid="5.5.1.2"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Fragment-Spread-Type-Existence">5.5.1.2</a></span>Fragment Spread Type Existence</h5><p><strong>Formal Specification</strong></p><ul><li>For each named spread <var data-name="namedSpread">namedSpread</var> in the document</li><li>Let <var data-name="fragment">fragment</var> be the target of <var data-name="namedSpread">namedSpread</var></li><li>The target type of <var data-name="fragment">fragment</var> must be defined in the schema</li></ul><p><strong>Explanatory Text</strong></p><p>Fragments must be specified on types that exist in the schema. This applies for both named and inline fragments. If they are not defined in the schema, the query does not validate.</p><p>For example the following fragments are valid:</p><pre id="example-1b2da" class="spec-example"><a href="#example-1b2da">Example № 128</a><code><span class="token keyword">fragment</span> correctType <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> inlineFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> inlineFragment2 <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token directive function">@include</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>and the following do not validate:</p><pre id="example-463f6" class="spec-counter-example"><a href="#example-463f6">Counter Example № 129</a><code><span class="token keyword">fragment</span> notOnExistingType <span class="token keyword">on</span> NotInSchema <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> inlineNotExistingType <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> NotInSchema <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Fragments-On-Composite-Types" secid="5.5.1.3"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Fragments-On-Composite-Types">5.5.1.3</a></span>Fragments On Composite Types</h5><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="fragment">fragment</var> defined in the document.</li><li>The target type of fragment must have kind <span class="spec-nt"><span data-name="UNION">UNION</span></span>, <span class="spec-nt"><span data-name="INTERFACE">INTERFACE</span></span>, or <span class="spec-nt"><span data-name="OBJECT">OBJECT</span></span>.</li></ul><p><strong>Explanatory Text</strong></p><p>Fragments can only be declared on unions, interfaces, and objects. They are invalid on scalars. They can only be applied on non&#8208;leaf fields. This rule applies to both inline and named fragments.</p><p>The following fragment declarations are valid:</p><pre id="example-3c8d4" class="spec-example"><a href="#example-3c8d4">Example № 130</a><code><span class="token keyword">fragment</span> fragOnObject <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> fragOnInterface <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> fragOnUnion <span class="token keyword">on</span> CatOrDog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>and the following are invalid:</p><pre id="example-4d5e5" class="spec-counter-example"><a href="#example-4d5e5">Counter Example № 131</a><code><span class="token keyword">fragment</span> fragOnScalar <span class="token keyword">on</span> Int <span class="token punctuation">{</span> something <span class="token punctuation">}</span> <span class="token keyword">fragment</span> inlineFragOnScalar <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Boolean <span class="token punctuation">{</span> somethingElse <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Fragments-Must-Be-Used" secid="5.5.1.4"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Fragments-Must-Be-Used">5.5.1.4</a></span>Fragments Must Be Used</h5><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="fragment">fragment</var> defined in the document.</li><li><var data-name="fragment">fragment</var> must be the target of at least one spread in the document</li></ul><p><strong>Explanatory Text</strong></p><p>Defined fragments must be used within a document.</p><p>For example the following is an invalid document:</p><pre id="example-9e1e3" class="spec-counter-example"><a href="#example-9e1e3">Counter Example № 132</a><code><span class="token keyword">fragment</span> nameFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token comment" spellcheck="true"># unused</span> name <span class="token punctuation">}</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Fragment-Spreads" secid="5.5.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Fragment-Spreads">5.5.2</a></span>Fragment Spreads</h4><p>Field selection is also determined by spreading fragments into one another. The selection set of the target fragment is unioned with the selection set at the level at which the target fragment is referenced.</p><section id="sec-Fragment-spread-target-defined" secid="5.5.2.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Fragment-spread-target-defined">5.5.2.1</a></span>Fragment spread target defined</h5><p><strong>Formal Specification</strong></p><ul><li>For every <var data-name="namedSpread">namedSpread</var> in the document.</li><li>Let <var data-name="fragment">fragment</var> be the target of <var data-name="namedSpread">namedSpread</var></li><li><var data-name="fragment">fragment</var> must be defined in the document</li></ul><p><strong>Explanatory Text</strong></p><p>Named fragment spreads must refer to fragments defined within the document. It is a validation error if the target of a spread is not defined.</p><pre id="example-28421" class="spec-counter-example"><a href="#example-28421">Counter Example № 133</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>undefinedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Fragment-spreads-must-not-form-cycles" secid="5.5.2.2"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Fragment-spreads-must-not-form-cycles">5.5.2.2</a></span>Fragment spreads must not form cycles</h5><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="fragmentDefinition">fragmentDefinition</var> in the document</li><li>Let <var data-name="visited">visited</var> be the empty set.</li><li><span class="spec-call"><span data-name="DetectCycles">DetectCycles</span>(<var data-name="fragmentDefinition">fragmentDefinition</var>, <var data-name="visited">visited</var>)</span></li></ul><p><span class="spec-call"><span data-name="DetectCycles">DetectCycles</span>(<var data-name="fragmentDefinition">fragmentDefinition</var>, <var data-name="visited">visited</var>)</span> :</p><ul><li>Let <var data-name="spreads">spreads</var> be all fragment spread descendants of <var data-name="fragmentDefinition">fragmentDefinition</var></li><li>For each <var data-name="spread">spread</var> in <var data-name="spreads">spreads</var><ul><li><var data-name="visited">visited</var> must not contain <var data-name="spread">spread</var></li><li>Let <var data-name="nextVisited">nextVisited</var> be the set including <var data-name="spread">spread</var> and members of <var data-name="visited">visited</var></li><li>Let <var data-name="nextFragmentDefinition">nextFragmentDefinition</var> be the target of <var data-name="spread">spread</var></li><li><span class="spec-call"><span data-name="DetectCycles">DetectCycles</span>(<var data-name="nextFragmentDefinition">nextFragmentDefinition</var>, <var data-name="nextVisited">nextVisited</var>)</span></li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>The graph of fragment spreads must not form any cycles including spreading itself. Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data.</p><p>This invalidates fragments that would result in an infinite spread:</p><pre id="example-9ceb4" class="spec-counter-example"><a href="#example-9ceb4">Counter Example № 134</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>nameFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> nameFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name <span class="token operator">...</span>barkVolumeFragment <span class="token punctuation">}</span> <span class="token keyword">fragment</span> barkVolumeFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token operator">...</span>nameFragment <span class="token punctuation">}</span> </code></pre><p>If the above fragments were inlined, this would result in the infinitely large:</p><pre id="example-08734" class="spec-example"><a href="#example-08734">Example № 135</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> name barkVolume name barkVolume name barkVolume name <span class="token comment" spellcheck="true"># forever...</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>This also invalidates fragments that would result in an infinite recursion when executed against cyclic data:</p><pre id="example-6bbad" class="spec-counter-example"><a href="#example-6bbad">Counter Example № 136</a><code><span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>dogFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> dogFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name owner <span class="token punctuation">{</span> <span class="token operator">...</span>ownerFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> ownerFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> name pets <span class="token punctuation">{</span> <span class="token operator">...</span>dogFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Fragment-spread-is-possible" secid="5.5.2.3"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Fragment-spread-is-possible">5.5.2.3</a></span>Fragment spread is possible</h5><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="spread">spread</var> (named or inline) defined in the document.</li><li>Let <var data-name="fragment">fragment</var> be the target of <var data-name="spread">spread</var></li><li>Let <var data-name="fragmentType">fragmentType</var> be the type condition of <var data-name="fragment">fragment</var></li><li>Let <var data-name="parentType">parentType</var> be the type of the selection set containing <var data-name="spread">spread</var></li><li>Let <var data-name="applicableTypes">applicableTypes</var> be the intersection of <span class="spec-call"><a href="#GetPossibleTypes()" data-name="GetPossibleTypes">GetPossibleTypes</a>(<var data-name="fragmentType">fragmentType</var>)</span> and <span class="spec-call"><a href="#GetPossibleTypes()" data-name="GetPossibleTypes">GetPossibleTypes</a>(<var data-name="parentType">parentType</var>)</span></li><li><var data-name="applicableTypes">applicableTypes</var> must not be empty.</li></ul><div class="spec-algo" id="GetPossibleTypes()"><span class="spec-call"><a href="#GetPossibleTypes()" data-name="GetPossibleTypes">GetPossibleTypes</a>(<var data-name="type">type</var>)</span><ol><li>If <var data-name="type">type</var> is an object type, return a set containing <var data-name="type">type</var></li><li>If <var data-name="type">type</var> is an interface type, return the set of types implementing <var data-name="type">type</var></li><li>If <var data-name="type">type</var> is a union type, return the set of possible types of <var data-name="type">type</var></li></ol></div><p><strong>Explanatory Text</strong></p><p>Fragments are declared on a type and will only apply when the runtime object type matches the type condition. They also are spread within the context of a parent type. A fragment spread is only valid if its type condition could ever apply within the parent type.</p><section id="sec-Object-Spreads-In-Object-Scope" secid="5.5.2.3.1"><h6><span class="spec-secid" title="link to this section"><a href="#sec-Object-Spreads-In-Object-Scope">5.5.2.3.1</a></span>Object Spreads In Object Scope</h6><p>In the scope of an object type, the only valid object type fragment spread is one that applies to the same type that is in scope.</p><p>For example</p><pre id="example-0fc38" class="spec-example"><a href="#example-0fc38">Example № 137</a><code><span class="token keyword">fragment</span> dogFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>and the following is invalid</p><pre id="example-4d411" class="spec-counter-example"><a href="#example-4d411">Counter Example № 138</a><code><span class="token keyword">fragment</span> catInDogFragmentInvalid <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Cat <span class="token punctuation">{</span> meowVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Abstract-Spreads-in-Object-Scope" secid="5.5.2.3.2"><h6><span class="spec-secid" title="link to this section"><a href="#sec-Abstract-Spreads-in-Object-Scope">5.5.2.3.2</a></span>Abstract Spreads in Object Scope</h6><p>In scope of an object type, unions or interface spreads can be used if the object type implements the interface or is a member of the union.</p><p>For example</p><pre id="example-2c8d0" class="spec-example"><a href="#example-2c8d0">Example № 139</a><code><span class="token keyword">fragment</span> petNameFragment <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token keyword">fragment</span> interfaceWithinObjectFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span>petNameFragment <span class="token punctuation">}</span> </code></pre><p>is valid because <span class="spec-nt"><span data-name="Dog">Dog</span></span> implements Pet.</p><p>Likewise</p><pre id="example-41843" class="spec-example"><a href="#example-41843">Example № 140</a><code><span class="token keyword">fragment</span> catOrDogNameFragment <span class="token keyword">on</span> CatOrDog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Cat <span class="token punctuation">{</span> meowVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> unionWithObjectFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span>catOrDogNameFragment <span class="token punctuation">}</span> </code></pre><p>is valid because <span class="spec-nt"><span data-name="Dog">Dog</span></span> is a member of the <span class="spec-nt"><span data-name="CatOrDog">CatOrDog</span></span> union. It is worth noting that if one inspected the contents of the <span class="spec-nt"><span data-name="CatOrDogNameFragment">CatOrDogNameFragment</span></span> you could note that no valid results would ever be returned. However we do not specify this as invalid because we only consider the fragment declaration, not its body.</p></section><section id="sec-Object-Spreads-In-Abstract-Scope" secid="5.5.2.3.3"><h6><span class="spec-secid" title="link to this section"><a href="#sec-Object-Spreads-In-Abstract-Scope">5.5.2.3.3</a></span>Object Spreads In Abstract Scope</h6><p>Union or interface spreads can be used within the context of an object type fragment, but only if the object type is one of the possible types of that interface or union.</p><p>For example, the following fragments are valid:</p><pre id="example-85110" class="spec-example"><a href="#example-85110">Example № 141</a><code><span class="token keyword">fragment</span> petFragment <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> name <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> catOrDogFragment <span class="token keyword">on</span> CatOrDog <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Cat <span class="token punctuation">{</span> meowVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p><var data-name="petFragment">petFragment</var> is valid because <span class="spec-nt"><span data-name="Dog">Dog</span></span> implements the interface <span class="spec-nt"><span data-name="Pet">Pet</span></span>. <var data-name="catOrDogFragment">catOrDogFragment</var> is valid because <span class="spec-nt"><span data-name="Cat">Cat</span></span> is a member of the <span class="spec-nt"><span data-name="CatOrDog">CatOrDog</span></span> union.</p><p>By contrast the following fragments are invalid:</p><pre id="example-a8dcc" class="spec-counter-example"><a href="#example-a8dcc">Counter Example № 142</a><code><span class="token keyword">fragment</span> sentientFragment <span class="token keyword">on</span> Sentient <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> humanOrAlienFragment <span class="token keyword">on</span> HumanOrAlien <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Cat <span class="token punctuation">{</span> meowVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p><span class="spec-nt"><span data-name="Dog">Dog</span></span> does not implement the interface <span class="spec-nt"><span data-name="Sentient">Sentient</span></span> and therefore <var data-name="sentientFragment">sentientFragment</var> can never return meaningful results. Therefore the fragment is invalid. Likewise <span class="spec-nt"><span data-name="Cat">Cat</span></span> is not a member of the union <span class="spec-nt"><span data-name="HumanOrAlien">HumanOrAlien</span></span>, and it can also never return meaningful results, making it invalid.</p></section><section id="sec-Abstract-Spreads-in-Abstract-Scope" secid="5.5.2.3.4"><h6><span class="spec-secid" title="link to this section"><a href="#sec-Abstract-Spreads-in-Abstract-Scope">5.5.2.3.4</a></span>Abstract Spreads in Abstract Scope</h6><p>Union or interfaces fragments can be used within each other. As long as there exists at least <em>one</em> object type that exists in the intersection of the possible types of the scope and the spread, the spread is considered valid.</p><p>So for example</p><pre id="example-dc875" class="spec-example"><a href="#example-dc875">Example № 143</a><code><span class="token keyword">fragment</span> unionWithInterface <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> <span class="token operator">...</span>dogOrHumanFragment <span class="token punctuation">}</span> <span class="token keyword">fragment</span> dogOrHumanFragment <span class="token keyword">on</span> DogOrHuman <span class="token punctuation">{</span> <span class="token operator">...</span> <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> barkVolume <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>is consider valid because <span class="spec-nt"><span data-name="Dog">Dog</span></span> implements interface <span class="spec-nt"><span data-name="Pet">Pet</span></span> and is a member of <span class="spec-nt"><span data-name="DogOrHuman">DogOrHuman</span></span>.</p><p>However</p><pre id="example-c9c63" class="spec-counter-example"><a href="#example-c9c63">Counter Example № 144</a><code><span class="token keyword">fragment</span> nonIntersectingInterfaces <span class="token keyword">on</span> Pet <span class="token punctuation">{</span> <span class="token operator">...</span>sentientFragment <span class="token punctuation">}</span> <span class="token keyword">fragment</span> sentientFragment <span class="token keyword">on</span> Sentient <span class="token punctuation">{</span> name <span class="token punctuation">}</span> </code></pre><p>is not valid because there exists no type that implements both <span class="spec-nt"><span data-name="Pet">Pet</span></span> and <span class="spec-nt"><span data-name="Sentient">Sentient</span></span>.</p></section></section></section></section><section id="sec-Values" secid="5.6"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Values">5.6</a></span>Values</h3><section id="sec-Values-of-Correct-Type" secid="5.6.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Values-of-Correct-Type">5.6.1</a></span>Values of Correct Type</h4><p><strong>Format Specification</strong></p><ul><li>For each input Value <var data-name="value">value</var> in the document.<ul><li>Let <var data-name="type">type</var> be the type expected in the position <var data-name="value">value</var> is found.</li><li><var data-name="value">value</var> must be coercible to <var data-name="type">type</var>.</li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Literal values must be compatible with the type expected in the position they are found as per the coercion rules defined in the Type System chapter.</p><p>The type expected in a position include the type defined by the argument a value is provided for, the type defined by an input object field a value is provided for, and the type of a variable definition a default value is provided for.</p><p>The following examples are valid use of value literals:</p><pre id="example-7ee0e" class="spec-example"><a href="#example-7ee0e">Example № 145</a><code><span class="token keyword">fragment</span> goodBooleanArg <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> booleanArgField<span class="token punctuation">(</span><span class="token attr-name">booleanArg</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> coercedIntIntoFloatArg <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> <span class="token comment" spellcheck="true"># Note: The input coercion rules for Float allow Int literals.</span> floatArgField<span class="token punctuation">(</span><span class="token attr-name">floatArg</span><span class="token punctuation">:</span> <span class="token number">123</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> goodComplexDefaultValue<span class="token punctuation">(</span><span class="token variable">$search</span><span class="token punctuation">:</span> ComplexInput <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> <span class="token string">"Fido"</span> <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> findDog<span class="token punctuation">(</span><span class="token attr-name">complex</span><span class="token punctuation">:</span> <span class="token variable">$search</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>Non&#8208;coercible values (such as a String into an Int) are invalid. The following examples are invalid:</p><pre id="example-3a7c1" class="spec-counter-example"><a href="#example-3a7c1">Counter Example № 146</a><code><span class="token keyword">fragment</span> stringIntoInt <span class="token keyword">on</span> Arguments <span class="token punctuation">{</span> intArgField<span class="token punctuation">(</span><span class="token attr-name">intArg</span><span class="token punctuation">:</span> <span class="token string">"123"</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> badComplexValue <span class="token punctuation">{</span> findDog<span class="token punctuation">(</span><span class="token attr-name">complex</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> <span class="token number">123</span> <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Input-Object-Field-Names" secid="5.6.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Input-Object-Field-Names">5.6.2</a></span>Input Object Field Names</h4><p><strong>Formal Specification</strong></p><ul><li>For each Input Object Field <var data-name="inputField">inputField</var> in the document</li><li>Let <var data-name="inputFieldName">inputFieldName</var> be the Name of <var data-name="inputField">inputField</var>.</li><li>Let <var data-name="inputFieldDefinition">inputFieldDefinition</var> be the input field definition provided by the parent input object type named <var data-name="inputFieldName">inputFieldName</var>.</li><li><var data-name="inputFieldDefinition">inputFieldDefinition</var> must exist.</li></ul><p><strong>Explanatory Text</strong></p><p>Every input field provided in an input object value must be defined in the set of possible fields of that input object&rsquo;s expected type.</p><p>For example the following example input object is valid:</p><pre id="example-a940b" class="spec-example"><a href="#example-a940b">Example № 147</a><code><span class="token punctuation">{</span> findDog<span class="token punctuation">(</span><span class="token attr-name">complex</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> <span class="token string">"Fido"</span> <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>While the following example input&#8208;object uses a field &ldquo;favoriteCookieFlavor&rdquo; which is not defined on the expected type:</p><pre id="example-1a5f6" class="spec-counter-example"><a href="#example-1a5f6">Counter Example № 148</a><code><span class="token punctuation">{</span> findDog<span class="token punctuation">(</span><span class="token attr-name">complex</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token attr-name">favoriteCookieFlavor</span><span class="token punctuation">:</span> <span class="token string">"Bacon"</span> <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Input-Object-Field-Uniqueness" secid="5.6.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Input-Object-Field-Uniqueness">5.6.3</a></span>Input Object Field Uniqueness</h4><p><strong>Formal Specification</strong></p><ul><li>For each input object value <var data-name="inputObject">inputObject</var> in the document.</li><li>For every <var data-name="inputField">inputField</var> in <var data-name="inputObject">inputObject</var><ul><li>Let <var data-name="name">name</var> be the Name of <var data-name="inputField">inputField</var>.</li><li>Let <var data-name="fields">fields</var> be all Input Object Fields named <var data-name="name">name</var> in <var data-name="inputObject">inputObject</var>.</li><li><var data-name="fields">fields</var> must be the set containing only <var data-name="inputField">inputField</var>.</li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Input objects must not contain more than one field of the same name, otherwise an ambiguity would exist which includes an ignored portion of syntax.</p><p>For example the following query will not pass validation.</p><pre id="example-5d541" class="spec-counter-example"><a href="#example-5d541">Counter Example № 149</a><code><span class="token punctuation">{</span> field<span class="token punctuation">(</span><span class="token attr-name">arg</span><span class="token punctuation">:</span> <span class="token punctuation">{</span> <span class="token attr-name">field</span><span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token attr-name">field</span><span class="token punctuation">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Input-Object-Required-Fields" secid="5.6.4"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Input-Object-Required-Fields">5.6.4</a></span>Input Object Required Fields</h4><p><strong>Formal Specification</strong></p><ul><li>For each Input Object in the document.<ul><li>Let <var data-name="fields">fields</var> be the fields provided by that Input Object.</li><li>Let <var data-name="fieldDefinitions">fieldDefinitions</var> be the set of input field definitions of that Input Object.</li></ul></li><li>For each <var data-name="fieldDefinition">fieldDefinition</var> in <var data-name="fieldDefinitions">fieldDefinitions</var>:<ul><li>Let <var data-name="type">type</var> be the expected type of <var data-name="fieldDefinition">fieldDefinition</var>.</li><li>Let <var data-name="defaultValue">defaultValue</var> be the default value of <var data-name="fieldDefinition">fieldDefinition</var>.</li><li>If <var data-name="type">type</var> is Non&#8208;Null and <var data-name="defaultValue">defaultValue</var> does not exist:<ul><li>Let <var data-name="fieldName">fieldName</var> be the name of <var data-name="fieldDefinition">fieldDefinition</var>.</li><li>Let <var data-name="field">field</var> be the input field in <var data-name="fields">fields</var> named <var data-name="fieldName">fieldName</var></li><li><var data-name="field">field</var> must exist.</li><li>Let <var data-name="value">value</var> be the value of <var data-name="field">field</var>.</li><li><var data-name="value">value</var> must not be the <span class="spec-keyword">null</span> literal.</li></ul></li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Input object fields may be required. Much like a field may have required arguments, an input object may have required fields. An input field is required if it has a non&#8208;null type and does not have a default value. Otherwise, the input object field is optional.</p></section></section><section id="sec-Validation.Directives" secid="5.7"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Validation.Directives">5.7</a></span>Directives</h3><section id="sec-Directives-Are-Defined" secid="5.7.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Directives-Are-Defined">5.7.1</a></span>Directives Are Defined</h4><p><strong>Formal Specification</strong></p><ul><li>For every <var data-name="directive">directive</var> in a document.</li><li>Let <var data-name="directiveName">directiveName</var> be the name of <var data-name="directive">directive</var>.</li><li>Let <var data-name="directiveDefinition">directiveDefinition</var> be the directive named <var data-name="directiveName">directiveName</var>.</li><li><var data-name="directiveDefinition">directiveDefinition</var> must exist.</li></ul><p><strong>Explanatory Text</strong></p><p>GraphQL servers define what directives they support. For each usage of a directive, the directive must be available on that server.</p></section><section id="sec-Directives-Are-In-Valid-Locations" secid="5.7.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Directives-Are-In-Valid-Locations">5.7.2</a></span>Directives Are In Valid Locations</h4><p><strong>Formal Specification</strong></p><ul><li>For every <var data-name="directive">directive</var> in a document.</li><li>Let <var data-name="directiveName">directiveName</var> be the name of <var data-name="directive">directive</var>.</li><li>Let <var data-name="directiveDefinition">directiveDefinition</var> be the directive named <var data-name="directiveName">directiveName</var>.</li><li>Let <var data-name="locations">locations</var> be the valid locations for <var data-name="directiveDefinition">directiveDefinition</var>.</li><li>Let <var data-name="adjacent">adjacent</var> be the AST node the directive affects.</li><li><var data-name="adjacent">adjacent</var> must be represented by an item within <var data-name="locations">locations</var>.</li></ul><p><strong>Explanatory Text</strong></p><p>GraphQL servers define what directives they support and where they support them. For each usage of a directive, the directive must be used in a location that the server has declared support for.</p><p>For example the following query will not pass validation because <code>@skip</code> does not provide <code>QUERY</code> as a valid location.</p><pre id="example-55f3f" class="spec-counter-example"><a href="#example-55f3f">Counter Example № 150</a><code><span class="token keyword">query</span> <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$foo</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> field <span class="token punctuation">}</span> </code></pre></section><section id="sec-Directives-Are-Unique-Per-Location" secid="5.7.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Directives-Are-Unique-Per-Location">5.7.3</a></span>Directives Are Unique Per Location</h4><p><strong>Formal Specification</strong></p><ul><li>For every <var data-name="location">location</var> in the document for which Directives can apply:<ul><li>Let <var data-name="directives">directives</var> be the set of Directives which apply to <var data-name="location">location</var>.</li><li>For each <var data-name="directive">directive</var> in <var data-name="directives">directives</var>:<ul><li>Let <var data-name="directiveName">directiveName</var> be the name of <var data-name="directive">directive</var>.</li><li>Let <var data-name="namedDirectives">namedDirectives</var> be the set of all Directives named <var data-name="directiveName">directiveName</var> in <var data-name="directives">directives</var>.</li><li><var data-name="namedDirectives">namedDirectives</var> must be a set of one.</li></ul></li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Directives are used to describe some metadata or behavioral change on the definition they apply to. When more than one directive of the same name is used, the expected metadata or behavior becomes ambiguous, therefore only one of each directive is allowed per location.</p><p>For example, the following query will not pass validation because <code>@skip</code> has been used twice for the same field:</p><pre id="example-b2e6c" class="spec-counter-example"><a href="#example-b2e6c">Counter Example № 151</a><code><span class="token keyword">query</span> <span class="token punctuation">(</span><span class="token variable">$foo</span><span class="token punctuation">:</span> Boolean <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token variable">$bar</span><span class="token punctuation">:</span> Boolean <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> field <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$foo</span><span class="token punctuation">)</span> <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$bar</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>However the following example is valid because <code>@skip</code> has been used only once per location, despite being used twice in the query and on the same named field:</p><pre id="example-c5ee9" class="spec-example"><a href="#example-c5ee9">Example № 152</a><code><span class="token keyword">query</span> <span class="token punctuation">(</span><span class="token variable">$foo</span><span class="token punctuation">:</span> Boolean <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token variable">$bar</span><span class="token punctuation">:</span> Boolean <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> field <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$foo</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> subfieldA <span class="token punctuation">}</span> field <span class="token directive function">@skip</span><span class="token punctuation">(</span><span class="token attr-name">if</span><span class="token punctuation">:</span> <span class="token variable">$bar</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> subfieldB <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Validation.Variables" secid="5.8"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Validation.Variables">5.8</a></span>Variables</h3><section id="sec-Variable-Uniqueness" secid="5.8.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Variable-Uniqueness">5.8.1</a></span>Variable Uniqueness</h4><p><strong>Formal Specification</strong></p><ul><li>For every <var data-name="operation">operation</var> in the document<ul><li>For every <var data-name="variable">variable</var> defined on <var data-name="operation">operation</var><ul><li>Let <var data-name="variableName">variableName</var> be the name of <var data-name="variable">variable</var></li><li>Let <var data-name="variables">variables</var> be the set of all variables named <var data-name="variableName">variableName</var> on <var data-name="operation">operation</var></li><li><var data-name="variables">variables</var> must be a set of one</li></ul></li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>If any operation defines more than one variable with the same name, it is ambiguous and invalid. It is invalid even if the type of the duplicate variable is the same.</p><pre id="example-b767a" class="spec-counter-example"><a href="#example-b767a">Counter Example № 153</a><code><span class="token keyword">query</span> houseTrainedQuery<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">,</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>It is valid for multiple operations to define a variable with the same name. If two operations reference the same fragment, it might actually be necessary:</p><pre id="example-6f6b9" class="spec-example"><a href="#example-6f6b9">Example № 154</a><code><span class="token keyword">query</span> A<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token operator">...</span>HouseTrainedFragment <span class="token punctuation">}</span> <span class="token keyword">query</span> B<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token operator">...</span>HouseTrainedFragment <span class="token punctuation">}</span> <span class="token keyword">fragment</span> HouseTrainedFragment <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Variables-Are-Input-Types" secid="5.8.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Variables-Are-Input-Types">5.8.2</a></span>Variables Are Input Types</h4><p><strong>Formal Specification</strong></p><ul><li>For every <var data-name="operation">operation</var> in a <var data-name="document">document</var></li><li>For every <var data-name="variable">variable</var> on each <var data-name="operation">operation</var><ul><li>Let <var data-name="variableType">variableType</var> be the type of <var data-name="variable">variable</var></li><li><span class="spec-call"><a href="#IsInputType()" data-name="IsInputType">IsInputType</a>(<var data-name="variableType">variableType</var>)</span> must be <span class="spec-keyword">true</span></li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Variables can only be input types. Objects, unions, and interfaces cannot be used as inputs.</p><p>For these examples, consider the following typesystem additions:</p><pre id="example-f3185" class="spec-example"><a href="#example-f3185">Example № 155</a><code>input ComplexInput <span class="token punctuation">{</span> <span class="token attr-name">name</span><span class="token punctuation">:</span> String<span class="token punctuation">,</span> <span class="token attr-name">owner</span><span class="token punctuation">:</span> String <span class="token punctuation">}</span> extend type Query <span class="token punctuation">{</span> findDog<span class="token punctuation">(</span><span class="token attr-name">complex</span><span class="token punctuation">:</span> ComplexInput<span class="token punctuation">)</span><span class="token punctuation">:</span> Dog booleanList<span class="token punctuation">(</span><span class="token attr-name">booleanListArg</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Boolean<span class="token operator">!</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Boolean <span class="token punctuation">}</span> </code></pre><p>The following queries are valid:</p><pre id="example-77f18" class="spec-example"><a href="#example-77f18">Example № 156</a><code><span class="token keyword">query</span> takesBoolean<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> takesComplexInput<span class="token punctuation">(</span><span class="token variable">$complexInput</span><span class="token punctuation">:</span> ComplexInput<span class="token punctuation">)</span> <span class="token punctuation">{</span> findDog<span class="token punctuation">(</span><span class="token attr-name">complex</span><span class="token punctuation">:</span> <span class="token variable">$complexInput</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> TakesListOfBooleanBang<span class="token punctuation">(</span><span class="token variable">$booleans</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Boolean<span class="token operator">!</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> booleanList<span class="token punctuation">(</span><span class="token attr-name">booleanListArg</span><span class="token punctuation">:</span> <span class="token variable">$booleans</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>The following queries are invalid:</p><pre id="example-aeba9" class="spec-counter-example"><a href="#example-aeba9">Counter Example № 157</a><code><span class="token keyword">query</span> takesCat<span class="token punctuation">(</span><span class="token variable">$cat</span><span class="token punctuation">:</span> Cat<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment" spellcheck="true"># ...</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> takesDogBang<span class="token punctuation">(</span><span class="token variable">$dog</span><span class="token punctuation">:</span> Dog<span class="token operator">!</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment" spellcheck="true"># ...</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> takesListOfPet<span class="token punctuation">(</span><span class="token variable">$pets</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Pet<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment" spellcheck="true"># ...</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> takesCatOrDog<span class="token punctuation">(</span><span class="token variable">$catOrDog</span><span class="token punctuation">:</span> CatOrDog<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token comment" spellcheck="true"># ...</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-All-Variable-Uses-Defined" secid="5.8.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-All-Variable-Uses-Defined">5.8.3</a></span>All Variable Uses Defined</h4><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="operation">operation</var> in a document<ul><li>For each <var data-name="variableUsage">variableUsage</var> in scope, variable must be in <var data-name="operation">operation</var>&lsquo;s variable list.</li><li>Let <var data-name="fragments">fragments</var> be every fragment referenced by that <var data-name="operation">operation</var> transitively</li><li>For each <var data-name="fragment">fragment</var> in <var data-name="fragments">fragments</var><ul><li>For each <var data-name="variableUsage">variableUsage</var> in scope of <var data-name="fragment">fragment</var>, variable must be in <var data-name="operation">operation</var>&lsquo;s variable list.</li></ul></li></ul></li></ul><p><strong>Explanatory Text</strong></p><p>Variables are scoped on a per&#8208;operation basis. That means that any variable used within the context of an operation must be defined at the top level of that operation</p><p>For example:</p><pre id="example-a5099" class="spec-example"><a href="#example-a5099">Example № 158</a><code><span class="token keyword">query</span> variableIsDefined<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>is valid. $<var data-name="atOtherHomes">atOtherHomes</var> is defined by the operation.</p><p>By contrast the following query is invalid:</p><pre id="example-c8425" class="spec-counter-example"><a href="#example-c8425">Counter Example № 159</a><code><span class="token keyword">query</span> variableIsNotDefined <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>$<var data-name="atOtherHomes">atOtherHomes</var> is not defined by the operation.</p><p>Fragments complicate this rule. Any fragment transitively included by an operation has access to the variables defined by that operation. Fragments can appear within multiple operations and therefore variable usages must correspond to variable definitions in all of those operations.</p><p>For example the following is valid:</p><pre id="example-f4a77" class="spec-example"><a href="#example-f4a77">Example № 160</a><code><span class="token keyword">query</span> variableIsDefinedUsedInSingleFragment<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>since <var data-name="isHousetrainedFragment">isHousetrainedFragment</var> is used within the context of the operation <var data-name="variableIsDefinedUsedInSingleFragment">variableIsDefinedUsedInSingleFragment</var> and the variable is defined by that operation.</p><p>On the other hand, if a fragment is included within an operation that does not define a referenced variable, the query is invalid.</p><pre id="example-8c8db" class="spec-counter-example"><a href="#example-8c8db">Counter Example № 161</a><code><span class="token keyword">query</span> variableIsNotDefinedUsedInSingleFragment <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>This applies transitively as well, so the following also fails:</p><pre id="example-7b65c" class="spec-counter-example"><a href="#example-7b65c">Counter Example № 162</a><code><span class="token keyword">query</span> variableIsNotDefinedUsedInNestedFragment <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>outerHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> outerHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>Variables must be defined in all operations in which a fragment is used.</p><pre id="example-84129" class="spec-example"><a href="#example-84129">Example № 163</a><code><span class="token keyword">query</span> housetrainedQueryOne<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> housetrainedQueryTwo<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>However the following does not validate:</p><pre id="example-ef68a" class="spec-counter-example"><a href="#example-ef68a">Counter Example № 164</a><code><span class="token keyword">query</span> housetrainedQueryOne<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> housetrainedQueryTwoNotDefined <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>This is because <var data-name="housetrainedQueryTwoNotDefined">housetrainedQueryTwoNotDefined</var> does not define a variable $<var data-name="atOtherHomes">atOtherHomes</var> but that variable is used by <var data-name="isHousetrainedFragment">isHousetrainedFragment</var> which is included in that operation.</p></section><section id="sec-All-Variables-Used" secid="5.8.4"><h4><span class="spec-secid" title="link to this section"><a href="#sec-All-Variables-Used">5.8.4</a></span>All Variables Used</h4><p><strong>Formal Specification</strong></p><ul><li>For every <var data-name="operation">operation</var> in the document.</li><li>Let <var data-name="variables">variables</var> be the variables defined by that <var data-name="operation">operation</var></li><li>Each <var data-name="variable">variable</var> in <var data-name="variables">variables</var> must be used at least once in either the operation scope itself or any fragment transitively referenced by that operation.</li></ul><p><strong>Explanatory Text</strong></p><p>All variables defined by an operation must be used in that operation or a fragment transitively included by that operation. Unused variables cause a validation error.</p><p>For example the following is invalid:</p><pre id="example-516af" class="spec-counter-example"><a href="#example-516af">Counter Example № 165</a><code><span class="token keyword">query</span> variableUnused<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> isHousetrained <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>because $<var data-name="atOtherHomes">atOtherHomes</var> is not referenced.</p><p>These rules apply to transitive fragment spreads as well:</p><pre id="example-ed1fa" class="spec-example"><a href="#example-ed1fa">Example № 166</a><code><span class="token keyword">query</span> variableUsedInFragment<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>The above is valid since $<var data-name="atOtherHomes">atOtherHomes</var> is used in <var data-name="isHousetrainedFragment">isHousetrainedFragment</var> which is included by <var data-name="variableUsedInFragment">variableUsedInFragment</var>.</p><p>If that fragment did not have a reference to $<var data-name="atOtherHomes">atOtherHomes</var> it would be not valid:</p><pre id="example-f6c72" class="spec-counter-example"><a href="#example-f6c72">Counter Example № 167</a><code><span class="token keyword">query</span> variableNotUsedWithinFragment<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedWithoutVariableFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedWithoutVariableFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained <span class="token punctuation">}</span> </code></pre><p>All operations in a document must use all of their variables.</p><p>As a result, the following document does not validate.</p><pre id="example-5593f" class="spec-counter-example"><a href="#example-5593f">Counter Example № 168</a><code><span class="token keyword">query</span> queryWithUsedVar<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">query</span> queryWithExtraVar<span class="token punctuation">(</span><span class="token variable">$atOtherHomes</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">,</span> <span class="token variable">$extra</span><span class="token punctuation">:</span> Int<span class="token punctuation">)</span> <span class="token punctuation">{</span> dog <span class="token punctuation">{</span> <span class="token operator">...</span>isHousetrainedFragment <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token keyword">fragment</span> isHousetrainedFragment <span class="token keyword">on</span> Dog <span class="token punctuation">{</span> isHousetrained<span class="token punctuation">(</span><span class="token attr-name">atOtherHomes</span><span class="token punctuation">:</span> <span class="token variable">$atOtherHomes</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> </code></pre><p>This document is not valid because <var data-name="queryWithExtraVar">queryWithExtraVar</var> defines an extraneous variable.</p></section><section id="sec-All-Variable-Usages-are-Allowed" secid="5.8.5"><h4><span class="spec-secid" title="link to this section"><a href="#sec-All-Variable-Usages-are-Allowed">5.8.5</a></span>All Variable Usages are Allowed</h4><p><strong>Formal Specification</strong></p><ul><li>For each <var data-name="operation">operation</var> in <var data-name="document">document</var>:</li><li>Let <var data-name="variableUsages">variableUsages</var> be all usages transitively included in the <var data-name="operation">operation</var>.</li><li>For each <var data-name="variableUsage">variableUsage</var> in <var data-name="variableUsages">variableUsages</var>:<ul><li>Let <var data-name="variableName">variableName</var> be the name of <var data-name="variableUsage">variableUsage</var>.</li><li>Let <var data-name="variableDefinition">variableDefinition</var> be the <span class="spec-nt"><a href="#VariableDefinition" data-name="VariableDefinition">VariableDefinition</a></span> named <var data-name="variableName">variableName</var> defined within <var data-name="operation">operation</var>.</li><li><span class="spec-call"><a href="#IsVariableUsageAllowed()" data-name="IsVariableUsageAllowed">IsVariableUsageAllowed</a>(<var data-name="variableDefinition">variableDefinition</var>, <var data-name="variableUsage">variableUsage</var>)</span> must be <span class="spec-keyword">true</span>.</li></ul></li></ul><div class="spec-algo" id="IsVariableUsageAllowed()"><span class="spec-call"><a href="#IsVariableUsageAllowed()" data-name="IsVariableUsageAllowed">IsVariableUsageAllowed</a>(<var data-name="variableDefinition">variableDefinition</var>, <var data-name="variableUsage">variableUsage</var>)</span><ol><li>Let <var data-name="variableType">variableType</var> be the expected type of <var data-name="variableDefinition">variableDefinition</var>.</li><li>Let <var data-name="locationType">locationType</var> be the expected type of the <span class="spec-nt"><a href="#Argument" data-name="Argument">Argument</a></span>, <span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a></span>, or <span class="spec-nt"><a href="#ListValue" data-name="ListValue">ListValue</a></span> entry where <var data-name="variableUsage">variableUsage</var> is located.</li><li>If <var data-name="locationType">locationType</var> is a non&#8208;null type AND <var data-name="variableType">variableType</var> is NOT a non&#8208;null type:<ol><li>Let <var data-name="hasNonNullVariableDefaultValue">hasNonNullVariableDefaultValue</var> be <span class="spec-keyword">true</span> if a default value exists for <var data-name="variableDefinition">variableDefinition</var> and is not the value <span class="spec-keyword">null</span>.</li><li>Let <var data-name="hasLocationDefaultValue">hasLocationDefaultValue</var> be <span class="spec-keyword">true</span> if a default value exists for the <span class="spec-nt"><a href="#Argument" data-name="Argument">Argument</a></span> or <span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a></span> where <var data-name="variableUsage">variableUsage</var> is located.</li><li>If <var data-name="hasNonNullVariableDefaultValue">hasNonNullVariableDefaultValue</var> is NOT <span class="spec-keyword">true</span> AND <var data-name="hasLocationDefaultValue">hasLocationDefaultValue</var> is NOT <span class="spec-keyword">true</span>, return <span class="spec-keyword">false</span>.</li><li>Let <var data-name="nullableLocationType">nullableLocationType</var> be the unwrapped nullable type of <var data-name="locationType">locationType</var>.</li><li>Return <span class="spec-call"><a href="#AreTypesCompatible()" data-name="AreTypesCompatible">AreTypesCompatible</a>(<var data-name="variableType">variableType</var>, <var data-name="nullableLocationType">nullableLocationType</var>)</span>.</li></ol></li><li>Return <span class="spec-call"><a href="#AreTypesCompatible()" data-name="AreTypesCompatible">AreTypesCompatible</a>(<var data-name="variableType">variableType</var>, <var data-name="locationType">locationType</var>)</span>.</li></ol></div><div class="spec-algo" id="AreTypesCompatible()"><span class="spec-call"><a href="#AreTypesCompatible()" data-name="AreTypesCompatible">AreTypesCompatible</a>(<var data-name="variableType">variableType</var>, <var data-name="locationType">locationType</var>)</span><ol><li>If <var data-name="locationType">locationType</var> is a non&#8208;null type:<ol><li>If <var data-name="variableType">variableType</var> is NOT a non&#8208;null type, return <span class="spec-keyword">false</span>.</li><li>Let <var data-name="nullableLocationType">nullableLocationType</var> be the unwrapped nullable type of <var data-name="locationType">locationType</var>.</li><li>Let <var data-name="nullableVariableType">nullableVariableType</var> be the unwrapped nullable type of <var data-name="variableType">variableType</var>.</li><li>Return <span class="spec-call"><a href="#AreTypesCompatible()" data-name="AreTypesCompatible">AreTypesCompatible</a>(<var data-name="nullableVariableType">nullableVariableType</var>, <var data-name="nullableLocationType">nullableLocationType</var>)</span>.</li></ol></li><li>Otherwise, if <var data-name="variableType">variableType</var> is a non&#8208;null type:<ol><li>Let <var data-name="nullableVariableType">nullableVariableType</var> be the nullable type of <var data-name="variableType">variableType</var>.</li><li>Return <span class="spec-call"><a href="#AreTypesCompatible()" data-name="AreTypesCompatible">AreTypesCompatible</a>(<var data-name="nullableVariableType">nullableVariableType</var>, <var data-name="locationType">locationType</var>)</span>.</li></ol></li><li>Otherwise, if <var data-name="locationType">locationType</var> is a list type:<ol><li>If <var data-name="variableType">variableType</var> is NOT a list type, return <span class="spec-keyword">false</span>.</li><li>Let <var data-name="itemLocationType">itemLocationType</var> be the unwrapped item type of <var data-name="locationType">locationType</var>.</li><li>Let <var data-name="itemVariableType">itemVariableType</var> be the unwrapped item type of <var data-name="variableType">variableType</var>.</li><li>Return <span class="spec-call"><a href="#AreTypesCompatible()" data-name="AreTypesCompatible">AreTypesCompatible</a>(<var data-name="itemVariableType">itemVariableType</var>, <var data-name="itemLocationType">itemLocationType</var>)</span>.</li></ol></li><li>Otherwise, if <var data-name="variableType">variableType</var> is a list type, return <span class="spec-keyword">false</span>.</li><li>Return <span class="spec-keyword">true</span> if <var data-name="variableType">variableType</var> and <var data-name="locationType">locationType</var> are identical, otherwise <span class="spec-keyword">false</span>.</li></ol></div><p><strong>Explanatory Text</strong></p><p>Variable usages must be compatible with the arguments they are passed to.</p><p>Validation failures occur when variables are used in the context of types that are complete mismatches, or if a nullable type in a variable is passed to a non&#8208;null argument type.</p><p>Types must match:</p><pre id="example-2028e" class="spec-counter-example"><a href="#example-2028e">Counter Example № 169</a><code><span class="token keyword">query</span> intCannotGoIntoBoolean<span class="token punctuation">(</span><span class="token variable">$intArg</span><span class="token punctuation">:</span> Int<span class="token punctuation">)</span> <span class="token punctuation">{</span> arguments <span class="token punctuation">{</span> booleanArgField<span class="token punctuation">(</span><span class="token attr-name">booleanArg</span><span class="token punctuation">:</span> <span class="token variable">$intArg</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>$<var data-name="intArg">intArg</var> typed as <span class="spec-nt"><span data-name="Int">Int</span></span> cannot be used as a argument to <var data-name="booleanArg">booleanArg</var>, typed as <span class="spec-nt"><span data-name="Boolean">Boolean</span></span>.</p><p>List cardinality must also be the same. For example, lists cannot be passed into singular values.</p><pre id="example-8d369" class="spec-counter-example"><a href="#example-8d369">Counter Example № 170</a><code><span class="token keyword">query</span> booleanListCannotGoIntoBoolean<span class="token punctuation">(</span><span class="token variable">$booleanListArg</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Boolean<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> arguments <span class="token punctuation">{</span> booleanArgField<span class="token punctuation">(</span><span class="token attr-name">booleanArg</span><span class="token punctuation">:</span> <span class="token variable">$booleanListArg</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>Nullability must also be respected. In general a nullable variable cannot be passed to a non&#8208;null argument.</p><pre id="example-ed727" class="spec-counter-example"><a href="#example-ed727">Counter Example № 171</a><code><span class="token keyword">query</span> booleanArgQuery<span class="token punctuation">(</span><span class="token variable">$booleanArg</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> arguments <span class="token punctuation">{</span> nonNullBooleanArgField<span class="token punctuation">(</span><span class="token attr-name">nonNullBooleanArg</span><span class="token punctuation">:</span> <span class="token variable">$booleanArg</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>For list types, the same rules around nullability apply to both outer types and inner types. A nullable list cannot be passed to a non&#8208;null list, and a list of nullable values cannot be passed to a list of non&#8208;null values. The following is valid:</p><pre id="example-c5959" class="spec-example"><a href="#example-c5959">Example № 172</a><code><span class="token keyword">query</span> nonNullListToList<span class="token punctuation">(</span><span class="token variable">$nonNullBooleanList</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Boolean<span class="token punctuation">]</span><span class="token operator">!</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> arguments <span class="token punctuation">{</span> booleanListArgField<span class="token punctuation">(</span><span class="token attr-name">booleanListArg</span><span class="token punctuation">:</span> <span class="token variable">$nonNullBooleanList</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>However, a nullable list cannot be passed to a non&#8208;null list:</p><pre id="example-64255" class="spec-counter-example"><a href="#example-64255">Counter Example № 173</a><code><span class="token keyword">query</span> listToNonNullList<span class="token punctuation">(</span><span class="token variable">$booleanList</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>Boolean<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> arguments <span class="token punctuation">{</span> nonNullBooleanListField<span class="token punctuation">(</span><span class="token attr-name">nonNullBooleanListArg</span><span class="token punctuation">:</span> <span class="token variable">$booleanList</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>This would fail validation because a <code>[T]</code> cannot be passed to a <code>[T]!</code>. Similarly a <code>[T]</code> cannot be passed to a <code>[T!]</code>.</p><p><strong>Allowing optional variables when default values exist</strong></p><p>A notable exception to typical variable type compatibility is allowing a variable definition with a nullable type to be provided to a non&#8208;null location as long as either that variable or that location provides a default value.</p><pre id="example-0877c" class="spec-example"><a href="#example-0877c">Example № 174</a><code><span class="token keyword">query</span> booleanArgQueryWithDefault<span class="token punctuation">(</span><span class="token variable">$booleanArg</span><span class="token punctuation">:</span> Boolean<span class="token punctuation">)</span> <span class="token punctuation">{</span> arguments <span class="token punctuation">{</span> optionalNonNullBooleanArgField<span class="token punctuation">(</span><span class="token attr-name">optionalBooleanArg</span><span class="token punctuation">:</span> <span class="token variable">$booleanArg</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>In the example above, an optional variable is allowed to be used in an non&#8208;null argument which provides a default value.</p><pre id="example-d24d9" class="spec-example"><a href="#example-d24d9">Example № 175</a><code><span class="token keyword">query</span> booleanArgQueryWithDefault<span class="token punctuation">(</span><span class="token variable">$booleanArg</span><span class="token punctuation">:</span> Boolean <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> arguments <span class="token punctuation">{</span> nonNullBooleanArgField<span class="token punctuation">(</span><span class="token attr-name">nonNullBooleanArg</span><span class="token punctuation">:</span> <span class="token variable">$booleanArg</span><span class="token punctuation">)</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>In the example above, a variable provides a default value and can be used in a non&#8208;null argument. This behavior is explicitly supported for compatibility with earlier editions of this specification. GraphQL authoring tools may wish to report this is a warning with the suggestion to replace <code>Boolean</code> with <code>Boolean!</code>.</p><div class="spec-note">The value <span class="spec-keyword">null</span> could still be provided to a such a variable at runtime. A non&#8208;null argument must produce a field error if provided a <span class="spec-keyword">null</span> value. </div></section></section></section><section id="sec-Execution" secid="6"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Execution">6</a></span>Execution</h2><p>GraphQL generates a response from a request via execution.</p><p>A request for execution consists of a few pieces of information:</p><ul><li>The schema to use, typically solely provided by the GraphQL service.</li><li>A <span class="spec-nt"><a href="#Document" data-name="Document">Document</a></span> which must contain GraphQL <span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span> and may contain <span class="spec-nt"><a href="#FragmentDefinition" data-name="FragmentDefinition">FragmentDefinition</a></span>.</li><li>Optionally: The name of the Operation in the Document to execute.</li><li>Optionally: Values for any Variables defined by the Operation.</li><li>An initial value corresponding to the root type being executed. Conceptually, an initial value represents the &ldquo;universe&rdquo; of data available via a GraphQL Service. It is common for a GraphQL Service to always use the same initial value for every request.</li></ul><p>Given this information, the result of <span class="spec-call"><a href="#ExecuteRequest()" data-name="ExecuteRequest">ExecuteRequest</a>()</span> produces the response, to be formatted according to the Response section below.</p><section id="sec-Executing-Requests" secid="6.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Executing-Requests">6.1</a></span>Executing Requests</h3><p>To execute a request, the executor must have a parsed <span class="spec-nt"><a href="#Document" data-name="Document">Document</a></span> and a selected operation name to run if the document defines multiple operations, otherwise the document is expected to only contain a single operation. The result of the request is determined by the result of executing this operation according to the &ldquo;Executing Operations&rdquo; section below.</p><div class="spec-algo" id="ExecuteRequest()"><span class="spec-call"><a href="#ExecuteRequest()" data-name="ExecuteRequest">ExecuteRequest</a>(<var data-name="schema">schema</var>, <var data-name="document">document</var>, <var data-name="operationName">operationName</var>, <var data-name="variableValues">variableValues</var>, <var data-name="initialValue">initialValue</var>)</span><ol><li>Let <var data-name="operation">operation</var> be the result of <span class="spec-call"><a href="#GetOperation()" data-name="GetOperation">GetOperation</a>(<var data-name="document">document</var>, <var data-name="operationName">operationName</var>)</span>.</li><li>Let <var data-name="coercedVariableValues">coercedVariableValues</var> be the result of <span class="spec-call"><a href="#CoerceVariableValues()" data-name="CoerceVariableValues">CoerceVariableValues</a>(<var data-name="schema">schema</var>, <var data-name="operation">operation</var>, <var data-name="variableValues">variableValues</var>)</span>.</li><li>If <var data-name="operation">operation</var> is a query operation:<ol><li>Return <span class="spec-call"><a href="#ExecuteQuery()" data-name="ExecuteQuery">ExecuteQuery</a>(<var data-name="operation">operation</var>, <var data-name="schema">schema</var>, <var data-name="coercedVariableValues">coercedVariableValues</var>, <var data-name="initialValue">initialValue</var>)</span>.</li></ol></li><li>Otherwise if <var data-name="operation">operation</var> is a mutation operation:<ol><li>Return <span class="spec-call"><a href="#ExecuteMutation()" data-name="ExecuteMutation">ExecuteMutation</a>(<var data-name="operation">operation</var>, <var data-name="schema">schema</var>, <var data-name="coercedVariableValues">coercedVariableValues</var>, <var data-name="initialValue">initialValue</var>)</span>.</li></ol></li><li>Otherwise if <var data-name="operation">operation</var> is a subscription operation:<ol><li>Return <span class="spec-call"><a href="#Subscribe()" data-name="Subscribe">Subscribe</a>(<var data-name="operation">operation</var>, <var data-name="schema">schema</var>, <var data-name="coercedVariableValues">coercedVariableValues</var>, <var data-name="initialValue">initialValue</var>)</span>.</li></ol></li></ol></div><div class="spec-algo" id="GetOperation()"><span class="spec-call"><a href="#GetOperation()" data-name="GetOperation">GetOperation</a>(<var data-name="document">document</var>, <var data-name="operationName">operationName</var>)</span><ol><li>If <var data-name="operationName">operationName</var> is <span class="spec-keyword">null</span>:<ol><li>If <var data-name="document">document</var> contains exactly one operation.<ol><li>Return the Operation contained in the <var data-name="document">document</var>.</li></ol></li><li>Otherwise produce a query error requiring <var data-name="operationName">operationName</var>.</li></ol></li><li>Otherwise:<ol><li>Let <var data-name="operation">operation</var> be the Operation named <var data-name="operationName">operationName</var> in <var data-name="document">document</var>.</li><li>If <var data-name="operation">operation</var> was not found, produce a query error.</li><li>Return <var data-name="operation">operation</var>.</li></ol></li></ol></div><section id="sec-Validating-Requests" secid="6.1.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Validating-Requests">6.1.1</a></span>Validating Requests</h4><p>As explained in the Validation section, only requests which pass all validation rules should be executed. If validation errors are known, they should be reported in the list of &ldquo;errors&rdquo; in the response and the request must fail without execution.</p><p>Typically validation is performed in the context of a request immediately before execution, however a GraphQL service may execute a request without immediately validating it if that exact same request is known to have been validated before. A GraphQL service should only execute requests which <em>at some point</em> were known to be free of any validation errors, and have since not changed.</p><p>For example: the request may be validated during development, provided it does not later change, or a service may validate a request once and memoize the result to avoid validating the same request again in the future.</p></section><section id="sec-Coercing-Variable-Values" secid="6.1.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Coercing-Variable-Values">6.1.2</a></span>Coercing Variable Values</h4><p>If the operation has defined any variables, then the values for those variables need to be coerced using the input coercion rules of variable&rsquo;s declared type. If a query error is encountered during input coercion of variable values, then the operation fails without execution.</p><div class="spec-algo" id="CoerceVariableValues()"><span class="spec-call"><a href="#CoerceVariableValues()" data-name="CoerceVariableValues">CoerceVariableValues</a>(<var data-name="schema">schema</var>, <var data-name="operation">operation</var>, <var data-name="variableValues">variableValues</var>)</span><ol><li>Let <var data-name="coercedValues">coercedValues</var> be an empty unordered Map.</li><li>Let <var data-name="variableDefinitions">variableDefinitions</var> be the variables defined by <var data-name="operation">operation</var>.</li><li>For each <var data-name="variableDefinition">variableDefinition</var> in <var data-name="variableDefinitions">variableDefinitions</var>:<ol><li>Let <var data-name="variableName">variableName</var> be the name of <var data-name="variableDefinition">variableDefinition</var>.</li><li>Let <var data-name="variableType">variableType</var> be the expected type of <var data-name="variableDefinition">variableDefinition</var>.</li><li>Assert: <span class="spec-call"><a href="#IsInputType()" data-name="IsInputType">IsInputType</a>(<var data-name="variableType">variableType</var>)</span> must be <span class="spec-keyword">true</span>.</li><li>Let <var data-name="defaultValue">defaultValue</var> be the default value for <var data-name="variableDefinition">variableDefinition</var>.</li><li>Let <var data-name="hasValue">hasValue</var> be <span class="spec-keyword">true</span> if <var data-name="variableValues">variableValues</var> provides a value for the name <var data-name="variableName">variableName</var>.</li><li>Let <var data-name="value">value</var> be the value provided in <var data-name="variableValues">variableValues</var> for the name <var data-name="variableName">variableName</var>.</li><li>If <var data-name="hasValue">hasValue</var> is not <span class="spec-keyword">true</span> and <var data-name="defaultValue">defaultValue</var> exists (including <span class="spec-keyword">null</span>):<ol><li>Add an entry to <var data-name="coercedValues">coercedValues</var> named <var data-name="variableName">variableName</var> with the value <var data-name="defaultValue">defaultValue</var>.</li></ol></li><li>Otherwise if <var data-name="variableType">variableType</var> is a Non&#8208;Nullable type, and either <var data-name="hasValue">hasValue</var> is not <span class="spec-keyword">true</span> or <var data-name="value">value</var> is <span class="spec-keyword">null</span>, throw a query error.</li><li>Otherwise if <var data-name="hasValue">hasValue</var> is true:<ol><li>If <var data-name="value">value</var> is <span class="spec-keyword">null</span>:<ol><li>Add an entry to <var data-name="coercedValues">coercedValues</var> named <var data-name="variableName">variableName</var> with the value <span class="spec-keyword">null</span>.</li></ol></li><li>Otherwise:<ol><li>If <var data-name="value">value</var> cannot be coerced according to the input coercion rules of <var data-name="variableType">variableType</var>, throw a query error.</li><li>Let <var data-name="coercedValue">coercedValue</var> be the result of coercing <var data-name="value">value</var> according to the input coercion rules of <var data-name="variableType">variableType</var>.</li><li>Add an entry to <var data-name="coercedValues">coercedValues</var> named <var data-name="variableName">variableName</var> with the value <var data-name="coercedValue">coercedValue</var>.</li></ol></li></ol></li></ol></li><li>Return <var data-name="coercedValues">coercedValues</var>.</li></ol></div><div class="spec-note">This algorithm is very similar to <span class="spec-call"><a href="#CoerceArgumentValues()" data-name="CoerceArgumentValues">CoerceArgumentValues</a>()</span>.</div></section></section><section id="sec-Executing-Operations" secid="6.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Executing-Operations">6.2</a></span>Executing Operations</h3><p>The type system, as described in the &ldquo;Type System&rdquo; section of the spec, must provide a query root object type. If mutations or subscriptions are supported, it must also provide a mutation or subscription root object type, respectively.</p><section id="sec-Query" secid="6.2.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Query">6.2.1</a></span>Query</h4><p>If the operation is a query, the result of the operation is the result of executing the query&rsquo;s top level selection set with the query root object type.</p><p>An initial value may be provided when executing a query.</p><div class="spec-algo" id="ExecuteQuery()"><span class="spec-call"><a href="#ExecuteQuery()" data-name="ExecuteQuery">ExecuteQuery</a>(<var data-name="query">query</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>, <var data-name="initialValue">initialValue</var>)</span><ol><li>Let <var data-name="queryType">queryType</var> be the root Query type in <var data-name="schema">schema</var>.</li><li>Assert: <var data-name="queryType">queryType</var> is an Object type.</li><li>Let <var data-name="selectionSet">selectionSet</var> be the top level Selection Set in <var data-name="query">query</var>.</li><li>Let <var data-name="data">data</var> be the result of running <span class="spec-call"><a href="#ExecuteSelectionSet()" data-name="ExecuteSelectionSet">ExecuteSelectionSet</a>(<var data-name="selectionSet">selectionSet</var>, <var data-name="queryType">queryType</var>, <var data-name="initialValue">initialValue</var>, <var data-name="variableValues">variableValues</var>)</span> <em>normally</em> (allowing parallelization).</li><li>Let <var data-name="errors">errors</var> be any <em>field errors</em> produced while executing the selection set.</li><li>Return an unordered map containing <var data-name="data">data</var> and <var data-name="errors">errors</var>.</li></ol></div></section><section id="sec-Mutation" secid="6.2.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Mutation">6.2.2</a></span>Mutation</h4><p>If the operation is a mutation, the result of the operation is the result of executing the mutation&rsquo;s top level selection set on the mutation root object type. This selection set should be executed serially.</p><p>It is expected that the top level fields in a mutation operation perform side&#8208;effects on the underlying data system. Serial execution of the provided mutations ensures against race conditions during these side&#8208;effects.</p><div class="spec-algo" id="ExecuteMutation()"><span class="spec-call"><a href="#ExecuteMutation()" data-name="ExecuteMutation">ExecuteMutation</a>(<var data-name="mutation">mutation</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>, <var data-name="initialValue">initialValue</var>)</span><ol><li>Let <var data-name="mutationType">mutationType</var> be the root Mutation type in <var data-name="schema">schema</var>.</li><li>Assert: <var data-name="mutationType">mutationType</var> is an Object type.</li><li>Let <var data-name="selectionSet">selectionSet</var> be the top level Selection Set in <var data-name="mutation">mutation</var>.</li><li>Let <var data-name="data">data</var> be the result of running <span class="spec-call"><a href="#ExecuteSelectionSet()" data-name="ExecuteSelectionSet">ExecuteSelectionSet</a>(<var data-name="selectionSet">selectionSet</var>, <var data-name="mutationType">mutationType</var>, <var data-name="initialValue">initialValue</var>, <var data-name="variableValues">variableValues</var>)</span> <em>serially</em>.</li><li>Let <var data-name="errors">errors</var> be any <em>field errors</em> produced while executing the selection set.</li><li>Return an unordered map containing <var data-name="data">data</var> and <var data-name="errors">errors</var>.</li></ol></div></section><section id="sec-Subscription" secid="6.2.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Subscription">6.2.3</a></span>Subscription</h4><p>If the operation is a subscription, the result is an event stream called the &ldquo;Response Stream&rdquo; where each event in the event stream is the result of executing the operation for each new event on an underlying &ldquo;Source Stream&rdquo;.</p><p>Executing a subscription creates a persistent function on the server that maps an underlying Source Stream to a returned Response Stream.</p><div class="spec-algo" id="Subscribe()"><span class="spec-call"><a href="#Subscribe()" data-name="Subscribe">Subscribe</a>(<var data-name="subscription">subscription</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>, <var data-name="initialValue">initialValue</var>)</span><ol><li>Let <var data-name="sourceStream">sourceStream</var> be the result of running <span class="spec-call"><a href="#CreateSourceEventStream()" data-name="CreateSourceEventStream">CreateSourceEventStream</a>(<var data-name="subscription">subscription</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>, <var data-name="initialValue">initialValue</var>)</span>.</li><li>Let <var data-name="responseStream">responseStream</var> be the result of running <span class="spec-call"><a href="#MapSourceToResponseEvent()" data-name="MapSourceToResponseEvent">MapSourceToResponseEvent</a>(<var data-name="sourceStream">sourceStream</var>, <var data-name="subscription">subscription</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>)</span></li><li>Return <var data-name="responseStream">responseStream</var>.</li></ol></div><div class="spec-note">In large scale subscription systems, the <span class="spec-call"><a href="#Subscribe()" data-name="Subscribe">Subscribe</a>()</span> and <span class="spec-call"><a href="#ExecuteSubscriptionEvent()" data-name="ExecuteSubscriptionEvent">ExecuteSubscriptionEvent</a>()</span> algorithms may be run on separate services to maintain predictable scaling properties. See the section below on Supporting Subscriptions at Scale.</div><p>As an example, consider a chat application. To subscribe to new messages posted to the chat room, the client sends a request like so:</p><pre id="example-2a5f0" class="spec-example"><a href="#example-2a5f0">Example № 176</a><code>subscription NewMessages <span class="token punctuation">{</span> newMessage<span class="token punctuation">(</span><span class="token attr-name">roomId</span><span class="token punctuation">:</span> <span class="token number">123</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> sender text <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>While the client is subscribed, whenever new messages are posted to chat room with ID &ldquo;123&rdquo;, the selection for &ldquo;sender&rdquo; and &ldquo;text&rdquo; will be evaluated and published to the client, for example:</p><pre id="example-a4629" class="spec-example"><a href="#example-a4629">Example № 177</a><code><span class="token punctuation">{</span> <span class="token property">"data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"newMessage"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"sender"</span><span class="token operator">:</span> <span class="token string">"Hagrid"</span><span class="token punctuation">,</span> <span class="token property">"text"</span><span class="token operator">:</span> <span class="token string">"You're a wizard!"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>The &ldquo;new message posted to chat room&rdquo; could use a &ldquo;Pub&#8208;Sub&rdquo; system where the chat room ID is the &ldquo;topic&rdquo; and each &ldquo;publish&rdquo; contains the sender and text.</p><p><strong>Event Streams</strong></p><p>An event stream represents a sequence of discrete events over time which can be observed. As an example, a &ldquo;Pub&#8208;Sub&rdquo; system may produce an event stream when &ldquo;subscribing to a topic&rdquo;, with an event occurring on that event stream for each &ldquo;publish&rdquo; to that topic. Event streams may produce an infinite sequence of events or may complete at any point. Event streams may complete in response to an error or simply because no more events will occur. An observer may at any point decide to stop observing an event stream by cancelling it, after which it must receive no more events from that event stream.</p><p><strong>Supporting Subscriptions at Scale</strong></p><p>Supporting subscriptions is a significant change for any GraphQL service. Query and mutation operations are stateless, allowing scaling via cloning of GraphQL server instances. Subscriptions, by contrast, are stateful and require maintaining the GraphQL document, variables, and other context over the lifetime of the subscription.</p><p>Consider the behavior of your system when state is lost due to the failure of a single machine in a service. Durability and availability may be improved by having separate dedicated services for managing subscription state and client connectivity.</p><p><strong>Delivery Agnostic</strong></p><p>GraphQL subscriptions do not require any specific serialization format or transport mechanism. Subscriptions specifies algorithms for the creation of a stream, the content of each payload on that stream, and the closing of that stream. There are intentionally no specifications for message acknoledgement, buffering, resend requests, or any other quality of service (QoS) details. Message serialization, transport mechanisms, and quality of service details should be chosen by the implementing service.</p><section id="sec-Source-Stream" secid="6.2.3.1"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Source-Stream">6.2.3.1</a></span>Source Stream</h5><p>A Source Stream represents the sequence of events, each of which will trigger a GraphQL execution corresponding to that event. Like field value resolution, the logic to create a Source Stream is application&#8208;specific.</p><div class="spec-algo" id="CreateSourceEventStream()"><span class="spec-call"><a href="#CreateSourceEventStream()" data-name="CreateSourceEventStream">CreateSourceEventStream</a>(<var data-name="subscription">subscription</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>, <var data-name="initialValue">initialValue</var>)</span><ol><li>Let <var data-name="subscriptionType">subscriptionType</var> be the root Subscription type in <var data-name="schema">schema</var>.</li><li>Assert: <var data-name="subscriptionType">subscriptionType</var> is an Object type.</li><li>Let <var data-name="groupedFieldSet">groupedFieldSet</var> be the result of <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>(<var data-name="subscriptionType">subscriptionType</var>, <var data-name="selectionSet">selectionSet</var>, <var data-name="variableValues">variableValues</var>)</span>.</li><li>If <var data-name="groupedFieldSet">groupedFieldSet</var> does not have exactly one entry, throw a query error.</li><li>Let <var data-name="fields">fields</var> be the value of the first entry in <var data-name="groupedFieldSet">groupedFieldSet</var>.</li><li>Let <var data-name="fieldName">fieldName</var> be the name of the first entry in <var data-name="fields">fields</var>. Note: This value is unaffected if an alias is used.</li><li>Let <var data-name="field">field</var> be the first entry in <var data-name="fields">fields</var>.</li><li>Let <var data-name="argumentValues">argumentValues</var> be the result of <span class="spec-call"><a href="#CoerceArgumentValues()" data-name="CoerceArgumentValues">CoerceArgumentValues</a>(<var data-name="subscriptionType">subscriptionType</var>, <var data-name="field">field</var>, <var data-name="variableValues">variableValues</var>)</span></li><li>Let <var data-name="fieldStream">fieldStream</var> be the result of running <span class="spec-call"><a href="#ResolveFieldEventStream()" data-name="ResolveFieldEventStream">ResolveFieldEventStream</a>(<var data-name="subscriptionType">subscriptionType</var>, <var data-name="initialValue">initialValue</var>, <var data-name="fieldName">fieldName</var>, <var data-name="argumentValues">argumentValues</var>)</span>.</li><li>Return <var data-name="fieldStream">fieldStream</var>.</li></ol></div><div class="spec-algo" id="ResolveFieldEventStream()"><span class="spec-call"><a href="#ResolveFieldEventStream()" data-name="ResolveFieldEventStream">ResolveFieldEventStream</a>(<var data-name="subscriptionType">subscriptionType</var>, <var data-name="rootValue">rootValue</var>, <var data-name="fieldName">fieldName</var>, <var data-name="argumentValues">argumentValues</var>)</span><ol><li>Let <var data-name="resolver">resolver</var> be the internal function provided by <var data-name="subscriptionType">subscriptionType</var> for determining the resolved event stream of a subscription field named <var data-name="fieldName">fieldName</var>.</li><li>Return the result of calling <var data-name="resolver">resolver</var>, providing <var data-name="rootValue">rootValue</var> and <var data-name="argumentValues">argumentValues</var>.</li></ol></div><div class="spec-note">This <span class="spec-call"><a href="#ResolveFieldEventStream()" data-name="ResolveFieldEventStream">ResolveFieldEventStream</a>()</span> algorithm is intentionally similar to <span class="spec-call"><a href="#ResolveFieldValue()" data-name="ResolveFieldValue">ResolveFieldValue</a>()</span> to enable consistency when defining resolvers on any operation type.</div></section><section id="sec-Response-Stream" secid="6.2.3.2"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Response-Stream">6.2.3.2</a></span>Response Stream</h5><p>Each event in the underlying Source Stream triggers execution of the subscription selection set using that event as a root value.</p><div class="spec-algo" id="MapSourceToResponseEvent()"><span class="spec-call"><a href="#MapSourceToResponseEvent()" data-name="MapSourceToResponseEvent">MapSourceToResponseEvent</a>(<var data-name="sourceStream">sourceStream</var>, <var data-name="subscription">subscription</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>)</span><ol><li>Return a new event stream <var data-name="responseStream">responseStream</var> which yields events as follows:</li><li>For each <var data-name="event">event</var> on <var data-name="sourceStream">sourceStream</var>:<ol><li>Let <var data-name="response">response</var> be the result of running <span class="spec-call"><a href="#ExecuteSubscriptionEvent()" data-name="ExecuteSubscriptionEvent">ExecuteSubscriptionEvent</a>(<var data-name="subscription">subscription</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>, <var data-name="event">event</var>)</span>.</li><li>Yield an event containing <var data-name="response">response</var>.</li></ol></li><li>When <var data-name="responseStream">responseStream</var> completes: complete this event stream.</li></ol></div><div class="spec-algo" id="ExecuteSubscriptionEvent()"><span class="spec-call"><a href="#ExecuteSubscriptionEvent()" data-name="ExecuteSubscriptionEvent">ExecuteSubscriptionEvent</a>(<var data-name="subscription">subscription</var>, <var data-name="schema">schema</var>, <var data-name="variableValues">variableValues</var>, <var data-name="initialValue">initialValue</var>)</span><ol><li>Let <var data-name="subscriptionType">subscriptionType</var> be the root Subscription type in <var data-name="schema">schema</var>.</li><li>Assert: <var data-name="subscriptionType">subscriptionType</var> is an Object type.</li><li>Let <var data-name="selectionSet">selectionSet</var> be the top level Selection Set in <var data-name="subscription">subscription</var>.</li><li>Let <var data-name="data">data</var> be the result of running <span class="spec-call"><a href="#ExecuteSelectionSet()" data-name="ExecuteSelectionSet">ExecuteSelectionSet</a>(<var data-name="selectionSet">selectionSet</var>, <var data-name="subscriptionType">subscriptionType</var>, <var data-name="initialValue">initialValue</var>, <var data-name="variableValues">variableValues</var>)</span> <em>normally</em> (allowing parallelization).</li><li>Let <var data-name="errors">errors</var> be any <em>field errors</em> produced while executing the selection set.</li><li>Return an unordered map containing <var data-name="data">data</var> and <var data-name="errors">errors</var>.</li></ol></div><div class="spec-note">The <span class="spec-call"><a href="#ExecuteSubscriptionEvent()" data-name="ExecuteSubscriptionEvent">ExecuteSubscriptionEvent</a>()</span> algorithm is intentionally similar to <span class="spec-call"><a href="#ExecuteQuery()" data-name="ExecuteQuery">ExecuteQuery</a>()</span> since this is how each event result is produced.</div></section><section id="sec-Unsubscribe" secid="6.2.3.3"><h5><span class="spec-secid" title="link to this section"><a href="#sec-Unsubscribe">6.2.3.3</a></span>Unsubscribe</h5><p>Unsubscribe cancels the Response Stream when a client no longer wishes to receive payloads for a subscription. This may in turn also cancel the Source Stream. This is also a good opportunity to clean up any other resources used by the subscription.</p><div class="spec-algo" id="Unsubscribe()"><span class="spec-call"><a href="#Unsubscribe()" data-name="Unsubscribe">Unsubscribe</a>(<var data-name="responseStream">responseStream</var>)</span><ol><li>Cancel <var data-name="responseStream">responseStream</var></li></ol></div></section></section></section><section id="sec-Executing-Selection-Sets" secid="6.3"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Executing-Selection-Sets">6.3</a></span>Executing Selection Sets</h3><p>To execute a selection set, the object value being evaluated and the object type need to be known, as well as whether it must be executed serially, or may be executed in parallel.</p><p>First, the selection set is turned into a grouped field set; then, each represented field in the grouped field set produces an entry into a response map.</p><div class="spec-algo" id="ExecuteSelectionSet()"><span class="spec-call"><a href="#ExecuteSelectionSet()" data-name="ExecuteSelectionSet">ExecuteSelectionSet</a>(<var data-name="selectionSet">selectionSet</var>, <var data-name="objectType">objectType</var>, <var data-name="objectValue">objectValue</var>, <var data-name="variableValues">variableValues</var>)</span><ol><li>Let <var data-name="groupedFieldSet">groupedFieldSet</var> be the result of <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>(<var data-name="objectType">objectType</var>, <var data-name="selectionSet">selectionSet</var>, <var data-name="variableValues">variableValues</var>)</span>.</li><li>Initialize <var data-name="resultMap">resultMap</var> to an empty ordered map.</li><li>For each <var data-name="groupedFieldSet">groupedFieldSet</var> as <var data-name="responseKey">responseKey</var> and <var data-name="fields">fields</var>:<ol><li>Let <var data-name="fieldName">fieldName</var> be the name of the first entry in <var data-name="fields">fields</var>. Note: This value is unaffected if an alias is used.</li><li>Let <var data-name="fieldType">fieldType</var> be the return type defined for the field <var data-name="fieldName">fieldName</var> of <var data-name="objectType">objectType</var>.</li><li>If <var data-name="fieldType">fieldType</var> is defined:<ol><li>Let <var data-name="responseValue">responseValue</var> be <span class="spec-call"><a href="#ExecuteField()" data-name="ExecuteField">ExecuteField</a>(<var data-name="objectType">objectType</var>, <var data-name="objectValue">objectValue</var>, <var data-name="fields">fields</var>, <var data-name="fieldType">fieldType</var>, <var data-name="variableValues">variableValues</var>)</span>.</li><li>Set <var data-name="responseValue">responseValue</var> as the value for <var data-name="responseKey">responseKey</var> in <var data-name="resultMap">resultMap</var>.</li></ol></li></ol></li><li>Return <var data-name="resultMap">resultMap</var>.</li></ol></div><div class="spec-note"><var data-name="resultMap">resultMap</var> is ordered by which fields appear first in the query. This is explained in greater detail in the Field Collection section below.</div><p><strong>Errors and Non&#8208;Null Fields</strong></p><p>If during <span class="spec-call"><a href="#ExecuteSelectionSet()" data-name="ExecuteSelectionSet">ExecuteSelectionSet</a>()</span> a field with a non&#8208;null <var data-name="fieldType">fieldType</var> throws a field error then that error must propagate to this entire selection set, either resolving to <span class="spec-keyword">null</span> if allowed or further propagated to a parent field.</p><p>If this occurs, any sibling fields which have not yet executed or have not yet yielded a value may be cancelled to avoid unnecessary work.</p><p>See the <a href="#sec-Errors-and-Non-Nullability">Errors and Non&#8208;Nullability</a> section of Field Execution for more about this behavior.</p><section id="sec-Normal-and-Serial-Execution" secid="6.3.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Normal-and-Serial-Execution">6.3.1</a></span>Normal and Serial Execution</h4><p>Normally the executor can execute the entries in a grouped field set in whatever order it chooses (normally in parallel). Because the resolution of fields other than top&#8208;level mutation fields must always be side effect&#8208;free and idempotent, the execution order must not affect the result, and hence the server has the freedom to execute the field entries in whatever order it deems optimal.</p><p>For example, given the following grouped field set to be executed normally:</p><pre id="example-65e7d" class="spec-example"><a href="#example-65e7d">Example № 178</a><code><span class="token punctuation">{</span> birthday <span class="token punctuation">{</span> month <span class="token punctuation">}</span> address <span class="token punctuation">{</span> street <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>A valid GraphQL executor can resolve the four fields in whatever order it chose (however of course <code>birthday</code> must be resolved before <code>month</code>, and <code>address</code> before <code>street</code>).</p><p>When executing a mutation, the selections in the top most selection set will be executed in serial order, starting with the first appearing field textually.</p><p>When executing a grouped field set serially, the executor must consider each entry from the grouped field set in the order provided in the grouped field set. It must determine the corresponding entry in the result map for each item to completion before it continues on to the next item in the grouped field set:</p><p>For example, given the following selection set to be executed serially:</p><pre id="example-33b6a" class="spec-example"><a href="#example-33b6a">Example № 179</a><code><span class="token punctuation">{</span> changeBirthday<span class="token punctuation">(</span><span class="token attr-name">birthday</span><span class="token punctuation">:</span> <span class="token variable">$newBirthday</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> month <span class="token punctuation">}</span> changeAddress<span class="token punctuation">(</span><span class="token attr-name">address</span><span class="token punctuation">:</span> <span class="token variable">$newAddress</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> street <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>The executor must, in serial:</p><ul><li>Run <span class="spec-call"><a href="#ExecuteField()" data-name="ExecuteField">ExecuteField</a>()</span> for <code>changeBirthday</code>, which during <span class="spec-call"><a href="#CompleteValue()" data-name="CompleteValue">CompleteValue</a>()</span> will execute the <code>{ month }</code> sub&#8208;selection set normally.</li><li>Run <span class="spec-call"><a href="#ExecuteField()" data-name="ExecuteField">ExecuteField</a>()</span> for <code>changeAddress</code>, which during <span class="spec-call"><a href="#CompleteValue()" data-name="CompleteValue">CompleteValue</a>()</span> will execute the <code>{ street }</code> sub&#8208;selection set normally.</li></ul><p>As an illustrative example, let&rsquo;s assume we have a mutation field <code>changeTheNumber</code> that returns an object containing one field, <code>theNumber</code>. If we execute the following selection set serially:</p><pre id="example-c91a3" class="spec-example"><a href="#example-c91a3">Example № 180</a><code><span class="token punctuation">{</span> <span class="token attr-name">first</span><span class="token punctuation">:</span> changeTheNumber<span class="token punctuation">(</span><span class="token attr-name">newNumber</span><span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> theNumber <span class="token punctuation">}</span> <span class="token attr-name">second</span><span class="token punctuation">:</span> changeTheNumber<span class="token punctuation">(</span><span class="token attr-name">newNumber</span><span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> theNumber <span class="token punctuation">}</span> <span class="token attr-name">third</span><span class="token punctuation">:</span> changeTheNumber<span class="token punctuation">(</span><span class="token attr-name">newNumber</span><span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> theNumber <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>The executor will execute the following serially:</p><ul><li>Resolve the <code>changeTheNumber(newNumber: 1)</code> field</li><li>Execute the <code>{ theNumber }</code> sub&#8208;selection set of <code>first</code> normally</li><li>Resolve the <code>changeTheNumber(newNumber: 3)</code> field</li><li>Execute the <code>{ theNumber }</code> sub&#8208;selection set of <code>second</code> normally</li><li>Resolve the <code>changeTheNumber(newNumber: 2)</code> field</li><li>Execute the <code>{ theNumber }</code> sub&#8208;selection set of <code>third</code> normally</li></ul><p>A correct executor must generate the following result for that selection set:</p><pre id="example-1d82c" class="spec-example"><a href="#example-1d82c">Example № 181</a><code><span class="token punctuation">{</span> <span class="token property">"first"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"theNumber"</span><span class="token operator">:</span> <span class="token number">1</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token property">"second"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"theNumber"</span><span class="token operator">:</span> <span class="token number">3</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token property">"third"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"theNumber"</span><span class="token operator">:</span> <span class="token number">2</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre></section><section id="sec-Field-Collection" secid="6.3.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Field-Collection">6.3.2</a></span>Field Collection</h4><p>Before execution, the selection set is converted to a grouped field set by calling <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>()</span>. Each entry in the grouped field set is a list of fields that share a response key (the alias if defined, otherwise the field name). This ensures all fields with the same response key included via referenced fragments are executed at the same time.</p><p>As an example, collecting the fields of this selection set would collect two instances of the field <code>a</code> and one of field <code>b</code>:</p><pre id="example-fdbb7" class="spec-example"><a href="#example-fdbb7">Example № 182</a><code><span class="token punctuation">{</span> a <span class="token punctuation">{</span> subfield1 <span class="token punctuation">}</span> <span class="token operator">...</span>ExampleFragment <span class="token punctuation">}</span> <span class="token keyword">fragment</span> ExampleFragment on Query <span class="token punctuation">{</span> a <span class="token punctuation">{</span> subfield2 <span class="token punctuation">}</span> b <span class="token punctuation">}</span> </code></pre><p>The depth&#8208;first&#8208;search order of the field groups produced by <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>()</span> is maintained through execution, ensuring that fields appear in the executed response in a stable and predictable order.</p><div class="spec-algo" id="CollectFields()"><span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>(<var data-name="objectType">objectType</var>, <var data-name="selectionSet">selectionSet</var>, <var data-name="variableValues">variableValues</var>, <var data-name="visitedFragments">visitedFragments</var>)</span><ol><li>If <var data-name="visitedFragments">visitedFragments</var> if not provided, initialize it to the empty set.</li><li>Initialize <var data-name="groupedFields">groupedFields</var> to an empty ordered map of lists.</li><li>For each <var data-name="selection">selection</var> in <var data-name="selectionSet">selectionSet</var>:<ol><li>If <var data-name="selection">selection</var> provides the directive <code>@skip</code>, let <var data-name="skipDirective">skipDirective</var> be that directive.<ol><li>If <var data-name="skipDirective">skipDirective</var>&lsquo;s <var data-name="if">if</var> argument is <span class="spec-keyword">true</span> or is a variable in <var data-name="variableValues">variableValues</var> with the value <span class="spec-keyword">true</span>, continue with the next <var data-name="selection">selection</var> in <var data-name="selectionSet">selectionSet</var>.</li></ol></li><li>If <var data-name="selection">selection</var> provides the directive <code>@include</code>, let <var data-name="includeDirective">includeDirective</var> be that directive.<ol><li>If <var data-name="includeDirective">includeDirective</var>&lsquo;s <var data-name="if">if</var> argument is not <span class="spec-keyword">true</span> and is not a variable in <var data-name="variableValues">variableValues</var> with the value <span class="spec-keyword">true</span>, continue with the next <var data-name="selection">selection</var> in <var data-name="selectionSet">selectionSet</var>.</li></ol></li><li>If <var data-name="selection">selection</var> is a <span class="spec-nt"><a href="#Field" data-name="Field">Field</a></span>:<ol><li>Let <var data-name="responseKey">responseKey</var> be the response key of <var data-name="selection">selection</var> (the alias if defined, otherwise the field name).</li><li>Let <var data-name="groupForResponseKey">groupForResponseKey</var> be the list in <var data-name="groupedFields">groupedFields</var> for <var data-name="responseKey">responseKey</var>; if no such list exists, create it as an empty list.</li><li>Append <var data-name="selection">selection</var> to the <var data-name="groupForResponseKey">groupForResponseKey</var>.</li></ol></li><li>If <var data-name="selection">selection</var> is a <span class="spec-nt"><a href="#FragmentSpread" data-name="FragmentSpread">FragmentSpread</a></span>:<ol><li>Let <var data-name="fragmentSpreadName">fragmentSpreadName</var> be the name of <var data-name="selection">selection</var>.</li><li>If <var data-name="fragmentSpreadName">fragmentSpreadName</var> is in <var data-name="visitedFragments">visitedFragments</var>, continue with the next <var data-name="selection">selection</var> in <var data-name="selectionSet">selectionSet</var>.</li><li>Add <var data-name="fragmentSpreadName">fragmentSpreadName</var> to <var data-name="visitedFragments">visitedFragments</var>.</li><li>Let <var data-name="fragment">fragment</var> be the Fragment in the current Document whose name is <var data-name="fragmentSpreadName">fragmentSpreadName</var>.</li><li>If no such <var data-name="fragment">fragment</var> exists, continue with the next <var data-name="selection">selection</var> in <var data-name="selectionSet">selectionSet</var>.</li><li>Let <var data-name="fragmentType">fragmentType</var> be the type condition on <var data-name="fragment">fragment</var>.</li><li>If <span class="spec-call"><a href="#DoesFragmentTypeApply()" data-name="DoesFragmentTypeApply">DoesFragmentTypeApply</a>(<var data-name="objectType">objectType</var>, <var data-name="fragmentType">fragmentType</var>)</span> is false, continue with the next <var data-name="selection">selection</var> in <var data-name="selectionSet">selectionSet</var>.</li><li>Let <var data-name="fragmentSelectionSet">fragmentSelectionSet</var> be the top&#8208;level selection set of <var data-name="fragment">fragment</var>.</li><li>Let <var data-name="fragmentGroupedFieldSet">fragmentGroupedFieldSet</var> be the result of calling <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>(<var data-name="objectType">objectType</var>, <var data-name="fragmentSelectionSet">fragmentSelectionSet</var>, <var data-name="visitedFragments">visitedFragments</var>)</span>.</li><li>For each <var data-name="fragmentGroup">fragmentGroup</var> in <var data-name="fragmentGroupedFieldSet">fragmentGroupedFieldSet</var>:<ol><li>Let <var data-name="responseKey">responseKey</var> be the response key shared by all fields in <var data-name="fragmentGroup">fragmentGroup</var>.</li><li>Let <var data-name="groupForResponseKey">groupForResponseKey</var> be the list in <var data-name="groupedFields">groupedFields</var> for <var data-name="responseKey">responseKey</var>; if no such list exists, create it as an empty list.</li><li>Append all items in <var data-name="fragmentGroup">fragmentGroup</var> to <var data-name="groupForResponseKey">groupForResponseKey</var>.</li></ol></li></ol></li><li>If <var data-name="selection">selection</var> is an <span class="spec-nt"><a href="#InlineFragment" data-name="InlineFragment">InlineFragment</a></span>:<ol><li>Let <var data-name="fragmentType">fragmentType</var> be the type condition on <var data-name="selection">selection</var>.</li><li>If <var data-name="fragmentType">fragmentType</var> is not <span class="spec-keyword">null</span> and <span class="spec-call"><a href="#DoesFragmentTypeApply()" data-name="DoesFragmentTypeApply">DoesFragmentTypeApply</a>(<var data-name="objectType">objectType</var>, <var data-name="fragmentType">fragmentType</var>)</span> is false, continue with the next <var data-name="selection">selection</var> in <var data-name="selectionSet">selectionSet</var>.</li><li>Let <var data-name="fragmentSelectionSet">fragmentSelectionSet</var> be the top&#8208;level selection set of <var data-name="selection">selection</var>.</li><li>Let <var data-name="fragmentGroupedFieldSet">fragmentGroupedFieldSet</var> be the result of calling <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>(<var data-name="objectType">objectType</var>, <var data-name="fragmentSelectionSet">fragmentSelectionSet</var>, <var data-name="variableValues">variableValues</var>, <var data-name="visitedFragments">visitedFragments</var>)</span>.</li><li>For each <var data-name="fragmentGroup">fragmentGroup</var> in <var data-name="fragmentGroupedFieldSet">fragmentGroupedFieldSet</var>:<ol><li>Let <var data-name="responseKey">responseKey</var> be the response key shared by all fields in <var data-name="fragmentGroup">fragmentGroup</var>.</li><li>Let <var data-name="groupForResponseKey">groupForResponseKey</var> be the list in <var data-name="groupedFields">groupedFields</var> for <var data-name="responseKey">responseKey</var>; if no such list exists, create it as an empty list.</li><li>Append all items in <var data-name="fragmentGroup">fragmentGroup</var> to <var data-name="groupForResponseKey">groupForResponseKey</var>.</li></ol></li></ol></li></ol></li><li>Return <var data-name="groupedFields">groupedFields</var>.</li></ol></div><div class="spec-algo" id="DoesFragmentTypeApply()"><span class="spec-call"><a href="#DoesFragmentTypeApply()" data-name="DoesFragmentTypeApply">DoesFragmentTypeApply</a>(<var data-name="objectType">objectType</var>, <var data-name="fragmentType">fragmentType</var>)</span><ol><li>If <var data-name="fragmentType">fragmentType</var> is an Object Type:<ol><li>if <var data-name="objectType">objectType</var> and <var data-name="fragmentType">fragmentType</var> are the same type, return <span class="spec-keyword">true</span>, otherwise return <span class="spec-keyword">false</span>.</li></ol></li><li>If <var data-name="fragmentType">fragmentType</var> is an Interface Type:<ol><li>if <var data-name="objectType">objectType</var> is an implementation of <var data-name="fragmentType">fragmentType</var>, return <span class="spec-keyword">true</span> otherwise return <span class="spec-keyword">false</span>.</li></ol></li><li>If <var data-name="fragmentType">fragmentType</var> is a Union:<ol><li>if <var data-name="objectType">objectType</var> is a possible type of <var data-name="fragmentType">fragmentType</var>, return <span class="spec-keyword">true</span> otherwise return <span class="spec-keyword">false</span>.</li></ol></li></ol></div></section></section><section id="sec-Executing-Fields" secid="6.4"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Executing-Fields">6.4</a></span>Executing Fields</h3><p>Each field requested in the grouped field set that is defined on the selected objectType will result in an entry in the response map. Field execution first coerces any provided argument values, then resolves a value for the field, and finally completes that value either by recursively executing another selection set or coercing a scalar value.</p><div class="spec-algo" id="ExecuteField()"><span class="spec-call"><a href="#ExecuteField()" data-name="ExecuteField">ExecuteField</a>(<var data-name="objectType">objectType</var>, <var data-name="objectValue">objectValue</var>, <var data-name="fieldType">fieldType</var>, <var data-name="fields">fields</var>, <var data-name="variableValues">variableValues</var>)</span><ol><li>Let <var data-name="field">field</var> be the first entry in <var data-name="fields">fields</var>.</li><li>Let <var data-name="fieldName">fieldName</var> be the field name of <var data-name="field">field</var>.</li><li>Let <var data-name="argumentValues">argumentValues</var> be the result of <span class="spec-call"><a href="#CoerceArgumentValues()" data-name="CoerceArgumentValues">CoerceArgumentValues</a>(<var data-name="objectType">objectType</var>, <var data-name="field">field</var>, <var data-name="variableValues">variableValues</var>)</span></li><li>Let <var data-name="resolvedValue">resolvedValue</var> be <span class="spec-call"><a href="#ResolveFieldValue()" data-name="ResolveFieldValue">ResolveFieldValue</a>(<var data-name="objectType">objectType</var>, <var data-name="objectValue">objectValue</var>, <var data-name="fieldName">fieldName</var>, <var data-name="argumentValues">argumentValues</var>)</span>.</li><li>Return the result of <span class="spec-call"><a href="#CompleteValue()" data-name="CompleteValue">CompleteValue</a>(<var data-name="fieldType">fieldType</var>, <var data-name="fields">fields</var>, <var data-name="resolvedValue">resolvedValue</var>, <var data-name="variableValues">variableValues</var>)</span>.</li></ol></div><section id="sec-Coercing-Field-Arguments" secid="6.4.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Coercing-Field-Arguments">6.4.1</a></span>Coercing Field Arguments</h4><p>Fields may include arguments which are provided to the underlying runtime in order to correctly produce a value. These arguments are defined by the field in the type system to have a specific input type.</p><p>At each argument position in a query may be a literal <span class="spec-nt"><a href="#Value" data-name="Value">Value</a></span>, or a <span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span> to be provided at runtime.</p><div class="spec-algo" id="CoerceArgumentValues()"><span class="spec-call"><a href="#CoerceArgumentValues()" data-name="CoerceArgumentValues">CoerceArgumentValues</a>(<var data-name="objectType">objectType</var>, <var data-name="field">field</var>, <var data-name="variableValues">variableValues</var>)</span><ol><li>Let <var data-name="coercedValues">coercedValues</var> be an empty unordered Map.</li><li>Let <var data-name="argumentValues">argumentValues</var> be the argument values provided in <var data-name="field">field</var>.</li><li>Let <var data-name="fieldName">fieldName</var> be the name of <var data-name="field">field</var>.</li><li>Let <var data-name="argumentDefinitions">argumentDefinitions</var> be the arguments defined by <var data-name="objectType">objectType</var> for the field named <var data-name="fieldName">fieldName</var>.</li><li>For each <var data-name="argumentDefinition">argumentDefinition</var> in <var data-name="argumentDefinitions">argumentDefinitions</var>:<ol><li>Let <var data-name="argumentName">argumentName</var> be the name of <var data-name="argumentDefinition">argumentDefinition</var>.</li><li>Let <var data-name="argumentType">argumentType</var> be the expected type of <var data-name="argumentDefinition">argumentDefinition</var>.</li><li>Let <var data-name="defaultValue">defaultValue</var> be the default value for <var data-name="argumentDefinition">argumentDefinition</var>.</li><li>Let <var data-name="hasValue">hasValue</var> be <span class="spec-keyword">true</span> if <var data-name="argumentValues">argumentValues</var> provides a value for the name <var data-name="argumentName">argumentName</var>.</li><li>Let <var data-name="argumentValue">argumentValue</var> be the value provided in <var data-name="argumentValues">argumentValues</var> for the name <var data-name="argumentName">argumentName</var>.</li><li>If <var data-name="argumentValue">argumentValue</var> is a <span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span>:<ol><li>Let <var data-name="variableName">variableName</var> be the name of <var data-name="argumentValue">argumentValue</var>.</li><li>Let <var data-name="hasValue">hasValue</var> be <span class="spec-keyword">true</span> if <var data-name="variableValues">variableValues</var> provides a value for the name <var data-name="variableName">variableName</var>.</li><li>Let <var data-name="value">value</var> be the value provided in <var data-name="variableValues">variableValues</var> for the name <var data-name="variableName">variableName</var>.</li></ol></li><li>Otherwise, let <var data-name="value">value</var> be <var data-name="argumentValue">argumentValue</var>.</li><li>If <var data-name="hasValue">hasValue</var> is not <span class="spec-keyword">true</span> and <var data-name="defaultValue">defaultValue</var> exists (including <span class="spec-keyword">null</span>):<ol><li>Add an entry to <var data-name="coercedValues">coercedValues</var> named <var data-name="argumentName">argumentName</var> with the value <var data-name="defaultValue">defaultValue</var>.</li></ol></li><li>Otherwise if <var data-name="argumentType">argumentType</var> is a Non&#8208;Nullable type, and either <var data-name="hasValue">hasValue</var> is not <span class="spec-keyword">true</span> or <var data-name="value">value</var> is <span class="spec-keyword">null</span>, throw a field error.</li><li>Otherwise if <var data-name="hasValue">hasValue</var> is true:<ol><li>If <var data-name="value">value</var> is <span class="spec-keyword">null</span>:<ol><li>Add an entry to <var data-name="coercedValues">coercedValues</var> named <var data-name="argumentName">argumentName</var> with the value <span class="spec-keyword">null</span>.</li></ol></li><li>Otherwise, if <var data-name="argumentValue">argumentValue</var> is a <span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span>:<ol><li>Add an entry to <var data-name="coercedValues">coercedValues</var> named <var data-name="argumentName">argumentName</var> with the value <var data-name="value">value</var>.</li></ol></li><li>Otherwise:<ol><li>If <var data-name="value">value</var> cannot be coerced according to the input coercion rules of <var data-name="variableType">variableType</var>, throw a field error.</li><li>Let <var data-name="coercedValue">coercedValue</var> be the result of coercing <var data-name="value">value</var> according to the input coercion rules of <var data-name="variableType">variableType</var>.</li><li>Add an entry to <var data-name="coercedValues">coercedValues</var> named <var data-name="argumentName">argumentName</var> with the value <var data-name="coercedValue">coercedValue</var>.</li></ol></li></ol></li></ol></li><li>Return <var data-name="coercedValues">coercedValues</var>.</li></ol></div><div class="spec-note">Variable values are not coerced because they are expected to be coerced before executing the operation in <span class="spec-call"><a href="#CoerceVariableValues()" data-name="CoerceVariableValues">CoerceVariableValues</a>()</span>, and valid queries must only allow usage of variables of appropriate types.</div></section><section id="sec-Value-Resolution" secid="6.4.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Value-Resolution">6.4.2</a></span>Value Resolution</h4><p>While nearly all of GraphQL execution can be described generically, ultimately the internal system exposing the GraphQL interface must provide values. This is exposed via <span class="spec-nt"><span data-name="ResolveFieldValue">ResolveFieldValue</span></span>, which produces a value for a given field on a type for a real value.</p><p>As an example, this might accept the <var data-name="objectType">objectType</var> <code>Person</code>, the <var data-name="field">field</var> <span class="spec-string">"soulMate"</span>, and the <var data-name="objectValue">objectValue</var> representing John Lennon. It would be expected to yield the value representing Yoko Ono.</p><div class="spec-algo" id="ResolveFieldValue()"><span class="spec-call"><a href="#ResolveFieldValue()" data-name="ResolveFieldValue">ResolveFieldValue</a>(<var data-name="objectType">objectType</var>, <var data-name="objectValue">objectValue</var>, <var data-name="fieldName">fieldName</var>, <var data-name="argumentValues">argumentValues</var>)</span><ol><li>Let <var data-name="resolver">resolver</var> be the internal function provided by <var data-name="objectType">objectType</var> for determining the resolved value of a field named <var data-name="fieldName">fieldName</var>.</li><li>Return the result of calling <var data-name="resolver">resolver</var>, providing <var data-name="objectValue">objectValue</var> and <var data-name="argumentValues">argumentValues</var>.</li></ol></div><div class="spec-note">It is common for <var data-name="resolver">resolver</var> to be asynchronous due to relying on reading an underlying database or networked service to produce a value. This necessitates the rest of a GraphQL executor to handle an asynchronous execution flow.</div></section><section id="sec-Value-Completion" secid="6.4.3"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Value-Completion">6.4.3</a></span>Value Completion</h4><p>After resolving the value for a field, it is completed by ensuring it adheres to the expected return type. If the return type is another Object type, then the field execution process continues recursively.</p><div class="spec-algo" id="CompleteValue()"><span class="spec-call"><a href="#CompleteValue()" data-name="CompleteValue">CompleteValue</a>(<var data-name="fieldType">fieldType</var>, <var data-name="fields">fields</var>, <var data-name="result">result</var>, <var data-name="variableValues">variableValues</var>)</span><ol><li>If the <var data-name="fieldType">fieldType</var> is a Non&#8208;Null type:<ol><li>Let <var data-name="innerType">innerType</var> be the inner type of <var data-name="fieldType">fieldType</var>.</li><li>Let <var data-name="completedResult">completedResult</var> be the result of calling <span class="spec-call"><a href="#CompleteValue()" data-name="CompleteValue">CompleteValue</a>(<var data-name="innerType">innerType</var>, <var data-name="fields">fields</var>, <var data-name="result">result</var>, <var data-name="variableValues">variableValues</var>)</span>.</li><li>If <var data-name="completedResult">completedResult</var> is <span class="spec-keyword">null</span>, throw a field error.</li><li>Return <var data-name="completedResult">completedResult</var>.</li></ol></li><li>If <var data-name="result">result</var> is <span class="spec-keyword">null</span> (or another internal value similar to <span class="spec-keyword">null</span> such as <span class="spec-keyword">undefined</span> or <span class="spec-nt"><span data-name="NaN">NaN</span></span>), return <span class="spec-keyword">null</span>.</li><li>If <var data-name="fieldType">fieldType</var> is a List type:<ol><li>If <var data-name="result">result</var> is not a collection of values, throw a field error.</li><li>Let <var data-name="innerType">innerType</var> be the inner type of <var data-name="fieldType">fieldType</var>.</li><li>Return a list where each list item is the result of calling <span class="spec-call"><a href="#CompleteValue()" data-name="CompleteValue">CompleteValue</a>(<var data-name="innerType">innerType</var>, <var data-name="fields">fields</var>, <var data-name="resultItem">resultItem</var>, <var data-name="variableValues">variableValues</var>)</span>, where <var data-name="resultItem">resultItem</var> is each item in <var data-name="result">result</var>.</li></ol></li><li>If <var data-name="fieldType">fieldType</var> is a Scalar or Enum type:<ol><li>Return the result of &ldquo;coercing&rdquo; <var data-name="result">result</var>, ensuring it is a legal value of <var data-name="fieldType">fieldType</var>, otherwise <span class="spec-keyword">null</span>.</li></ol></li><li>If <var data-name="fieldType">fieldType</var> is an Object, Interface, or Union type:<ol><li>If <var data-name="fieldType">fieldType</var> is an Object type.<ol><li>Let <var data-name="objectType">objectType</var> be <var data-name="fieldType">fieldType</var>.</li></ol></li><li>Otherwise if <var data-name="fieldType">fieldType</var> is an Interface or Union type.<ol><li>Let <var data-name="objectType">objectType</var> be <span class="spec-call"><a href="#ResolveAbstractType()" data-name="ResolveAbstractType">ResolveAbstractType</a>(<var data-name="fieldType">fieldType</var>, <var data-name="result">result</var>)</span>.</li></ol></li><li>Let <var data-name="subSelectionSet">subSelectionSet</var> be the result of calling <span class="spec-call"><a href="#MergeSelectionSets()" data-name="MergeSelectionSets">MergeSelectionSets</a>(<var data-name="fields">fields</var>)</span>.</li><li>Return the result of evaluating <span class="spec-call"><a href="#ExecuteSelectionSet()" data-name="ExecuteSelectionSet">ExecuteSelectionSet</a>(<var data-name="subSelectionSet">subSelectionSet</var>, <var data-name="objectType">objectType</var>, <var data-name="result">result</var>, <var data-name="variableValues">variableValues</var>)</span> <em>normally</em> (allowing for parallelization).</li></ol></li></ol></div><p><strong>Resolving Abstract Types</strong></p><p>When completing a field with an abstract return type, that is an Interface or Union return type, first the abstract type must be resolved to a relevant Object type. This determination is made by the internal system using whatever means appropriate.</p><div class="spec-note">A common method of determining the Object type for an <var data-name="objectValue">objectValue</var> in object&#8208;oriented environments, such as Java or C#, is to use the class name of the <var data-name="objectValue">objectValue</var>.</div><div class="spec-algo" id="ResolveAbstractType()"><span class="spec-call"><a href="#ResolveAbstractType()" data-name="ResolveAbstractType">ResolveAbstractType</a>(<var data-name="abstractType">abstractType</var>, <var data-name="objectValue">objectValue</var>)</span><ol><li>Return the result of calling the internal method provided by the type system for determining the Object type of <var data-name="abstractType">abstractType</var> given the value <var data-name="objectValue">objectValue</var>.</li></ol></div><p><strong>Merging Selection Sets</strong></p><p>When more than one fields of the same name are executed in parallel, their selection sets are merged together when completing the value in order to continue execution of the sub&#8208;selection sets.</p><p>An example query illustrating parallel fields with the same name with sub&#8208;selections.</p><pre id="example-77852" class="spec-example"><a href="#example-77852">Example № 183</a><code><span class="token punctuation">{</span> me <span class="token punctuation">{</span> firstName <span class="token punctuation">}</span> me <span class="token punctuation">{</span> lastName <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>After resolving the value for <code>me</code>, the selection sets are merged together so <code>firstName</code> and <code>lastName</code> can be resolved for one value.</p><div class="spec-algo" id="MergeSelectionSets()"><span class="spec-call"><a href="#MergeSelectionSets()" data-name="MergeSelectionSets">MergeSelectionSets</a>(<var data-name="fields">fields</var>)</span><ol><li>Let <var data-name="selectionSet">selectionSet</var> be an empty list.</li><li>For each <var data-name="field">field</var> in <var data-name="fields">fields</var>:<ol><li>Let <var data-name="fieldSelectionSet">fieldSelectionSet</var> be the selection set of <var data-name="field">field</var>.</li><li>If <var data-name="fieldSelectionSet">fieldSelectionSet</var> is null or empty, continue to the next field.</li><li>Append all selections in <var data-name="fieldSelectionSet">fieldSelectionSet</var> to <var data-name="selectionSet">selectionSet</var>.</li></ol></li><li>Return <var data-name="selectionSet">selectionSet</var>.</li></ol></div></section><section id="sec-Errors-and-Non-Nullability" secid="6.4.4"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Errors-and-Non-Nullability">6.4.4</a></span>Errors and Non-Nullability</h4><p>If an error is thrown while resolving a field, it should be treated as though the field returned <span class="spec-keyword">null</span>, and an error must be added to the <span class="spec-string">"errors"</span> list in the response.</p><p>If the result of resolving a field is <span class="spec-keyword">null</span> (either because the function to resolve the field returned <span class="spec-keyword">null</span> or because an error occurred), and that field is of a <code>Non-Null</code> type, then a field error is thrown. The error must be added to the <span class="spec-string">"errors"</span> list in the response.</p><p>If the field returns <span class="spec-keyword">null</span> because of an error which has already been added to the <span class="spec-string">"errors"</span> list in the response, the <span class="spec-string">"errors"</span> list must not be further affected. That is, only one error should be added to the errors list per field.</p><p>Since <code>Non-Null</code> type fields cannot be <span class="spec-keyword">null</span>, field errors are propagated to be handled by the parent field. If the parent field may be <span class="spec-keyword">null</span> then it resolves to <span class="spec-keyword">null</span>, otherwise if it is a <code>Non-Null</code> type, the field error is further propagated to it&rsquo;s parent field.</p><p>If a <code>List</code> type wraps a <code>Non-Null</code> type, and one of the elements of that list resolves to <span class="spec-keyword">null</span>, then the entire list must resolve to <span class="spec-keyword">null</span>. If the <code>List</code> type is also wrapped in a <code>Non-Null</code>, the field error continues to propagate upwards.</p><p>If all fields from the root of the request to the source of the field error return <code>Non-Null</code> types, then the <span class="spec-string">"data"</span> entry in the response should be <span class="spec-keyword">null</span>. </p></section></section></section><section id="sec-Response" secid="7"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Response">7</a></span>Response</h2><p>When a GraphQL server receives a request, it must return a well&#8208;formed response. The server&rsquo;s response describes the result of executing the requested operation if successful, and describes any errors encountered during the request.</p><p>A response may contain both a partial response as well as encountered errors in the case that a field error occurred on a field which was replaced with <span class="spec-keyword">null</span>.</p><section id="sec-Response-Format" secid="7.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Response-Format">7.1</a></span>Response Format</h3><p>A response to a GraphQL operation must be a map.</p><p>If the operation encountered any errors, the response map must contain an entry with key <code>errors</code>. The value of this entry is described in the &ldquo;Errors&rdquo; section. If the operation completed without encountering any errors, this entry must not be present.</p><p>If the operation included execution, the response map must contain an entry with key <code>data</code>. The value of this entry is described in the &ldquo;Data&rdquo; section. If the operation failed before execution, due to a syntax error, missing information, or validation error, this entry must not be present.</p><p>The response map may also contain an entry with key <code>extensions</code>. This entry, if set, must have a map as its value. This entry is reserved for implementors to extend the protocol however they see fit, and hence there are no additional restrictions on its contents.</p><p>To ensure future changes to the protocol do not break existing servers and clients, the top level response map must not contain any entries other than the three described above.</p><div class="spec-note">When <code>errors</code> is present in the response, it may be helpful for it to appear first when serialized to make it more clear when errors are present in a response during debugging.</div><section id="sec-Data" secid="7.1.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Data">7.1.1</a></span>Data</h4><p>The <code>data</code> entry in the response will be the result of the execution of the requested operation. If the operation was a query, this output will be an object of the schema&rsquo;s query root type; if the operation was a mutation, this output will be an object of the schema&rsquo;s mutation root type.</p><p>If an error was encountered before execution begins, the <code>data</code> entry should not be present in the result.</p><p>If an error was encountered during the execution that prevented a valid response, the <code>data</code> entry in the response should be <code>null</code>.</p></section><section id="sec-Errors" secid="7.1.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Errors">7.1.2</a></span>Errors</h4><p>The <code>errors</code> entry in the response is a non&#8208;empty list of errors, where each error is a map.</p><p>If no errors were encountered during the requested operation, the <code>errors</code> entry should not be present in the result.</p><p>If the <code>data</code> entry in the response is not present, the <code>errors</code> entry in the response must not be empty. It must contain at least one error. The errors it contains should indicate why no data was able to be returned.</p><p>If the <code>data</code> entry in the response is present (including if it is the value <span class="spec-keyword">null</span>), the <code>errors</code> entry in the response may contain any errors that occurred during execution. If errors occurred during execution, it should contain those errors.</p><p><strong>Error result format</strong></p><p>Every error must contain an entry with the key <code>message</code> with a string description of the error intended for the developer as a guide to understand and correct the error.</p><p>If an error can be associated to a particular point in the requested GraphQL document, it should contain an entry with the key <code>locations</code> with a list of locations, where each location is a map with the keys <code>line</code> and <code>column</code>, both positive numbers starting from <code>1</code> which describe the beginning of an associated syntax element.</p><p>If an error can be associated to a particular field in the GraphQL result, it must contain an entry with the key <code>path</code> that details the path of the response field which experienced the error. This allows clients to identify whether a <code>null</code> result is intentional or caused by a runtime error.</p><p>This field should be a list of path segments starting at the root of the response and ending with the field associated with the error. Path segments that represent fields should be strings, and path segments that represent list indices should be 0&#8208;indexed integers. If the error happens in an aliased field, the path to the error should use the aliased name, since it represents a path in the response, not in the query.</p><p>For example, if fetching one of the friends&rsquo; names fails in the following query:</p><pre id="example-bc485" class="spec-example"><a href="#example-bc485">Example № 184</a><code><span class="token punctuation">{</span> hero<span class="token punctuation">(</span><span class="token attr-name">episode</span><span class="token punctuation">:</span> <span class="token variable">$episode</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> name <span class="token attr-name">heroFriends</span><span class="token punctuation">:</span> friends <span class="token punctuation">{</span> id name <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>The response might look like:</p><pre id="example-90475" class="spec-example"><a href="#example-90475">Example № 185</a><code><span class="token punctuation">{</span> <span class="token property">"errors"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"message"</span><span class="token operator">:</span> <span class="token string">"Name for character with ID 1002 could not be fetched."</span><span class="token punctuation">,</span> <span class="token property">"locations"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"line"</span><span class="token operator">:</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token property">"column"</span><span class="token operator">:</span> <span class="token number">7</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"path"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"hero"</span><span class="token punctuation">,</span> <span class="token string">"heroFriends"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">"name"</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"hero"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"R2-D2"</span><span class="token punctuation">,</span> <span class="token property">"heroFriends"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"id"</span><span class="token operator">:</span> <span class="token string">"1000"</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Luke Skywalker"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token property">"id"</span><span class="token operator">:</span> <span class="token string">"1002"</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token null">null</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token property">"id"</span><span class="token operator">:</span> <span class="token string">"1003"</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Leia Organa"</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>If the field which experienced an error was declared as <code>Non-Null</code>, the <code>null</code> result will bubble up to the next nullable field. In that case, the <code>path</code> for the error should include the full path to the result field where the error occurred, even if that field is not present in the response.</p><p>For example, if the <code>name</code> field from above had declared a <code>Non-Null</code> return type in the schema, the result would look different but the error reported would be the same:</p><pre id="example-08b62" class="spec-example"><a href="#example-08b62">Example № 186</a><code><span class="token punctuation">{</span> <span class="token property">"errors"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"message"</span><span class="token operator">:</span> <span class="token string">"Name for character with ID 1002 could not be fetched."</span><span class="token punctuation">,</span> <span class="token property">"locations"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"line"</span><span class="token operator">:</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token property">"column"</span><span class="token operator">:</span> <span class="token number">7</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"path"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"hero"</span><span class="token punctuation">,</span> <span class="token string">"heroFriends"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">"name"</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"data"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"hero"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"R2-D2"</span><span class="token punctuation">,</span> <span class="token property">"heroFriends"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"id"</span><span class="token operator">:</span> <span class="token string">"1000"</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Luke Skywalker"</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token null">null</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token property">"id"</span><span class="token operator">:</span> <span class="token string">"1003"</span><span class="token punctuation">,</span> <span class="token property">"name"</span><span class="token operator">:</span> <span class="token string">"Leia Organa"</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> </code></pre><p>GraphQL services may provide an additional entry to errors with key <code>extensions</code>. This entry, if set, must have a map as its value. This entry is reserved for implementors to add additional information to errors however they see fit, and there are no additional restrictions on its contents.</p><pre id="example-fce18" class="spec-example"><a href="#example-fce18">Example № 187</a><code><span class="token punctuation">{</span> <span class="token property">"errors"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"message"</span><span class="token operator">:</span> <span class="token string">"Name for character with ID 1002 could not be fetched."</span><span class="token punctuation">,</span> <span class="token property">"locations"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"line"</span><span class="token operator">:</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token property">"column"</span><span class="token operator">:</span> <span class="token number">7</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"path"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"hero"</span><span class="token punctuation">,</span> <span class="token string">"heroFriends"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">"name"</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"extensions"</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token property">"code"</span><span class="token operator">:</span> <span class="token string">"CAN_NOT_FETCH_BY_ID"</span><span class="token punctuation">,</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"Fri Feb 9 14:33:09 UTC 2018"</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> </code></pre><p>GraphQL services should not provide any additional entries to the error format since they could conflict with additional entries that may be added in future versions of this specification.</p><div class="spec-note">Previous versions of this spec did not describe the <code>extensions</code> entry for error formatting. While non&#8208;specified entries are not violations, they are still discouraged.</div><pre id="example-9008d" class="spec-counter-example"><a href="#example-9008d">Counter Example № 188</a><code><span class="token punctuation">{</span> <span class="token property">"errors"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"message"</span><span class="token operator">:</span> <span class="token string">"Name for character with ID 1002 could not be fetched."</span><span class="token punctuation">,</span> <span class="token property">"locations"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token punctuation">{</span> <span class="token property">"line"</span><span class="token operator">:</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token property">"column"</span><span class="token operator">:</span> <span class="token number">7</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"path"</span><span class="token operator">:</span> <span class="token punctuation">[</span> <span class="token string">"hero"</span><span class="token punctuation">,</span> <span class="token string">"heroFriends"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token string">"name"</span> <span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token property">"code"</span><span class="token operator">:</span> <span class="token string">"CAN_NOT_FETCH_BY_ID"</span><span class="token punctuation">,</span> <span class="token property">"timestamp"</span><span class="token operator">:</span> <span class="token string">"Fri Feb 9 14:33:09 UTC 2018"</span> <span class="token punctuation">}</span> <span class="token punctuation">]</span> <span class="token punctuation">}</span> </code></pre></section></section><section id="sec-Serialization-Format" secid="7.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Serialization-Format">7.2</a></span>Serialization Format</h3><p>GraphQL does not require a specific serialization format. However, clients should use a serialization format that supports the major primitives in the GraphQL response. In particular, the serialization format must at least support representations of the following four primitives:</p><ul><li>Map</li><li>List</li><li>String</li><li>Null</li></ul><p>A serialization format should also support the following primitives, each representing one of the common GraphQL scalar types, however a string or simpler primitive may be used as a substitute if any are not directly supported:</p><ul><li>Boolean</li><li>Int</li><li>Float</li><li>Enum Value</li></ul><p>This is not meant to be an exhaustive list of what a serialization format may encode. For example custom scalars representing a Date, Time, URI, or number with a different precision may be represented in whichever relevant format a given serialization format may support.</p><section id="sec-JSON-Serialization" secid="7.2.1"><h4><span class="spec-secid" title="link to this section"><a href="#sec-JSON-Serialization">7.2.1</a></span>JSON Serialization</h4><p>JSON is the most common serialization format for GraphQL. Though as mentioned above, GraphQL does not require a specific serialization format.</p><p>When using JSON as a serialization of GraphQL responses, the following JSON values should be used to encode the related GraphQL values:</p><table><thead><tr><th>GraphQL Value </th><th>JSON Value </th></tr></thead><tbody><tr><td>Map </td><td>Object </td></tr><tr><td>List </td><td>Array </td></tr><tr><td>Null </td><td><span class="spec-keyword">null</span> </td></tr><tr><td>String </td><td>String </td></tr><tr><td>Boolean </td><td><span class="spec-keyword">true</span> or <span class="spec-keyword">false</span> </td></tr><tr><td>Int </td><td>Number </td></tr><tr><td>Float </td><td>Number </td></tr><tr><td>Enum Value </td><td>String </td></tr></tbody></table><div class="spec-note">For consistency and ease of notation, examples of responses are given in JSON format throughout this document.</div></section><section id="sec-Serialized-Map-Ordering" secid="7.2.2"><h4><span class="spec-secid" title="link to this section"><a href="#sec-Serialized-Map-Ordering">7.2.2</a></span>Serialized Map Ordering</h4><p>Since the result of evaluating a selection set is ordered, the serialized Map of results should preserve this order by writing the map entries in the same order as those fields were requested as defined by query execution. Producing a serialized response where fields are represented in the same order in which they appear in the request improves human readability during debugging and enables more efficient parsing of responses if the order of properties can be anticipated.</p><p>Serialization formats which represent an ordered map should preserve the order of requested fields as defined by <span class="spec-call"><a href="#CollectFields()" data-name="CollectFields">CollectFields</a>()</span> in the Execution section. Serialization formats which only represent unordered maps but where order is still implicit in the serialization&rsquo;s textual order (such as JSON) should preserve the order of requested fields textually.</p><p>For example, if the request was <code>{ name, age }</code>, a GraphQL service responding in JSON should respond with <code>{ &quot;name&quot;: &quot;Mark&quot;, &quot;age&quot;: 30 }</code> and should not respond with <code>{ &quot;age&quot;: 30, &quot;name&quot;: &quot;Mark&quot; }</code>.</p><p>While JSON Objects are specified as an <a href="https://tools.ietf.org/html/rfc7159#section-4">unordered collection of key&#8208;value pairs</a> the pairs are represented in an ordered manner. In other words, while the JSON strings <code>{ &quot;name&quot;: &quot;Mark&quot;, &quot;age&quot;: 30 }</code> and <code>{ &quot;age&quot;: 30, &quot;name&quot;: &quot;Mark&quot; }</code> encode the same value, they also have observably different property orderings.</p><div class="spec-note">This does not violate the JSON spec, as clients may still interpret objects in the response as unordered Maps and arrive at a valid value. </div></section></section></section><section id="sec-Appendix-Notation-Conventions" secid="A"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Appendix-Notation-Conventions">A</a></span>Appendix: Notation Conventions</h2><p>This specification document contains a number of notation conventions used to describe technical concepts such as language grammar and semantics as well as runtime algorithms.</p><p>This appendix seeks to explain these notations in greater detail to avoid ambiguity.</p><section id="sec-Context-Free-Grammar" secid="A.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Context-Free-Grammar">A.1</a></span>Context-Free Grammar</h3><p>A context&#8208;free grammar consists of a number of productions. Each production has an abstract symbol called a &ldquo;non&#8208;terminal&rdquo; as its left&#8208;hand side, and zero or more possible sequences of non&#8208;terminal symbols and or terminal characters as its right&#8208;hand side.</p><p>Starting from a single goal non&#8208;terminal symbol, a context&#8208;free grammar describes a language: the set of possible sequences of characters that can be described by repeatedly replacing any non&#8208;terminal in the goal sequence with one of the sequences it is defined by, until all non&#8208;terminal symbols have been replaced by terminal characters.</p><p>Terminals are represented in this document in a monospace font in two forms: a specific Unicode character or sequence of Unicode characters (ex. <span class="spec-t">=</span> or <span class="spec-t">terminal</span>), and a pattern of Unicode characters defined by a regular expression (ex <span class="spec-rx">/[0-9]+/</span>).</p><p>Non&#8208;terminal production rules are represented in this document using the following notation for a non&#8208;terminal with a single definition:</p><div class="spec-production" id="NonTerminalWithSingleDefinition"><span class="spec-nt"><a href="#NonTerminalWithSingleDefinition" data-name="NonTerminalWithSingleDefinition">NonTerminalWithSingleDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="NonTerminal">NonTerminal</span></span><span class="spec-t">terminal</span></div></div><p>While using the following notation for a production with a list of definitions:</p><div class="spec-production" id="NonTerminalWithManyDefinitions"><span class="spec-nt"><a href="#NonTerminalWithManyDefinitions" data-name="NonTerminalWithManyDefinitions">NonTerminalWithManyDefinitions</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="OtherNonTerminal">OtherNonTerminal</span></span><span class="spec-t">terminal</span></div><div class="spec-rhs"><span class="spec-t">terminal</span></div></div><p>A definition may refer to itself, which describes repetitive sequences, for example:</p><div class="spec-production" id="ListOfLetterA"><span class="spec-nt"><a href="#ListOfLetterA" data-name="ListOfLetterA">ListOfLetterA</a></span><div class="spec-rhs"><span class="spec-t">a</span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ListOfLetterA" data-name="ListOfLetterA">ListOfLetterA</a></span><span class="spec-t">a</span></div></div></section><section id="sec-Lexical-and-Syntactical-Grammar" secid="A.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Lexical-and-Syntactical-Grammar">A.2</a></span>Lexical and Syntactical Grammar</h3><p>The GraphQL language is defined in a syntactic grammar where terminal symbols are tokens. Tokens are defined in a lexical grammar which matches patterns of source characters. The result of parsing a sequence of source Unicode characters produces a GraphQL AST.</p><p>A Lexical grammar production describes non&#8208;terminal &ldquo;tokens&rdquo; by patterns of terminal Unicode characters. No &ldquo;whitespace&rdquo; or other ignored characters may appear between any terminal Unicode characters in the lexical grammar production. A lexical grammar production is distinguished by a two colon <code>::</code> definition.</p><div class="spec-production d2" id="Word"><span class="spec-nt"><a href="#Word" data-name="Word">Word</a></span><div class="spec-rhs"><span class="spec-rx">/[A-Za-z]+/</span></div></div><p>A Syntactical grammar production describes non&#8208;terminal &ldquo;rules&rdquo; by patterns of terminal Tokens. Whitespace and other ignored characters may appear before or after any terminal Token. A syntactical grammar production is distinguished by a one colon <code>:</code> definition.</p><div class="spec-production" id="Sentence"><span class="spec-nt"><a href="#Sentence" data-name="Sentence">Sentence</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="Noun">Noun</span></span><span class="spec-nt"><span data-name="Verb">Verb</span></span></div></div></section><section id="sec-Grammar-Notation" secid="A.3"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Grammar-Notation">A.3</a></span>Grammar Notation</h3><p>This specification uses some additional notation to describe common patterns, such as optional or repeated patterns, or parameterized alterations of the definition of a non&#8208;terminal. This section explains these short&#8208;hand notations and their expanded definitions in the context&#8208;free grammar.</p><p><strong>Constraints</strong></p><p>A grammar production may specify that certain expansions are not permitted by using the phrase &ldquo;but not&rdquo; and then indicating the expansions to be excluded.</p><p>For example, the production:</p><div class="spec-production" id="SafeName"><span class="spec-nt"><a href="#SafeName" data-name="SafeName">SafeName</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-butnot"><span class="spec-nt"><span data-name="SevenCarlinWords">SevenCarlinWords</span></span></span></span></div></div><p>means that the nonterminal <span class="spec-nt"><a href="#SafeName" data-name="SafeName">SafeName</a></span> may be replaced by any sequence of characters that could replace <span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span> provided that the same sequence of characters could not replace <span class="spec-nt"><span data-name="SevenCarlinWords">SevenCarlinWords</span></span>.</p><p>A grammar may also list a number of restrictions after &ldquo;but not&rdquo; separated by &ldquo;or&rdquo;.</p><p>For example:</p><div class="spec-production" id="NonBooleanName"><span class="spec-nt"><a href="#NonBooleanName" data-name="NonBooleanName">NonBooleanName</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-butnot"><span class="spec-t">true</span><span class="spec-t">false</span></span></span></div></div><p><strong>Optionality and Lists</strong></p><p>A subscript suffix &ldquo;<span class="spec-quantified"><span class="spec-nt"><span data-name="Symbol">Symbol</span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span>&rdquo; is shorthand for two possible sequences, one including that symbol and one excluding it.</p><p>As an example:</p><div class="spec-production" id="Sentence"><span class="spec-nt"><a href="#Sentence" data-name="Sentence">Sentence</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="Noun">Noun</span></span><span class="spec-nt"><span data-name="Verb">Verb</span></span><span class="spec-quantified"><span class="spec-nt"><span data-name="Adverb">Adverb</span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><p>is shorthand for</p><div class="spec-production" id="Sentence"><span class="spec-nt"><a href="#Sentence" data-name="Sentence">Sentence</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="Noun">Noun</span></span><span class="spec-nt"><span data-name="Verb">Verb</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="Noun">Noun</span></span><span class="spec-nt"><span data-name="Verb">Verb</span></span><span class="spec-nt"><span data-name="Adverb">Adverb</span></span></div></div><p>A subscript suffix &ldquo;<span class="spec-quantified"><span class="spec-nt"><span data-name="Symbol">Symbol</span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span>&rdquo; is shorthand for a list of one or more of that symbol.</p><p>As an example:</p><div class="spec-production" id="Book"><span class="spec-nt"><a href="#Book" data-name="Book">Book</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="Cover">Cover</span></span><span class="spec-quantified"><span class="spec-nt"><span data-name="Page">Page</span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-nt"><span data-name="Cover">Cover</span></span></div></div><p>is shorthand for</p><div class="spec-production" id="Book"><span class="spec-nt"><a href="#Book" data-name="Book">Book</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="Cover">Cover</span></span><span class="spec-nt"><a href="#Page_list" data-name="Page_list">Page_list</a></span><span class="spec-nt"><span data-name="Cover">Cover</span></span></div></div><div class="spec-production" id="Page_list"><span class="spec-nt"><a href="#Page_list" data-name="Page_list">Page_list</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="Page">Page</span></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#Page_list" data-name="Page_list">Page_list</a></span><span class="spec-nt"><span data-name="Page">Page</span></span></div></div><p><strong>Parameterized Grammar Productions</strong></p><p>A symbol definition subscript suffix parameter in braces &ldquo;<span class="spec-nt"><span data-name="Symbol">Symbol</span><span class="spec-params"><span class="spec-param">Param</span></span></span>&rdquo; is shorthand for two symbol definitions, one appended with that parameter name, the other without. The same subscript suffix on a symbol is shorthand for that variant of the definition. If the parameter starts with &ldquo;?&rdquo;, that form of the symbol is used if in a symbol definition with the same parameter. Some possible sequences can be included or excluded conditionally when respectively prefixed with &ldquo;[+Param]&rdquo; and &ldquo;[~Param]&rdquo;.</p><p>As an example:</p><div class="spec-production" id="Example"><span class="spec-nt"><a href="#Example" data-name="Example">Example</a><span class="spec-params"><span class="spec-param">Param</span></span></span><div class="spec-rhs"><span class="spec-nt"><span data-name="A">A</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="B">B</span><span class="spec-params"><span class="spec-param">Param</span></span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="C">C</span><span class="spec-params"><span class="spec-param conditional">Param</span></span></span></div><div class="spec-rhs"><span class="spec-condition">Param</span><span class="spec-nt"><span data-name="D">D</span></span></div><div class="spec-rhs"><span class="spec-condition not">Param</span><span class="spec-nt"><span data-name="E">E</span></span></div></div><p>is shorthand for</p><div class="spec-production" id="Example"><span class="spec-nt"><a href="#Example" data-name="Example">Example</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="A">A</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="B_param">B_param</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="C">C</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="E">E</span></span></div></div><div class="spec-production" id="Example_param"><span class="spec-nt"><a href="#Example_param" data-name="Example_param">Example_param</a></span><div class="spec-rhs"><span class="spec-nt"><span data-name="A">A</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="B_param">B_param</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="C_param">C_param</span></span></div><div class="spec-rhs"><span class="spec-nt"><span data-name="D">D</span></span></div></div></section><section id="sec-Grammar-Semantics" secid="A.4"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Grammar-Semantics">A.4</a></span>Grammar Semantics</h3><p>This specification describes the semantic value of many grammar productions in the form of a list of algorithmic steps.</p><p>For example, this describes how a parser should interpret a string literal:</p><div class="spec-semantic d2"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span><div class="spec-rhs"><span class="spec-t">&quot;&quot;</span></div><ol><li>Return an empty Unicode character sequence.</li></ol></div><div class="spec-semantic d2"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span><div class="spec-rhs"><span class="spec-t">&quot;</span><span class="spec-quantified"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">&quot;</span></div><ol><li>Return the Unicode character sequence of all <span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span> Unicode character values.</li></ol></div></section><section id="sec-Algorithms" secid="A.5"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Algorithms">A.5</a></span>Algorithms</h3><p>This specification describes some algorithms used by the static and runtime semantics, they&rsquo;re defined in the form of a function&#8208;like syntax with the algorithm&rsquo;s name and the arguments it accepts along with a list of algorithmic steps to take in the order listed. Each step may establish references to other values, check various conditions, call other algorithms, and eventually return a value representing the outcome of the algorithm for the provided arguments.</p><p>For example, the following example describes an algorithm named <span class="spec-nt"><span data-name="Fibonacci">Fibonacci</span></span> which accepts a single argument <var data-name="number">number</var>. The algoritm&rsquo;s steps produce the next number in the Fibonacci sequence:</p><div class="spec-algo" id="Fibonacci()"><span class="spec-call"><a href="#Fibonacci()" data-name="Fibonacci">Fibonacci</a>(<var data-name="number">number</var>)</span><ol><li>If <var data-name="number">number</var> is <span class="spec-t">0</span>:<ol><li>Return <span class="spec-t">1</span>.</li></ol></li><li>If <var data-name="number">number</var> is <span class="spec-t">1</span>:<ol><li>Return <span class="spec-t">2</span>.</li></ol></li><li>Let <var data-name="previousNumber">previousNumber</var> be <var data-name="number">number</var> - <span class="spec-t">1</span>.</li><li>Let <var data-name="previousPreviousNumber">previousPreviousNumber</var> be <var data-name="number">number</var> - <span class="spec-t">2</span>.</li><li>Return <span class="spec-call"><a href="#Fibonacci()" data-name="Fibonacci">Fibonacci</a>(<var data-name="previousNumber">previousNumber</var>)</span> + <span class="spec-call"><a href="#Fibonacci()" data-name="Fibonacci">Fibonacci</a>(<var data-name="previousPreviousNumber">previousPreviousNumber</var>)</span>.</li></ol></div><div class="spec-note">Algorithms described in this document are written to be easy to understand. Implementers are encouraged to include equivalent but optimized implementations. </div></section></section><section id="sec-Appendix-Grammar-Summary" secid="B"><h2><span class="spec-secid" title="link to this section"><a href="#sec-Appendix-Grammar-Summary">B</a></span>Appendix: Grammar Summary</h2><div class="spec-production d2" id="SourceCharacter"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><div class="spec-rhs"><span class="spec-rx">/[\u0009\u000A\u000D\u0020-\uFFFF]/</span></div></div><section id="sec-Appendix-Grammar-Summary.Ignored-Tokens" secid="B.1"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Appendix-Grammar-Summary.Ignored-Tokens">B.1</a></span>Ignored Tokens</h3><div class="spec-production d2" id="Ignored"><span class="spec-nt"><a href="#Ignored" data-name="Ignored">Ignored</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#UnicodeBOM" data-name="UnicodeBOM">UnicodeBOM</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#Comment" data-name="Comment">Comment</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#Comma" data-name="Comma">Comma</a></span></div></div><div class="spec-production d2" id="UnicodeBOM"><span class="spec-nt"><a href="#UnicodeBOM" data-name="UnicodeBOM">UnicodeBOM</a></span><div class="spec-rhs"><span class="spec-prose">Byte Order Mark (U+FEFF)</span></div></div><div class="spec-production d2" id="WhiteSpace"><span class="spec-nt"><a href="#WhiteSpace" data-name="WhiteSpace">WhiteSpace</a></span><div class="spec-rhs"><span class="spec-prose">Horizontal Tab (U+0009)</span></div><div class="spec-rhs"><span class="spec-prose">Space (U+0020)</span></div></div><div class="spec-production d2" id="LineTerminator"><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span><div class="spec-rhs"><span class="spec-prose">New Line (U+000A)</span></div><div class="spec-rhs"><span class="spec-prose">Carriage Return (U+000D)</span><span class="spec-lookahead not"><span class="spec-prose">New Line (U+000A)</span></span></div><div class="spec-rhs"><span class="spec-prose">Carriage Return (U+000D)</span><span class="spec-prose">New Line (U+000A)</span></div></div><div class="spec-production d2" id="Comment"><span class="spec-nt"><a href="#Comment" data-name="Comment">Comment</a></span><div class="spec-rhs"><span class="spec-t">#</span><span class="spec-quantified"><span class="spec-nt"><a href="#CommentChar" data-name="CommentChar">CommentChar</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production d2" id="CommentChar"><span class="spec-nt"><a href="#CommentChar" data-name="CommentChar">CommentChar</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span></span></span></div></div><div class="spec-production d2" id="Comma"><span class="spec-nt"><a href="#Comma" data-name="Comma">Comma</a></span><div class="spec-rhs"><span class="spec-t">,</span></div></div></section><section id="sec-Appendix-Grammar-Summary.Lexical-Tokens" secid="B.2"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Appendix-Grammar-Summary.Lexical-Tokens">B.2</a></span>Lexical Tokens</h3><div class="spec-production d2" id="Token"><span class="spec-nt"><a href="#Token" data-name="Token">Token</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Punctuator" data-name="Punctuator">Punctuator</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntValue" data-name="IntValue">IntValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FloatValue" data-name="FloatValue">FloatValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span></div></div><div class="spec-production d2" id="Punctuator"><span class="spec-nt"><a href="#Punctuator" data-name="Punctuator">Punctuator</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">!</span></td><td class="spec-rhs"><span class="spec-t">$</span></td><td class="spec-rhs"><span class="spec-t">(</span></td><td class="spec-rhs"><span class="spec-t">)</span></td><td class="spec-rhs"><span class="spec-t">...</span></td><td class="spec-rhs"><span class="spec-t">:</span></td><td class="spec-rhs"><span class="spec-t">=</span></td><td class="spec-rhs"><span class="spec-t">@</span></td><td class="spec-rhs"><span class="spec-t">[</span></td><td class="spec-rhs"><span class="spec-t">]</span></td><td class="spec-rhs"><span class="spec-t">{</span></td><td class="spec-rhs"><span class="spec-t">|</span></td><td class="spec-rhs"><span class="spec-t">}</span></td></tr></table></div></div><div class="spec-production d2" id="Name"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><div class="spec-rhs"><span class="spec-rx">/[_A-Za-z][_0-9A-Za-z]*/</span></div></div><div class="spec-production d2" id="IntValue"><span class="spec-nt"><a href="#IntValue" data-name="IntValue">IntValue</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span></div></div><div class="spec-production d2" id="IntegerPart"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#NegativeSign" data-name="NegativeSign">NegativeSign</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">0</span></div><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#NegativeSign" data-name="NegativeSign">NegativeSign</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#NonZeroDigit" data-name="NonZeroDigit">NonZeroDigit</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production d2" id="NegativeSign"><span class="spec-nt"><a href="#NegativeSign" data-name="NegativeSign">NegativeSign</a></span><div class="spec-rhs"><span class="spec-t">-</span></div></div><div class="spec-production d2" id="Digit"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">0</span></td><td class="spec-rhs"><span class="spec-t">1</span></td><td class="spec-rhs"><span class="spec-t">2</span></td><td class="spec-rhs"><span class="spec-t">3</span></td><td class="spec-rhs"><span class="spec-t">4</span></td><td class="spec-rhs"><span class="spec-t">5</span></td><td class="spec-rhs"><span class="spec-t">6</span></td><td class="spec-rhs"><span class="spec-t">7</span></td><td class="spec-rhs"><span class="spec-t">8</span></td><td class="spec-rhs"><span class="spec-t">9</span></td></tr></table></div></div><div class="spec-production d2" id="NonZeroDigit"><span class="spec-nt"><a href="#NonZeroDigit" data-name="NonZeroDigit">NonZeroDigit</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-butnot"><span class="spec-t">0</span></span></span></div></div><div class="spec-production d2" id="FloatValue"><span class="spec-nt"><a href="#FloatValue" data-name="FloatValue">FloatValue</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><span class="spec-nt"><a href="#FractionalPart" data-name="FractionalPart">FractionalPart</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><span class="spec-nt"><a href="#ExponentPart" data-name="ExponentPart">ExponentPart</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntegerPart" data-name="IntegerPart">IntegerPart</a></span><span class="spec-nt"><a href="#FractionalPart" data-name="FractionalPart">FractionalPart</a></span><span class="spec-nt"><a href="#ExponentPart" data-name="ExponentPart">ExponentPart</a></span></div></div><div class="spec-production d2" id="FractionalPart"><span class="spec-nt"><a href="#FractionalPart" data-name="FractionalPart">FractionalPart</a></span><div class="spec-rhs"><span class="spec-t">.</span><span class="spec-quantified"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production d2" id="ExponentPart"><span class="spec-nt"><a href="#ExponentPart" data-name="ExponentPart">ExponentPart</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ExponentIndicator" data-name="ExponentIndicator">ExponentIndicator</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Sign" data-name="Sign">Sign</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Digit" data-name="Digit">Digit</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production d2" id="ExponentIndicator"><span class="spec-nt"><a href="#ExponentIndicator" data-name="ExponentIndicator">ExponentIndicator</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">e</span></td><td class="spec-rhs"><span class="spec-t">E</span></td></tr></table></div></div><div class="spec-production d2" id="Sign"><span class="spec-nt"><a href="#Sign" data-name="Sign">Sign</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">+</span></td><td class="spec-rhs"><span class="spec-t">-</span></td></tr></table></div></div><div class="spec-production d2" id="StringValue"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span><div class="spec-rhs"><span class="spec-t">&quot;</span><span class="spec-quantified"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">&quot;</span></div><div class="spec-rhs"><span class="spec-t">&quot;&quot;&quot;</span><span class="spec-quantified"><span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">&quot;&quot;&quot;</span></div></div><div class="spec-production d2" id="StringCharacter"><span class="spec-nt"><a href="#StringCharacter" data-name="StringCharacter">StringCharacter</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-t">&quot;</span><span class="spec-t">\</span><span class="spec-nt"><a href="#LineTerminator" data-name="LineTerminator">LineTerminator</a></span></span></span></div><div class="spec-rhs"><span class="spec-t">\u</span><span class="spec-nt"><a href="#EscapedUnicode" data-name="EscapedUnicode">EscapedUnicode</a></span></div><div class="spec-rhs"><span class="spec-t">\</span><span class="spec-nt"><a href="#EscapedCharacter" data-name="EscapedCharacter">EscapedCharacter</a></span></div></div><div class="spec-production d2" id="EscapedUnicode"><span class="spec-nt"><a href="#EscapedUnicode" data-name="EscapedUnicode">EscapedUnicode</a></span><div class="spec-rhs"><span class="spec-rx">/[0-9A-Fa-f]{4}/</span></div></div><div class="spec-production d2" id="EscapedCharacter"><span class="spec-nt"><a href="#EscapedCharacter" data-name="EscapedCharacter">EscapedCharacter</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">&quot;</span></td><td class="spec-rhs"><span class="spec-t">\</span></td><td class="spec-rhs"><span class="spec-t">/</span></td><td class="spec-rhs"><span class="spec-t">b</span></td><td class="spec-rhs"><span class="spec-t">f</span></td><td class="spec-rhs"><span class="spec-t">n</span></td><td class="spec-rhs"><span class="spec-t">r</span></td><td class="spec-rhs"><span class="spec-t">t</span></td></tr></table></div></div><div class="spec-production d2" id="BlockStringCharacter"><span class="spec-nt"><a href="#BlockStringCharacter" data-name="BlockStringCharacter">BlockStringCharacter</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#SourceCharacter" data-name="SourceCharacter">SourceCharacter</a></span><span class="spec-butnot"><span class="spec-t">&quot;&quot;&quot;</span><span class="spec-t">\&quot;&quot;&quot;</span></span></span></div><div class="spec-rhs"><span class="spec-t">\&quot;&quot;&quot;</span></div></div><div class="spec-note">Block string values are interpreted to exclude blank initial and trailing lines and uniform indentation with <span class="spec-call"><a href="#BlockStringValue()" data-name="BlockStringValue">BlockStringValue</a>()</span>.</div></section><section id="sec-Appendix-Grammar-Summary.Document" secid="B.3"><h3><span class="spec-secid" title="link to this section"><a href="#sec-Appendix-Grammar-Summary.Document">B.3</a></span>Document</h3><div class="spec-production" id="Document"><span class="spec-nt"><a href="#Document" data-name="Document">Document</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Definition" data-name="Definition">Definition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production" id="Definition"><span class="spec-nt"><a href="#Definition" data-name="Definition">Definition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ExecutableDefinition" data-name="ExecutableDefinition">ExecutableDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeSystemExtension" data-name="TypeSystemExtension">TypeSystemExtension</a></span></div></div><div class="spec-production" id="ExecutableDefinition"><span class="spec-nt"><a href="#ExecutableDefinition" data-name="ExecutableDefinition">ExecutableDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FragmentDefinition" data-name="FragmentDefinition">FragmentDefinition</a></span></div></div><div class="spec-production" id="OperationDefinition"><span class="spec-nt"><a href="#OperationDefinition" data-name="OperationDefinition">OperationDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#OperationType" data-name="OperationType">OperationType</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#VariableDefinitions" data-name="VariableDefinitions">VariableDefinitions</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div></div><div class="spec-production" id="OperationType"><span class="spec-nt"><a href="#OperationType" data-name="OperationType">OperationType</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">query</span></td><td class="spec-rhs"><span class="spec-t">mutation</span></td><td class="spec-rhs"><span class="spec-t">subscription</span></td></tr></table></div></div><div class="spec-production" id="SelectionSet"><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#Selection" data-name="Selection">Selection</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="Selection"><span class="spec-nt"><a href="#Selection" data-name="Selection">Selection</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Field" data-name="Field">Field</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FragmentSpread" data-name="FragmentSpread">FragmentSpread</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InlineFragment" data-name="InlineFragment">InlineFragment</a></span></div></div><div class="spec-production" id="Field"><span class="spec-nt"><a href="#Field" data-name="Field">Field</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Alias" data-name="Alias">Alias</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Arguments" data-name="Arguments">Arguments</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="Alias"><span class="spec-nt"><a href="#Alias" data-name="Alias">Alias</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span></div></div><div class="spec-production" id="Arguments"><span class="spec-nt"><a href="#Arguments" data-name="Arguments">Arguments</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">(</span><span class="spec-quantified"><span class="spec-nt"><a href="#Argument" data-name="Argument">Argument</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">)</span></div></div><div class="spec-production" id="Argument"><span class="spec-nt"><a href="#Argument" data-name="Argument">Argument</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div></div><div class="spec-production" id="FragmentSpread"><span class="spec-nt"><a href="#FragmentSpread" data-name="FragmentSpread">FragmentSpread</a></span><div class="spec-rhs"><span class="spec-t">...</span><span class="spec-nt"><a href="#FragmentName" data-name="FragmentName">FragmentName</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="InlineFragment"><span class="spec-nt"><a href="#InlineFragment" data-name="InlineFragment">InlineFragment</a></span><div class="spec-rhs"><span class="spec-t">...</span><span class="spec-quantified"><span class="spec-nt"><a href="#TypeCondition" data-name="TypeCondition">TypeCondition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div></div><div class="spec-production" id="FragmentDefinition"><span class="spec-nt"><a href="#FragmentDefinition" data-name="FragmentDefinition">FragmentDefinition</a></span><div class="spec-rhs"><span class="spec-t">fragment</span><span class="spec-nt"><a href="#FragmentName" data-name="FragmentName">FragmentName</a></span><span class="spec-nt"><a href="#TypeCondition" data-name="TypeCondition">TypeCondition</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#SelectionSet" data-name="SelectionSet">SelectionSet</a></span></div></div><div class="spec-production" id="FragmentName"><span class="spec-nt"><a href="#FragmentName" data-name="FragmentName">FragmentName</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-butnot"><span class="spec-t">on</span></span></span></div></div><div class="spec-production" id="TypeCondition"><span class="spec-nt"><a href="#TypeCondition" data-name="TypeCondition">TypeCondition</a></span><div class="spec-rhs"><span class="spec-t">on</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><div class="spec-production" id="Value"><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-condition not">Const</span><span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#IntValue" data-name="IntValue">IntValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#FloatValue" data-name="FloatValue">FloatValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#BooleanValue" data-name="BooleanValue">BooleanValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#NullValue" data-name="NullValue">NullValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#EnumValue" data-name="EnumValue">EnumValue</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ListValue" data-name="ListValue">ListValue</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ObjectValue" data-name="ObjectValue">ObjectValue</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div></div><div class="spec-production" id="BooleanValue"><span class="spec-nt"><a href="#BooleanValue" data-name="BooleanValue">BooleanValue</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">true</span></td><td class="spec-rhs"><span class="spec-t">false</span></td></tr></table></div></div><div class="spec-production" id="NullValue"><span class="spec-nt"><a href="#NullValue" data-name="NullValue">NullValue</a></span><div class="spec-rhs"><span class="spec-t">null</span></div></div><div class="spec-production" id="EnumValue"><span class="spec-nt"><a href="#EnumValue" data-name="EnumValue">EnumValue</a></span><div class="spec-rhs"><span class="spec-constrained"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-butnot"><span class="spec-t">true</span><span class="spec-t">false</span><span class="spec-t">null</span></span></span></div></div><div class="spec-production" id="ListValue"><span class="spec-nt"><a href="#ListValue" data-name="ListValue">ListValue</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-t">]</span></div><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-quantified"><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">]</span></div></div><div class="spec-production" id="ObjectValue"><span class="spec-nt"><a href="#ObjectValue" data-name="ObjectValue">ObjectValue</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-t">}</span></div><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="ObjectField"><span class="spec-nt"><a href="#ObjectField" data-name="ObjectField">ObjectField</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span></div></div><div class="spec-production" id="VariableDefinitions"><span class="spec-nt"><a href="#VariableDefinitions" data-name="VariableDefinitions">VariableDefinitions</a></span><div class="spec-rhs"><span class="spec-t">(</span><span class="spec-quantified"><span class="spec-nt"><a href="#VariableDefinition" data-name="VariableDefinition">VariableDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">)</span></div></div><div class="spec-production" id="VariableDefinition"><span class="spec-nt"><a href="#VariableDefinition" data-name="VariableDefinition">VariableDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="Variable"><span class="spec-nt"><a href="#Variable" data-name="Variable">Variable</a></span><div class="spec-rhs"><span class="spec-t">$</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></div></div><div class="spec-production" id="DefaultValue"><span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span><div class="spec-rhs"><span class="spec-t">=</span><span class="spec-nt"><a href="#Value" data-name="Value">Value</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><div class="spec-production" id="Type"><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ListType" data-name="ListType">ListType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#NonNullType" data-name="NonNullType">NonNullType</a></span></div></div><div class="spec-production" id="NamedType"><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span></div></div><div class="spec-production" id="ListType"><span class="spec-nt"><a href="#ListType" data-name="ListType">ListType</a></span><div class="spec-rhs"><span class="spec-t">[</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-t">]</span></div></div><div class="spec-production" id="NonNullType"><span class="spec-nt"><a href="#NonNullType" data-name="NonNullType">NonNullType</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span><span class="spec-t">!</span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ListType" data-name="ListType">ListType</a></span><span class="spec-t">!</span></div></div><div class="spec-production" id="Directives"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Directive" data-name="Directive">Directive</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span></div></div><div class="spec-production" id="Directive"><span class="spec-nt"><a href="#Directive" data-name="Directive">Directive</a><span class="spec-params"><span class="spec-param">Const</span></span></span><div class="spec-rhs"><span class="spec-t">@</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Arguments" data-name="Arguments">Arguments</a><span class="spec-params"><span class="spec-param conditional">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="TypeSystemDefinition"><span class="spec-nt"><a href="#TypeSystemDefinition" data-name="TypeSystemDefinition">TypeSystemDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#SchemaDefinition" data-name="SchemaDefinition">SchemaDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeDefinition" data-name="TypeDefinition">TypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#DirectiveDefinition" data-name="DirectiveDefinition">DirectiveDefinition</a></span></div></div><div class="spec-production" id="TypeSystemExtension"><span class="spec-nt"><a href="#TypeSystemExtension" data-name="TypeSystemExtension">TypeSystemExtension</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#SchemaExtension" data-name="SchemaExtension">SchemaExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeExtension" data-name="TypeExtension">TypeExtension</a></span></div></div><div class="spec-production" id="SchemaDefinition"><span class="spec-nt"><a href="#SchemaDefinition" data-name="SchemaDefinition">SchemaDefinition</a></span><div class="spec-rhs"><span class="spec-t">schema</span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#OperationTypeDefinition" data-name="OperationTypeDefinition">OperationTypeDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="SchemaExtension"><span class="spec-nt"><a href="#SchemaExtension" data-name="SchemaExtension">SchemaExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">schema</span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#OperationTypeDefinition" data-name="OperationTypeDefinition">OperationTypeDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">schema</span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><div class="spec-production" id="OperationTypeDefinition"><span class="spec-nt"><a href="#OperationTypeDefinition" data-name="OperationTypeDefinition">OperationTypeDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#OperationType" data-name="OperationType">OperationType</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><div class="spec-production" id="Description"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#StringValue" data-name="StringValue">StringValue</a></span></div></div><div class="spec-production" id="TypeDefinition"><span class="spec-nt"><a href="#TypeDefinition" data-name="TypeDefinition">TypeDefinition</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ScalarTypeDefinition" data-name="ScalarTypeDefinition">ScalarTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ObjectTypeDefinition" data-name="ObjectTypeDefinition">ObjectTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InterfaceTypeDefinition" data-name="InterfaceTypeDefinition">InterfaceTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#UnionTypeDefinition" data-name="UnionTypeDefinition">UnionTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#EnumTypeDefinition" data-name="EnumTypeDefinition">EnumTypeDefinition</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InputObjectTypeDefinition" data-name="InputObjectTypeDefinition">InputObjectTypeDefinition</a></span></div></div><div class="spec-production" id="TypeExtension"><span class="spec-nt"><a href="#TypeExtension" data-name="TypeExtension">TypeExtension</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ScalarTypeExtension" data-name="ScalarTypeExtension">ScalarTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ObjectTypeExtension" data-name="ObjectTypeExtension">ObjectTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InterfaceTypeExtension" data-name="InterfaceTypeExtension">InterfaceTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#UnionTypeExtension" data-name="UnionTypeExtension">UnionTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#EnumTypeExtension" data-name="EnumTypeExtension">EnumTypeExtension</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#InputObjectTypeExtension" data-name="InputObjectTypeExtension">InputObjectTypeExtension</a></span></div></div><div class="spec-production" id="ScalarTypeDefinition"><span class="spec-nt"><a href="#ScalarTypeDefinition" data-name="ScalarTypeDefinition">ScalarTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">scalar</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="ScalarTypeExtension"><span class="spec-nt"><a href="#ScalarTypeExtension" data-name="ScalarTypeExtension">ScalarTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">scalar</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><div class="spec-production" id="ObjectTypeDefinition"><span class="spec-nt"><a href="#ObjectTypeDefinition" data-name="ObjectTypeDefinition">ObjectTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="ObjectTypeExtension"><span class="spec-nt"><a href="#ObjectTypeExtension" data-name="ObjectTypeExtension">ObjectTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">type</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span></div></div><div class="spec-production" id="ImplementsInterfaces"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><div class="spec-rhs"><span class="spec-t">implements</span><span class="spec-quantified"><span class="spec-t">&amp;</span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#ImplementsInterfaces" data-name="ImplementsInterfaces">ImplementsInterfaces</a></span><span class="spec-t">&amp;</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><div class="spec-production" id="FieldsDefinition"><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#FieldDefinition" data-name="FieldDefinition">FieldDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="FieldDefinition"><span class="spec-nt"><a href="#FieldDefinition" data-name="FieldDefinition">FieldDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ArgumentsDefinition" data-name="ArgumentsDefinition">ArgumentsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="ArgumentsDefinition"><span class="spec-nt"><a href="#ArgumentsDefinition" data-name="ArgumentsDefinition">ArgumentsDefinition</a></span><div class="spec-rhs"><span class="spec-t">(</span><span class="spec-quantified"><span class="spec-nt"><a href="#InputValueDefinition" data-name="InputValueDefinition">InputValueDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">)</span></div></div><div class="spec-production" id="InputValueDefinition"><span class="spec-nt"><a href="#InputValueDefinition" data-name="InputValueDefinition">InputValueDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-t">:</span><span class="spec-nt"><a href="#Type" data-name="Type">Type</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#DefaultValue" data-name="DefaultValue">DefaultValue</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="InterfaceTypeDefinition"><span class="spec-nt"><a href="#InterfaceTypeDefinition" data-name="InterfaceTypeDefinition">InterfaceTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">interface</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="InterfaceTypeExtension"><span class="spec-nt"><a href="#InterfaceTypeExtension" data-name="InterfaceTypeExtension">InterfaceTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">interface</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#FieldsDefinition" data-name="FieldsDefinition">FieldsDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">interface</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><div class="spec-production" id="UnionTypeDefinition"><span class="spec-nt"><a href="#UnionTypeDefinition" data-name="UnionTypeDefinition">UnionTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">union</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="UnionMemberTypes"><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span><div class="spec-rhs"><span class="spec-t">=</span><span class="spec-quantified"><span class="spec-t">|</span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span><span class="spec-t">|</span><span class="spec-nt"><a href="#NamedType" data-name="NamedType">NamedType</a></span></div></div><div class="spec-production" id="UnionTypeExtension"><span class="spec-nt"><a href="#UnionTypeExtension" data-name="UnionTypeExtension">UnionTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">union</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#UnionMemberTypes" data-name="UnionMemberTypes">UnionMemberTypes</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">union</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><div class="spec-production" id="EnumTypeDefinition"><span class="spec-nt"><a href="#EnumTypeDefinition" data-name="EnumTypeDefinition">EnumTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">enum</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#EnumValuesDefinition" data-name="EnumValuesDefinition">EnumValuesDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="EnumValuesDefinition"><span class="spec-nt"><a href="#EnumValuesDefinition" data-name="EnumValuesDefinition">EnumValuesDefinition</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#EnumValueDefinition" data-name="EnumValueDefinition">EnumValueDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="EnumValueDefinition"><span class="spec-nt"><a href="#EnumValueDefinition" data-name="EnumValueDefinition">EnumValueDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#EnumValue" data-name="EnumValue">EnumValue</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="EnumTypeExtension"><span class="spec-nt"><a href="#EnumTypeExtension" data-name="EnumTypeExtension">EnumTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">enum</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#EnumValuesDefinition" data-name="EnumValuesDefinition">EnumValuesDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">enum</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><div class="spec-production" id="InputObjectTypeDefinition"><span class="spec-nt"><a href="#InputObjectTypeDefinition" data-name="InputObjectTypeDefinition">InputObjectTypeDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">input</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-quantified"><span class="spec-nt"><a href="#InputFieldsDefinition" data-name="InputFieldsDefinition">InputFieldsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span></div></div><div class="spec-production" id="InputFieldsDefinition"><span class="spec-nt"><a href="#InputFieldsDefinition" data-name="InputFieldsDefinition">InputFieldsDefinition</a></span><div class="spec-rhs"><span class="spec-t">{</span><span class="spec-quantified"><span class="spec-nt"><a href="#InputValueDefinition" data-name="InputValueDefinition">InputValueDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier list">list</span></span></span><span class="spec-t">}</span></div></div><div class="spec-production" id="InputObjectTypeExtension"><span class="spec-nt"><a href="#InputObjectTypeExtension" data-name="InputObjectTypeExtension">InputObjectTypeExtension</a></span><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">input</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#InputFieldsDefinition" data-name="InputFieldsDefinition">InputFieldsDefinition</a></span></div><div class="spec-rhs"><span class="spec-t">extend</span><span class="spec-t">input</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-nt"><a href="#Directives" data-name="Directives">Directives</a><span class="spec-params"><span class="spec-param">Const</span></span></span></div></div><div class="spec-production" id="DirectiveDefinition"><span class="spec-nt"><a href="#DirectiveDefinition" data-name="DirectiveDefinition">DirectiveDefinition</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-nt"><a href="#Description" data-name="Description">Description</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">directive</span><span class="spec-t">@</span><span class="spec-nt"><a href="#Name" data-name="Name">Name</a></span><span class="spec-quantified"><span class="spec-nt"><a href="#ArgumentsDefinition" data-name="ArgumentsDefinition">ArgumentsDefinition</a></span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-t">on</span><span class="spec-nt"><a href="#DirectiveLocations" data-name="DirectiveLocations">DirectiveLocations</a></span></div></div><div class="spec-production" id="DirectiveLocations"><span class="spec-nt"><a href="#DirectiveLocations" data-name="DirectiveLocations">DirectiveLocations</a></span><div class="spec-rhs"><span class="spec-quantified"><span class="spec-t">|</span><span class="spec-quantifiers"><span class="spec-quantifier optional">opt</span></span></span><span class="spec-nt"><a href="#DirectiveLocation" data-name="DirectiveLocation">DirectiveLocation</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#DirectiveLocations" data-name="DirectiveLocations">DirectiveLocations</a></span><span class="spec-t">|</span><span class="spec-nt"><a href="#DirectiveLocation" data-name="DirectiveLocation">DirectiveLocation</a></span></div></div><div class="spec-production" id="DirectiveLocation"><span class="spec-nt"><a href="#DirectiveLocation" data-name="DirectiveLocation">DirectiveLocation</a></span><div class="spec-rhs"><span class="spec-nt"><a href="#ExecutableDirectiveLocation" data-name="ExecutableDirectiveLocation">ExecutableDirectiveLocation</a></span></div><div class="spec-rhs"><span class="spec-nt"><a href="#TypeSystemDirectiveLocation" data-name="TypeSystemDirectiveLocation">TypeSystemDirectiveLocation</a></span></div></div><div class="spec-production" id="ExecutableDirectiveLocation"><span class="spec-nt"><a href="#ExecutableDirectiveLocation" data-name="ExecutableDirectiveLocation">ExecutableDirectiveLocation</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">QUERY</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">MUTATION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">SUBSCRIPTION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FIELD</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FRAGMENT_DEFINITION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FRAGMENT_SPREAD</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INLINE_FRAGMENT</span></td></tr></table></div></div><div class="spec-production" id="TypeSystemDirectiveLocation"><span class="spec-nt"><a href="#TypeSystemDirectiveLocation" data-name="TypeSystemDirectiveLocation">TypeSystemDirectiveLocation</a></span><div class="spec-oneof"><table><tr><td class="spec-rhs"><span class="spec-t">SCHEMA</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">SCALAR</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">OBJECT</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">FIELD_DEFINITION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">ARGUMENT_DEFINITION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INTERFACE</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">UNION</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">ENUM</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">ENUM_VALUE</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INPUT_OBJECT</span></td></tr><tr><td class="spec-rhs"><span class="spec-t">INPUT_FIELD_DEFINITION</span></td></tr></table></div></div></section></section><section id="index" secid="index" class="spec-index"><h1><span class="spec-secid" title="link to the index"><a href="#index">§</a></span>Index</h1><ol><li><a href="#Alias">Alias</a></li><li><a href="#AreTypesCompatible()">AreTypesCompatible</a></li><li><a href="#Argument">Argument</a></li><li><a href="#Arguments">Arguments</a></li><li><a href="#ArgumentsDefinition">ArgumentsDefinition</a></li><li><a href="#BlockStringCharacter">BlockStringCharacter</a></li><li><a href="#BlockStringValue()">BlockStringValue</a></li><li><a href="#BooleanValue">BooleanValue</a></li><li><a href="#CoerceArgumentValues()">CoerceArgumentValues</a></li><li><a href="#CoerceVariableValues()">CoerceVariableValues</a></li><li><a href="#CollectFields()">CollectFields</a></li><li><a href="#Comma">Comma</a></li><li><a href="#Comment">Comment</a></li><li><a href="#CommentChar">CommentChar</a></li><li><a href="#CompleteValue()">CompleteValue</a></li><li><a href="#CreateSourceEventStream()">CreateSourceEventStream</a></li><li><a href="#DefaultValue">DefaultValue</a></li><li><a href="#Definition">Definition</a></li><li><a href="#Description">Description</a></li><li><a href="#Digit">Digit</a></li><li><a href="#Directive">Directive</a></li><li><a href="#DirectiveDefinition">DirectiveDefinition</a></li><li><a href="#DirectiveLocation">DirectiveLocation</a></li><li><a href="#DirectiveLocations">DirectiveLocations</a></li><li><a href="#Directives">Directives</a></li><li><a href="#Document">Document</a></li><li><a href="#DoesFragmentTypeApply()">DoesFragmentTypeApply</a></li><li><a href="#EnumTypeDefinition">EnumTypeDefinition</a></li><li><a href="#EnumTypeExtension">EnumTypeExtension</a></li><li><a href="#EnumValue">EnumValue</a></li><li><a href="#EnumValueDefinition">EnumValueDefinition</a></li><li><a href="#EnumValuesDefinition">EnumValuesDefinition</a></li><li><a href="#EscapedCharacter">EscapedCharacter</a></li><li><a href="#EscapedUnicode">EscapedUnicode</a></li><li><a href="#ExecutableDefinition">ExecutableDefinition</a></li><li><a href="#ExecutableDirectiveLocation">ExecutableDirectiveLocation</a></li><li><a href="#ExecuteField()">ExecuteField</a></li><li><a href="#ExecuteMutation()">ExecuteMutation</a></li><li><a href="#ExecuteQuery()">ExecuteQuery</a></li><li><a href="#ExecuteRequest()">ExecuteRequest</a></li><li><a href="#ExecuteSelectionSet()">ExecuteSelectionSet</a></li><li><a href="#ExecuteSubscriptionEvent()">ExecuteSubscriptionEvent</a></li><li><a href="#ExponentIndicator">ExponentIndicator</a></li><li><a href="#ExponentPart">ExponentPart</a></li><li><a href="#Field">Field</a></li><li><a href="#FieldDefinition">FieldDefinition</a></li><li><a href="#FieldsDefinition">FieldsDefinition</a></li><li><a href="#FieldsInSetCanMerge()">FieldsInSetCanMerge</a></li><li><a href="#FloatValue">FloatValue</a></li><li><a href="#FractionalPart">FractionalPart</a></li><li><a href="#FragmentDefinition">FragmentDefinition</a></li><li><a href="#FragmentName">FragmentName</a></li><li><a href="#FragmentSpread">FragmentSpread</a></li><li><a href="#GetOperation()">GetOperation</a></li><li><a href="#GetPossibleTypes()">GetPossibleTypes</a></li><li><a href="#Ignored">Ignored</a></li><li><a href="#ImplementsInterfaces">ImplementsInterfaces</a></li><li><a href="#InlineFragment">InlineFragment</a></li><li><a href="#InputFieldsDefinition">InputFieldsDefinition</a></li><li><a href="#InputObjectTypeDefinition">InputObjectTypeDefinition</a></li><li><a href="#InputObjectTypeExtension">InputObjectTypeExtension</a></li><li><a href="#InputValueDefinition">InputValueDefinition</a></li><li><a href="#IntValue">IntValue</a></li><li><a href="#IntegerPart">IntegerPart</a></li><li><a href="#InterfaceTypeDefinition">InterfaceTypeDefinition</a></li><li><a href="#InterfaceTypeExtension">InterfaceTypeExtension</a></li><li><a href="#IsInputType()">IsInputType</a></li><li><a href="#IsOutputType()">IsOutputType</a></li><li><a href="#IsVariableUsageAllowed()">IsVariableUsageAllowed</a></li><li><a href="#LineTerminator">LineTerminator</a></li><li><a href="#ListType">ListType</a></li><li><a href="#ListValue">ListValue</a></li><li><a href="#MapSourceToResponseEvent()">MapSourceToResponseEvent</a></li><li><a href="#MergeSelectionSets()">MergeSelectionSets</a></li><li><a href="#Name">Name</a></li><li><a href="#NamedType">NamedType</a></li><li><a href="#NegativeSign">NegativeSign</a></li><li><a href="#NonNullType">NonNullType</a></li><li><a href="#NonZeroDigit">NonZeroDigit</a></li><li><a href="#NullValue">NullValue</a></li><li><a href="#ObjectField">ObjectField</a></li><li><a href="#ObjectTypeDefinition">ObjectTypeDefinition</a></li><li><a href="#ObjectTypeExtension">ObjectTypeExtension</a></li><li><a href="#ObjectValue">ObjectValue</a></li><li><a href="#OperationDefinition">OperationDefinition</a></li><li><a href="#OperationType">OperationType</a></li><li><a href="#Punctuator">Punctuator</a></li><li><a href="#ResolveAbstractType()">ResolveAbstractType</a></li><li><a href="#ResolveFieldEventStream()">ResolveFieldEventStream</a></li><li><a href="#ResolveFieldValue()">ResolveFieldValue</a></li><li><a href="#RootOperationTypeDefinition">RootOperationTypeDefinition</a></li><li><a href="#SameResponseShape()">SameResponseShape</a></li><li><a href="#ScalarTypeDefinition">ScalarTypeDefinition</a></li><li><a href="#ScalarTypeExtension">ScalarTypeExtension</a></li><li><a href="#SchemaDefinition">SchemaDefinition</a></li><li><a href="#SchemaExtension">SchemaExtension</a></li><li><a href="#Selection">Selection</a></li><li><a href="#SelectionSet">SelectionSet</a></li><li><a href="#Sign">Sign</a></li><li><a href="#SourceCharacter">SourceCharacter</a></li><li><a href="#StringCharacter">StringCharacter</a></li><li><a href="#StringValue">StringValue</a></li><li><a href="#Subscribe()">Subscribe</a></li><li><a href="#Token">Token</a></li><li><a href="#Type">Type</a></li><li><a href="#TypeCondition">TypeCondition</a></li><li><a href="#TypeDefinition">TypeDefinition</a></li><li><a href="#TypeExtension">TypeExtension</a></li><li><a href="#TypeSystemDefinition">TypeSystemDefinition</a></li><li><a href="#TypeSystemDirectiveLocation">TypeSystemDirectiveLocation</a></li><li><a href="#TypeSystemExtension">TypeSystemExtension</a></li><li><a href="#UnicodeBOM">UnicodeBOM</a></li><li><a href="#UnionMemberTypes">UnionMemberTypes</a></li><li><a href="#UnionTypeDefinition">UnionTypeDefinition</a></li><li><a href="#UnionTypeExtension">UnionTypeExtension</a></li><li><a href="#Unsubscribe()">Unsubscribe</a></li><li><a href="#Value">Value</a></li><li><a href="#Variable">Variable</a></li><li><a href="#VariableDefinition">VariableDefinition</a></li><li><a href="#VariableDefinitions">VariableDefinitions</a></li><li><a href="#WhiteSpace">WhiteSpace</a></li></ol></section><footer>Written in <a href="http://leebyron.com/spec-md/" target="_blank">Spec Markdown</a>.</footer><input hidden class="spec-sidebar-toggle" type="checkbox" id="spec-sidebar-toggle" aria-hidden /><label for="spec-sidebar-toggle" aria-hidden>&#x2630;</label><div class="spec-sidebar" aria-hidden><div class="spec-toc"><div class="title"><a href="#">GraphQL</a></div><ol><li id="_sidebar_1"><a href="#sec-Overview"><span class="spec-secid">1</span>Overview</a></li><li id="_sidebar_2"><a href="#sec-Language"><span class="spec-secid">2</span>Language</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_2" /><label for="_sidebar_toggle_2"></label><ol><li id="_sidebar_2.1"><a href="#sec-Source-Text"><span class="spec-secid">2.1</span>Source Text</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_2.1" /><label for="_sidebar_toggle_2.1"></label><ol><li id="_sidebar_2.1.1"><a href="#sec-Unicode"><span class="spec-secid">2.1.1</span>Unicode</a></li><li id="_sidebar_2.1.2"><a href="#sec-White-Space"><span class="spec-secid">2.1.2</span>White Space</a></li><li id="_sidebar_2.1.3"><a href="#sec-Line-Terminators"><span class="spec-secid">2.1.3</span>Line Terminators</a></li><li id="_sidebar_2.1.4"><a href="#sec-Comments"><span class="spec-secid">2.1.4</span>Comments</a></li><li id="_sidebar_2.1.5"><a href="#sec-Insignificant-Commas"><span class="spec-secid">2.1.5</span>Insignificant Commas</a></li><li id="_sidebar_2.1.6"><a href="#sec-Source-Text.Lexical-Tokens"><span class="spec-secid">2.1.6</span>Lexical Tokens</a></li><li id="_sidebar_2.1.7"><a href="#sec-Source-Text.Ignored-Tokens"><span class="spec-secid">2.1.7</span>Ignored Tokens</a></li><li id="_sidebar_2.1.8"><a href="#sec-Punctuators"><span class="spec-secid">2.1.8</span>Punctuators</a></li><li id="_sidebar_2.1.9"><a href="#sec-Names"><span class="spec-secid">2.1.9</span>Names</a></li></ol></li><li id="_sidebar_2.2"><a href="#sec-Language.Document"><span class="spec-secid">2.2</span>Document</a></li><li id="_sidebar_2.3"><a href="#sec-Language.Operations"><span class="spec-secid">2.3</span>Operations</a></li><li id="_sidebar_2.4"><a href="#sec-Selection-Sets"><span class="spec-secid">2.4</span>Selection Sets</a></li><li id="_sidebar_2.5"><a href="#sec-Language.Fields"><span class="spec-secid">2.5</span>Fields</a></li><li id="_sidebar_2.6"><a href="#sec-Language.Arguments"><span class="spec-secid">2.6</span>Arguments</a></li><li id="_sidebar_2.7"><a href="#sec-Field-Alias"><span class="spec-secid">2.7</span>Field Alias</a></li><li id="_sidebar_2.8"><a href="#sec-Language.Fragments"><span class="spec-secid">2.8</span>Fragments</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_2.8" /><label for="_sidebar_toggle_2.8"></label><ol><li id="_sidebar_2.8.1"><a href="#sec-Type-Conditions"><span class="spec-secid">2.8.1</span>Type Conditions</a></li><li id="_sidebar_2.8.2"><a href="#sec-Inline-Fragments"><span class="spec-secid">2.8.2</span>Inline Fragments</a></li></ol></li><li id="_sidebar_2.9"><a href="#sec-Input-Values"><span class="spec-secid">2.9</span>Input Values</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_2.9" /><label for="_sidebar_toggle_2.9"></label><ol><li id="_sidebar_2.9.1"><a href="#sec-Int-Value"><span class="spec-secid">2.9.1</span>Int Value</a></li><li id="_sidebar_2.9.2"><a href="#sec-Float-Value"><span class="spec-secid">2.9.2</span>Float Value</a></li><li id="_sidebar_2.9.3"><a href="#sec-Boolean-Value"><span class="spec-secid">2.9.3</span>Boolean Value</a></li><li id="_sidebar_2.9.4"><a href="#sec-String-Value"><span class="spec-secid">2.9.4</span>String Value</a></li><li id="_sidebar_2.9.5"><a href="#sec-Null-Value"><span class="spec-secid">2.9.5</span>Null Value</a></li><li id="_sidebar_2.9.6"><a href="#sec-Enum-Value"><span class="spec-secid">2.9.6</span>Enum Value</a></li><li id="_sidebar_2.9.7"><a href="#sec-List-Value"><span class="spec-secid">2.9.7</span>List Value</a></li><li id="_sidebar_2.9.8"><a href="#sec-Input-Object-Values"><span class="spec-secid">2.9.8</span>Input Object Values</a></li></ol></li><li id="_sidebar_2.10"><a href="#sec-Language.Variables"><span class="spec-secid">2.10</span>Variables</a></li><li id="_sidebar_2.11"><a href="#sec-Type-References"><span class="spec-secid">2.11</span>Type References</a></li><li id="_sidebar_2.12"><a href="#sec-Language.Directives"><span class="spec-secid">2.12</span>Directives</a></li></ol></li><li id="_sidebar_3"><a href="#sec-Type-System"><span class="spec-secid">3</span>Type System</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3" /><label for="_sidebar_toggle_3"></label><ol><li id="_sidebar_3.1"><a href="#sec-Type-System-Extensions"><span class="spec-secid">3.1</span>Type System Extensions</a></li><li id="_sidebar_3.2"><a href="#sec-Schema"><span class="spec-secid">3.2</span>Schema</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.2" /><label for="_sidebar_toggle_3.2"></label><ol><li id="_sidebar_3.2.1"><a href="#sec-Root-Operation-Types"><span class="spec-secid">3.2.1</span>Root Operation Types</a></li><li id="_sidebar_3.2.2"><a href="#sec-Schema-Extension"><span class="spec-secid">3.2.2</span>Schema Extension</a></li></ol></li><li id="_sidebar_3.3"><a href="#sec-Descriptions"><span class="spec-secid">3.3</span>Descriptions</a></li><li id="_sidebar_3.4"><a href="#sec-Types"><span class="spec-secid">3.4</span>Types</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.4" /><label for="_sidebar_toggle_3.4"></label><ol><li id="_sidebar_3.4.1"><a href="#sec-Wrapping-Types"><span class="spec-secid">3.4.1</span>Wrapping Types</a></li><li id="_sidebar_3.4.2"><a href="#sec-Input-and-Output-Types"><span class="spec-secid">3.4.2</span>Input and Output Types</a></li><li id="_sidebar_3.4.3"><a href="#sec-Type-Extensions"><span class="spec-secid">3.4.3</span>Type Extensions</a></li></ol></li><li id="_sidebar_3.5"><a href="#sec-Scalars"><span class="spec-secid">3.5</span>Scalars</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.5" /><label for="_sidebar_toggle_3.5"></label><ol><li id="_sidebar_3.5.1"><a href="#sec-Int"><span class="spec-secid">3.5.1</span>Int</a></li><li id="_sidebar_3.5.2"><a href="#sec-Float"><span class="spec-secid">3.5.2</span>Float</a></li><li id="_sidebar_3.5.3"><a href="#sec-String"><span class="spec-secid">3.5.3</span>String</a></li><li id="_sidebar_3.5.4"><a href="#sec-Boolean"><span class="spec-secid">3.5.4</span>Boolean</a></li><li id="_sidebar_3.5.5"><a href="#sec-ID"><span class="spec-secid">3.5.5</span>ID</a></li><li id="_sidebar_3.5.6"><a href="#sec-Scalar-Extensions"><span class="spec-secid">3.5.6</span>Scalar Extensions</a></li></ol></li><li id="_sidebar_3.6"><a href="#sec-Objects"><span class="spec-secid">3.6</span>Objects</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.6" /><label for="_sidebar_toggle_3.6"></label><ol><li id="_sidebar_3.6.1"><a href="#sec-Field-Arguments"><span class="spec-secid">3.6.1</span>Field Arguments</a></li><li id="_sidebar_3.6.2"><a href="#sec-Field-Deprecation"><span class="spec-secid">3.6.2</span>Field Deprecation</a></li><li id="_sidebar_3.6.3"><a href="#sec-Object-Extensions"><span class="spec-secid">3.6.3</span>Object Extensions</a></li></ol></li><li id="_sidebar_3.7"><a href="#sec-Interfaces"><span class="spec-secid">3.7</span>Interfaces</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.7" /><label for="_sidebar_toggle_3.7"></label><ol><li id="_sidebar_3.7.1"><a href="#sec-Interface-Extensions"><span class="spec-secid">3.7.1</span>Interface Extensions</a></li></ol></li><li id="_sidebar_3.8"><a href="#sec-Unions"><span class="spec-secid">3.8</span>Unions</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.8" /><label for="_sidebar_toggle_3.8"></label><ol><li id="_sidebar_3.8.1"><a href="#sec-Union-Extensions"><span class="spec-secid">3.8.1</span>Union Extensions</a></li></ol></li><li id="_sidebar_3.9"><a href="#sec-Enums"><span class="spec-secid">3.9</span>Enums</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.9" /><label for="_sidebar_toggle_3.9"></label><ol><li id="_sidebar_3.9.1"><a href="#sec-Enum-Extensions"><span class="spec-secid">3.9.1</span>Enum Extensions</a></li></ol></li><li id="_sidebar_3.10"><a href="#sec-Input-Objects"><span class="spec-secid">3.10</span>Input Objects</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.10" /><label for="_sidebar_toggle_3.10"></label><ol><li id="_sidebar_3.10.1"><a href="#sec-Input-Object-Extensions"><span class="spec-secid">3.10.1</span>Input Object Extensions</a></li></ol></li><li id="_sidebar_3.11"><a href="#sec-Type-System.List"><span class="spec-secid">3.11</span>List</a></li><li id="_sidebar_3.12"><a href="#sec-Type-System.Non-Null"><span class="spec-secid">3.12</span>Non-Null</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.12" /><label for="_sidebar_toggle_3.12"></label><ol><li id="_sidebar_3.12.1"><a href="#sec-Combining-List-and-Non-Null"><span class="spec-secid">3.12.1</span>Combining List and Non-Null</a></li></ol></li><li id="_sidebar_3.13"><a href="#sec-Type-System.Directives"><span class="spec-secid">3.13</span>Directives</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_3.13" /><label for="_sidebar_toggle_3.13"></label><ol><li id="_sidebar_3.13.1"><a href="#sec--skip"><span class="spec-secid">3.13.1</span>@skip</a></li><li id="_sidebar_3.13.2"><a href="#sec--include"><span class="spec-secid">3.13.2</span>@include</a></li><li id="_sidebar_3.13.3"><a href="#sec--deprecated"><span class="spec-secid">3.13.3</span>@deprecated</a></li></ol></li></ol></li><li id="_sidebar_4"><a href="#sec-Introspection"><span class="spec-secid">4</span>Introspection</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_4" /><label for="_sidebar_toggle_4"></label><ol><li id="_sidebar_4.1"><a href="#sec-Reserved-Names"><span class="spec-secid">4.1</span>Reserved Names</a></li><li id="_sidebar_4.2"><a href="#sec-Documentation"><span class="spec-secid">4.2</span>Documentation</a></li><li id="_sidebar_4.3"><a href="#sec-Deprecation"><span class="spec-secid">4.3</span>Deprecation</a></li><li id="_sidebar_4.4"><a href="#sec-Type-Name-Introspection"><span class="spec-secid">4.4</span>Type Name Introspection</a></li><li id="_sidebar_4.5"><a href="#sec-Schema-Introspection"><span class="spec-secid">4.5</span>Schema Introspection</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_4.5" /><label for="_sidebar_toggle_4.5"></label><ol><li id="_sidebar_4.5.1"><a href="#sec-The-__Type-Type"><span class="spec-secid">4.5.1</span>The __Type Type</a></li><li id="_sidebar_4.5.2"><a href="#sec-Type-Kinds"><span class="spec-secid">4.5.2</span>Type Kinds</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_4.5.2" /><label for="_sidebar_toggle_4.5.2"></label><ol><li id="_sidebar_4.5.2.1"><a href="#sec-Scalar"><span class="spec-secid">4.5.2.1</span>Scalar</a></li><li id="_sidebar_4.5.2.2"><a href="#sec-Object"><span class="spec-secid">4.5.2.2</span>Object</a></li><li id="_sidebar_4.5.2.3"><a href="#sec-Union"><span class="spec-secid">4.5.2.3</span>Union</a></li><li id="_sidebar_4.5.2.4"><a href="#sec-Interface"><span class="spec-secid">4.5.2.4</span>Interface</a></li><li id="_sidebar_4.5.2.5"><a href="#sec-Enum"><span class="spec-secid">4.5.2.5</span>Enum</a></li><li id="_sidebar_4.5.2.6"><a href="#sec-Input-Object"><span class="spec-secid">4.5.2.6</span>Input Object</a></li><li id="_sidebar_4.5.2.7"><a href="#sec-Type-Kinds.List"><span class="spec-secid">4.5.2.7</span>List</a></li><li id="_sidebar_4.5.2.8"><a href="#sec-Type-Kinds.Non-Null"><span class="spec-secid">4.5.2.8</span>Non-Null</a></li></ol></li><li id="_sidebar_4.5.3"><a href="#sec-The-__Field-Type"><span class="spec-secid">4.5.3</span>The __Field Type</a></li><li id="_sidebar_4.5.4"><a href="#sec-The-__InputValue-Type"><span class="spec-secid">4.5.4</span>The __InputValue Type</a></li><li id="_sidebar_4.5.5"><a href="#sec-The-__EnumValue-Type"><span class="spec-secid">4.5.5</span>The __EnumValue Type</a></li><li id="_sidebar_4.5.6"><a href="#sec-The-__Directive-Type"><span class="spec-secid">4.5.6</span>The __Directive Type</a></li></ol></li></ol></li><li id="_sidebar_5"><a href="#sec-Validation"><span class="spec-secid">5</span>Validation</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5" /><label for="_sidebar_toggle_5"></label><ol><li id="_sidebar_5.1"><a href="#sec-Documents"><span class="spec-secid">5.1</span>Documents</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.1" /><label for="_sidebar_toggle_5.1"></label><ol><li id="_sidebar_5.1.1"><a href="#sec-Executable-Definitions"><span class="spec-secid">5.1.1</span>Executable Definitions</a></li></ol></li><li id="_sidebar_5.2"><a href="#sec-Validation.Operations"><span class="spec-secid">5.2</span>Operations</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.2" /><label for="_sidebar_toggle_5.2"></label><ol><li id="_sidebar_5.2.1"><a href="#sec-Named-Operation-Definitions"><span class="spec-secid">5.2.1</span>Named Operation Definitions</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.2.1" /><label for="_sidebar_toggle_5.2.1"></label><ol><li id="_sidebar_5.2.1.1"><a href="#sec-Operation-Name-Uniqueness"><span class="spec-secid">5.2.1.1</span>Operation Name Uniqueness</a></li></ol></li><li id="_sidebar_5.2.2"><a href="#sec-Anonymous-Operation-Definitions"><span class="spec-secid">5.2.2</span>Anonymous Operation Definitions</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.2.2" /><label for="_sidebar_toggle_5.2.2"></label><ol><li id="_sidebar_5.2.2.1"><a href="#sec-Lone-Anonymous-Operation"><span class="spec-secid">5.2.2.1</span>Lone Anonymous Operation</a></li></ol></li><li id="_sidebar_5.2.3"><a href="#sec-Subscription-Operation-Definitions"><span class="spec-secid">5.2.3</span>Subscription Operation Definitions</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.2.3" /><label for="_sidebar_toggle_5.2.3"></label><ol><li id="_sidebar_5.2.3.1"><a href="#sec-Single-root-field"><span class="spec-secid">5.2.3.1</span>Single root field</a></li></ol></li></ol></li><li id="_sidebar_5.3"><a href="#sec-Validation.Fields"><span class="spec-secid">5.3</span>Fields</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.3" /><label for="_sidebar_toggle_5.3"></label><ol><li id="_sidebar_5.3.1"><a href="#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types"><span class="spec-secid">5.3.1</span>Field Selections on Objects, Interfaces, and Unions Types</a></li><li id="_sidebar_5.3.2"><a href="#sec-Field-Selection-Merging"><span class="spec-secid">5.3.2</span>Field Selection Merging</a></li><li id="_sidebar_5.3.3"><a href="#sec-Leaf-Field-Selections"><span class="spec-secid">5.3.3</span>Leaf Field Selections</a></li></ol></li><li id="_sidebar_5.4"><a href="#sec-Validation.Arguments"><span class="spec-secid">5.4</span>Arguments</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.4" /><label for="_sidebar_toggle_5.4"></label><ol><li id="_sidebar_5.4.1"><a href="#sec-Argument-Names"><span class="spec-secid">5.4.1</span>Argument Names</a></li><li id="_sidebar_5.4.2"><a href="#sec-Argument-Uniqueness"><span class="spec-secid">5.4.2</span>Argument Uniqueness</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.4.2" /><label for="_sidebar_toggle_5.4.2"></label><ol><li id="_sidebar_5.4.2.1"><a href="#sec-Required-Arguments"><span class="spec-secid">5.4.2.1</span>Required Arguments</a></li></ol></li></ol></li><li id="_sidebar_5.5"><a href="#sec-Validation.Fragments"><span class="spec-secid">5.5</span>Fragments</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.5" /><label for="_sidebar_toggle_5.5"></label><ol><li id="_sidebar_5.5.1"><a href="#sec-Fragment-Declarations"><span class="spec-secid">5.5.1</span>Fragment Declarations</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.5.1" /><label for="_sidebar_toggle_5.5.1"></label><ol><li id="_sidebar_5.5.1.1"><a href="#sec-Fragment-Name-Uniqueness"><span class="spec-secid">5.5.1.1</span>Fragment Name Uniqueness</a></li><li id="_sidebar_5.5.1.2"><a href="#sec-Fragment-Spread-Type-Existence"><span class="spec-secid">5.5.1.2</span>Fragment Spread Type Existence</a></li><li id="_sidebar_5.5.1.3"><a href="#sec-Fragments-On-Composite-Types"><span class="spec-secid">5.5.1.3</span>Fragments On Composite Types</a></li><li id="_sidebar_5.5.1.4"><a href="#sec-Fragments-Must-Be-Used"><span class="spec-secid">5.5.1.4</span>Fragments Must Be Used</a></li></ol></li><li id="_sidebar_5.5.2"><a href="#sec-Fragment-Spreads"><span class="spec-secid">5.5.2</span>Fragment Spreads</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.5.2" /><label for="_sidebar_toggle_5.5.2"></label><ol><li id="_sidebar_5.5.2.1"><a href="#sec-Fragment-spread-target-defined"><span class="spec-secid">5.5.2.1</span>Fragment spread target defined</a></li><li id="_sidebar_5.5.2.2"><a href="#sec-Fragment-spreads-must-not-form-cycles"><span class="spec-secid">5.5.2.2</span>Fragment spreads must not form cycles</a></li><li id="_sidebar_5.5.2.3"><a href="#sec-Fragment-spread-is-possible"><span class="spec-secid">5.5.2.3</span>Fragment spread is possible</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.5.2.3" /><label for="_sidebar_toggle_5.5.2.3"></label><ol><li id="_sidebar_5.5.2.3.1"><a href="#sec-Object-Spreads-In-Object-Scope"><span class="spec-secid">5.5.2.3.1</span>Object Spreads In Object Scope</a></li><li id="_sidebar_5.5.2.3.2"><a href="#sec-Abstract-Spreads-in-Object-Scope"><span class="spec-secid">5.5.2.3.2</span>Abstract Spreads in Object Scope</a></li><li id="_sidebar_5.5.2.3.3"><a href="#sec-Object-Spreads-In-Abstract-Scope"><span class="spec-secid">5.5.2.3.3</span>Object Spreads In Abstract Scope</a></li><li id="_sidebar_5.5.2.3.4"><a href="#sec-Abstract-Spreads-in-Abstract-Scope"><span class="spec-secid">5.5.2.3.4</span>Abstract Spreads in Abstract Scope</a></li></ol></li></ol></li></ol></li><li id="_sidebar_5.6"><a href="#sec-Values"><span class="spec-secid">5.6</span>Values</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.6" /><label for="_sidebar_toggle_5.6"></label><ol><li id="_sidebar_5.6.1"><a href="#sec-Values-of-Correct-Type"><span class="spec-secid">5.6.1</span>Values of Correct Type</a></li><li id="_sidebar_5.6.2"><a href="#sec-Input-Object-Field-Names"><span class="spec-secid">5.6.2</span>Input Object Field Names</a></li><li id="_sidebar_5.6.3"><a href="#sec-Input-Object-Field-Uniqueness"><span class="spec-secid">5.6.3</span>Input Object Field Uniqueness</a></li><li id="_sidebar_5.6.4"><a href="#sec-Input-Object-Required-Fields"><span class="spec-secid">5.6.4</span>Input Object Required Fields</a></li></ol></li><li id="_sidebar_5.7"><a href="#sec-Validation.Directives"><span class="spec-secid">5.7</span>Directives</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.7" /><label for="_sidebar_toggle_5.7"></label><ol><li id="_sidebar_5.7.1"><a href="#sec-Directives-Are-Defined"><span class="spec-secid">5.7.1</span>Directives Are Defined</a></li><li id="_sidebar_5.7.2"><a href="#sec-Directives-Are-In-Valid-Locations"><span class="spec-secid">5.7.2</span>Directives Are In Valid Locations</a></li><li id="_sidebar_5.7.3"><a href="#sec-Directives-Are-Unique-Per-Location"><span class="spec-secid">5.7.3</span>Directives Are Unique Per Location</a></li></ol></li><li id="_sidebar_5.8"><a href="#sec-Validation.Variables"><span class="spec-secid">5.8</span>Variables</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_5.8" /><label for="_sidebar_toggle_5.8"></label><ol><li id="_sidebar_5.8.1"><a href="#sec-Variable-Uniqueness"><span class="spec-secid">5.8.1</span>Variable Uniqueness</a></li><li id="_sidebar_5.8.2"><a href="#sec-Variables-Are-Input-Types"><span class="spec-secid">5.8.2</span>Variables Are Input Types</a></li><li id="_sidebar_5.8.3"><a href="#sec-All-Variable-Uses-Defined"><span class="spec-secid">5.8.3</span>All Variable Uses Defined</a></li><li id="_sidebar_5.8.4"><a href="#sec-All-Variables-Used"><span class="spec-secid">5.8.4</span>All Variables Used</a></li><li id="_sidebar_5.8.5"><a href="#sec-All-Variable-Usages-are-Allowed"><span class="spec-secid">5.8.5</span>All Variable Usages are Allowed</a></li></ol></li></ol></li><li id="_sidebar_6"><a href="#sec-Execution"><span class="spec-secid">6</span>Execution</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_6" /><label for="_sidebar_toggle_6"></label><ol><li id="_sidebar_6.1"><a href="#sec-Executing-Requests"><span class="spec-secid">6.1</span>Executing Requests</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_6.1" /><label for="_sidebar_toggle_6.1"></label><ol><li id="_sidebar_6.1.1"><a href="#sec-Validating-Requests"><span class="spec-secid">6.1.1</span>Validating Requests</a></li><li id="_sidebar_6.1.2"><a href="#sec-Coercing-Variable-Values"><span class="spec-secid">6.1.2</span>Coercing Variable Values</a></li></ol></li><li id="_sidebar_6.2"><a href="#sec-Executing-Operations"><span class="spec-secid">6.2</span>Executing Operations</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_6.2" /><label for="_sidebar_toggle_6.2"></label><ol><li id="_sidebar_6.2.1"><a href="#sec-Query"><span class="spec-secid">6.2.1</span>Query</a></li><li id="_sidebar_6.2.2"><a href="#sec-Mutation"><span class="spec-secid">6.2.2</span>Mutation</a></li><li id="_sidebar_6.2.3"><a href="#sec-Subscription"><span class="spec-secid">6.2.3</span>Subscription</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_6.2.3" /><label for="_sidebar_toggle_6.2.3"></label><ol><li id="_sidebar_6.2.3.1"><a href="#sec-Source-Stream"><span class="spec-secid">6.2.3.1</span>Source Stream</a></li><li id="_sidebar_6.2.3.2"><a href="#sec-Response-Stream"><span class="spec-secid">6.2.3.2</span>Response Stream</a></li><li id="_sidebar_6.2.3.3"><a href="#sec-Unsubscribe"><span class="spec-secid">6.2.3.3</span>Unsubscribe</a></li></ol></li></ol></li><li id="_sidebar_6.3"><a href="#sec-Executing-Selection-Sets"><span class="spec-secid">6.3</span>Executing Selection Sets</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_6.3" /><label for="_sidebar_toggle_6.3"></label><ol><li id="_sidebar_6.3.1"><a href="#sec-Normal-and-Serial-Execution"><span class="spec-secid">6.3.1</span>Normal and Serial Execution</a></li><li id="_sidebar_6.3.2"><a href="#sec-Field-Collection"><span class="spec-secid">6.3.2</span>Field Collection</a></li></ol></li><li id="_sidebar_6.4"><a href="#sec-Executing-Fields"><span class="spec-secid">6.4</span>Executing Fields</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_6.4" /><label for="_sidebar_toggle_6.4"></label><ol><li id="_sidebar_6.4.1"><a href="#sec-Coercing-Field-Arguments"><span class="spec-secid">6.4.1</span>Coercing Field Arguments</a></li><li id="_sidebar_6.4.2"><a href="#sec-Value-Resolution"><span class="spec-secid">6.4.2</span>Value Resolution</a></li><li id="_sidebar_6.4.3"><a href="#sec-Value-Completion"><span class="spec-secid">6.4.3</span>Value Completion</a></li><li id="_sidebar_6.4.4"><a href="#sec-Errors-and-Non-Nullability"><span class="spec-secid">6.4.4</span>Errors and Non-Nullability</a></li></ol></li></ol></li><li id="_sidebar_7"><a href="#sec-Response"><span class="spec-secid">7</span>Response</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_7" /><label for="_sidebar_toggle_7"></label><ol><li id="_sidebar_7.1"><a href="#sec-Response-Format"><span class="spec-secid">7.1</span>Response Format</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_7.1" /><label for="_sidebar_toggle_7.1"></label><ol><li id="_sidebar_7.1.1"><a href="#sec-Data"><span class="spec-secid">7.1.1</span>Data</a></li><li id="_sidebar_7.1.2"><a href="#sec-Errors"><span class="spec-secid">7.1.2</span>Errors</a></li></ol></li><li id="_sidebar_7.2"><a href="#sec-Serialization-Format"><span class="spec-secid">7.2</span>Serialization Format</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_7.2" /><label for="_sidebar_toggle_7.2"></label><ol><li id="_sidebar_7.2.1"><a href="#sec-JSON-Serialization"><span class="spec-secid">7.2.1</span>JSON Serialization</a></li><li id="_sidebar_7.2.2"><a href="#sec-Serialized-Map-Ordering"><span class="spec-secid">7.2.2</span>Serialized Map Ordering</a></li></ol></li></ol></li><li id="_sidebar_A"><a href="#sec-Appendix-Notation-Conventions"><span class="spec-secid">A</span>Appendix: Notation Conventions</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_A" /><label for="_sidebar_toggle_A"></label><ol><li id="_sidebar_A.1"><a href="#sec-Context-Free-Grammar"><span class="spec-secid">A.1</span>Context-Free Grammar</a></li><li id="_sidebar_A.2"><a href="#sec-Lexical-and-Syntactical-Grammar"><span class="spec-secid">A.2</span>Lexical and Syntactical Grammar</a></li><li id="_sidebar_A.3"><a href="#sec-Grammar-Notation"><span class="spec-secid">A.3</span>Grammar Notation</a></li><li id="_sidebar_A.4"><a href="#sec-Grammar-Semantics"><span class="spec-secid">A.4</span>Grammar Semantics</a></li><li id="_sidebar_A.5"><a href="#sec-Algorithms"><span class="spec-secid">A.5</span>Algorithms</a></li></ol></li><li id="_sidebar_B"><a href="#sec-Appendix-Grammar-Summary"><span class="spec-secid">B</span>Appendix: Grammar Summary</a><input hidden class="toggle" type="checkbox" id="_sidebar_toggle_B" /><label for="_sidebar_toggle_B"></label><ol><li id="_sidebar_B.1"><a href="#sec-Appendix-Grammar-Summary.Ignored-Tokens"><span class="spec-secid">B.1</span>Ignored Tokens</a></li><li id="_sidebar_B.2"><a href="#sec-Appendix-Grammar-Summary.Lexical-Tokens"><span class="spec-secid">B.2</span>Lexical Tokens</a></li><li id="_sidebar_B.3"><a href="#sec-Appendix-Grammar-Summary.Document"><span class="spec-secid">B.3</span>Document</a></li></ol></li><li id="_sidebar_index"><a href="#index"><span class="spec-secid">§</span>Index</a></li></ol></div><script>(function (){ var currentSection; var numberedSections = []; var sections = document.getElementsByTagName('section'); for (var i = 0; i < sections.length; i++) { if (sections[i].getAttribute('secid')) { numberedSections.push(sections[i]); } } var scrollPos = window.scrollY; var pending = false; window.addEventListener('scroll', function (e) { scrollPos = window.scrollY; if (!pending) { pending = true; window.requestAnimationFrame(function () { updateSectionFocus(scrollPos); pending = false; }); } }); function updateSectionFocus(pos) { var readLine = pos + document.documentElement.clientHeight / 4; var focusedSection; for (var n = numberedSections.length - 1; n >= 0; n--) { if (numberedSections[n].offsetTop < readLine) { focusedSection = numberedSections[n]; break; } } var secid = focusedSection && focusedSection.getAttribute('secid'); if (secid !== currentSection) { currentSection && fold(currentSection, false); secid && fold(secid, true); currentSection = secid; } } function fold(secid, check) { document.getElementById('_sidebar_' + secid).className = check ? 'viewing' : ''; var sections = secid.split('.'); while (sections.length) { var toggle = document.getElementById('_sidebar_toggle_' + sections.join('.')); if (toggle) { toggle.checked = check; } sections.pop(); } } updateSectionFocus(window.scrollY); })()</script></div></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10