-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for type extensions #154
Conversation
@@ -773,12 +773,63 @@ public void Should_Parse_Unions(string text) | |||
} | |||
|
|||
[Theory] | |||
[InlineData("type Query", ASTNodeKind.ObjectTypeDefinition)] | |||
[InlineData("extend type Query", ASTNodeKind.TypeExtensionDefinition)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extend type Query
actually is invalid query :) , see Should_Throw_Extensions
[InlineData("input Empty", ASTNodeKind.InputObjectTypeDefinition)] | ||
[InlineData("interface Empty", ASTNodeKind.InterfaceTypeDefinition)] | ||
[InlineData("enum Empty", ASTNodeKind.EnumTypeDefinition)] | ||
[InlineData("extend type Type implements Interface", ASTNodeKind.TypeExtensionDefinition)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into Should_Parse_Extensions
Codecov Report
@@ Coverage Diff @@
## master #154 +/- ##
==========================================
- Coverage 89.61% 86.56% -3.05%
==========================================
Files 55 61 +6
Lines 3263 3559 +296
Branches 333 363 +30
==========================================
+ Hits 2924 3081 +157
- Misses 300 430 +130
- Partials 39 48 +9
Continue to review full report at Codecov.
|
var name = ParseName(); | ||
var args = ParseArgumentDefs(); | ||
bool repeatable = ParseRepeatable(); | ||
var def = NodeHelper.CreateGraphQLDirectiveDefinition(_ignoreOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly changed all the ParseXXX
methods:
private GraphQLScalarValue ParseStringValue(/*bool isConstant*/)
{
var token = _currentToken; // store token before node creation
// new line
var val = NodeHelper.CreateGraphQLScalarValue(_ignoreOptions, ASTNodeKind.StringValue); // create node
// new line
val.Comment = GetComment(); // store comment first
Advance(); // some setup here
val.Value = token.Value;
val.Location = GetLocation(token.Start);
// new line before return
return val;
}
I moved the initialization of node properties to a later stage (after node creation) so that it matches the grammar specification as much as possible (only in terms of reading).
ExpectKeyword("union"); | ||
def.Name = ParseName(); | ||
def.Directives = ParseDirectives(); | ||
def.Types = Peek(TokenKind.EQUALS) ? ParseUnionMemberTypes() : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
if (interfaceTypeDefinition.Fields?.Count > 0) | ||
{ | ||
await context.WriteLine().ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three lines (and two more below) were moved under if
to handle empty interfaces.
OK to merge? No comments? |
Yes. No comments; whatever you think. |
fixes #143