Skip to content

Commit c4fdbf6

Browse files
committed
feat: update grammar for executable descriptions
1 parent 9399cea commit c4fdbf6

File tree

2 files changed

+41
-35
lines changed

2 files changed

+41
-35
lines changed

crates/apollo-parser/src/cst/generated/nodes.rs

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
//! This is a generated file, please do not edit manually. Changes can be
22
//! made in codegeneration that lives in `xtask` top-level dir.
33
4-
use crate::cst::support;
5-
use crate::cst::CstChildren;
6-
use crate::cst::CstNode;
7-
use crate::SyntaxKind;
8-
use crate::SyntaxKind::*;
9-
use crate::SyntaxNode;
10-
use crate::SyntaxToken;
11-
use crate::S;
4+
use crate::{
5+
cst::{support, CstChildren, CstNode},
6+
SyntaxKind::{self, *},
7+
SyntaxNode, SyntaxToken, S,
8+
};
129
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1310
pub struct Name {
1411
pub(crate) syntax: SyntaxNode,
@@ -32,6 +29,9 @@ pub struct OperationDefinition {
3229
pub(crate) syntax: SyntaxNode,
3330
}
3431
impl OperationDefinition {
32+
pub fn description(&self) -> Option<Description> {
33+
support::child(&self.syntax)
34+
}
3535
pub fn operation_type(&self) -> Option<OperationType> {
3636
support::child(&self.syntax)
3737
}
@@ -53,6 +53,9 @@ pub struct FragmentDefinition {
5353
pub(crate) syntax: SyntaxNode,
5454
}
5555
impl FragmentDefinition {
56+
pub fn description(&self) -> Option<Description> {
57+
support::child(&self.syntax)
58+
}
5659
pub fn fragment_token(&self) -> Option<SyntaxToken> {
5760
support::token(&self.syntax, S![fragment])
5861
}
@@ -406,6 +409,15 @@ impl InputObjectTypeExtension {
406409
}
407410
}
408411
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
412+
pub struct Description {
413+
pub(crate) syntax: SyntaxNode,
414+
}
415+
impl Description {
416+
pub fn string_value(&self) -> Option<StringValue> {
417+
support::child(&self.syntax)
418+
}
419+
}
420+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
409421
pub struct OperationType {
410422
pub(crate) syntax: SyntaxNode,
411423
}
@@ -700,6 +712,9 @@ pub struct VariableDefinition {
700712
pub(crate) syntax: SyntaxNode,
701713
}
702714
impl VariableDefinition {
715+
pub fn description(&self) -> Option<Description> {
716+
support::child(&self.syntax)
717+
}
703718
pub fn variable(&self) -> Option<Variable> {
704719
support::child(&self.syntax)
705720
}
@@ -774,15 +789,6 @@ impl Directive {
774789
}
775790
}
776791
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
777-
pub struct Description {
778-
pub(crate) syntax: SyntaxNode,
779-
}
780-
impl Description {
781-
pub fn string_value(&self) -> Option<StringValue> {
782-
support::child(&self.syntax)
783-
}
784-
}
785-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
786792
pub struct RootOperationTypeDefinition {
787793
pub(crate) syntax: SyntaxNode,
788794
}
@@ -1351,6 +1357,21 @@ impl CstNode for InputObjectTypeExtension {
13511357
&self.syntax
13521358
}
13531359
}
1360+
impl CstNode for Description {
1361+
fn can_cast(kind: SyntaxKind) -> bool {
1362+
kind == DESCRIPTION
1363+
}
1364+
fn cast(syntax: SyntaxNode) -> Option<Self> {
1365+
if Self::can_cast(syntax.kind()) {
1366+
Some(Self { syntax })
1367+
} else {
1368+
None
1369+
}
1370+
}
1371+
fn syntax(&self) -> &SyntaxNode {
1372+
&self.syntax
1373+
}
1374+
}
13541375
impl CstNode for OperationType {
13551376
fn can_cast(kind: SyntaxKind) -> bool {
13561377
kind == OPERATION_TYPE
@@ -1771,21 +1792,6 @@ impl CstNode for Directive {
17711792
&self.syntax
17721793
}
17731794
}
1774-
impl CstNode for Description {
1775-
fn can_cast(kind: SyntaxKind) -> bool {
1776-
kind == DESCRIPTION
1777-
}
1778-
fn cast(syntax: SyntaxNode) -> Option<Self> {
1779-
if Self::can_cast(syntax.kind()) {
1780-
Some(Self { syntax })
1781-
} else {
1782-
None
1783-
}
1784-
}
1785-
fn syntax(&self) -> &SyntaxNode {
1786-
&self.syntax
1787-
}
1788-
}
17891795
impl CstNode for RootOperationTypeDefinition {
17901796
fn can_cast(kind: SyntaxKind) -> bool {
17911797
kind == ROOT_OPERATION_TYPE_DEFINITION

graphql.ungram

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Definition =
3939
| InputObjectTypeExtension
4040

4141
OperationDefinition =
42-
OperationType Name? VariableDefinitions? Directives? SelectionSet
42+
Description? OperationType Name? VariableDefinitions? Directives? SelectionSet
4343
| SelectionSet
4444

4545
OperationType =
@@ -74,7 +74,7 @@ InlineFragment =
7474
'...' TypeCondition? Directives? SelectionSet
7575

7676
FragmentDefinition =
77-
'fragment' FragmentName TypeCondition Directives? SelectionSet
77+
Description? 'fragment' FragmentName TypeCondition Directives? SelectionSet
7878

7979
FragmentName =
8080
Name
@@ -127,7 +127,7 @@ VariableDefinitions =
127127
'(' VariableDefinition* ')'
128128

129129
VariableDefinition =
130-
Variable ':' Type DefaultValue? Directives?
130+
Description? Variable ':' Type DefaultValue? Directives?
131131

132132
Variable =
133133
'$' Name

0 commit comments

Comments
 (0)