* Corresponds to both FragmentSpread and InlineFragment in the spec. * * FragmentSpread : ... FragmentName Directives? * * InlineFragment : ... TypeCondition? Directives? SelectionSet
()
| 2176 | * InlineFragment : ... TypeCondition? Directives? SelectionSet |
| 2177 | */ |
| 2178 | parseFragment() { |
| 2179 | const start = this._lexer.token; |
| 2180 | this.expectToken(_tokenKind.TokenKind.SPREAD); |
| 2181 | const hasTypeCondition = this.expectOptionalKeyword("on"); |
| 2182 | if (!hasTypeCondition && this.peek(_tokenKind.TokenKind.NAME)) { |
| 2183 | return this.node(start, { |
| 2184 | kind: _kinds.Kind.FRAGMENT_SPREAD, |
| 2185 | name: this.parseFragmentName(), |
| 2186 | directives: this.parseDirectives(false) |
| 2187 | }); |
| 2188 | } |
| 2189 | return this.node(start, { |
| 2190 | kind: _kinds.Kind.INLINE_FRAGMENT, |
| 2191 | typeCondition: hasTypeCondition ? this.parseNamedType() : void 0, |
| 2192 | directives: this.parseDirectives(false), |
| 2193 | selectionSet: this.parseSelectionSet() |
| 2194 | }); |
| 2195 | } |
| 2196 | /** |
| 2197 | * FragmentDefinition : |
| 2198 | * - fragment FragmentName on TypeCondition Directives? SelectionSet |
no test coverage detected