Skip to content

Add GetDirectiveLocation extension method - #396

Merged
Shane32 merged 2 commits into
masterfrom
getdirectivelocation
Aug 20, 2024
Merged

Shane32 merged 2 commits into
masterfrom
getdirectivelocation

Conversation

@Shane32

@Shane32 Shane32 commented Aug 19, 2024 •

Copy link
Copy Markdown
Member

Closes #395 with a non-breaking solution. Not quite ideal, but good enough; argument fields and input object fields now use derived classes, and an extension method to ASTNode provides the directive location.

Other non-breaking options:

  1. Move the method into ASTNode and override it in each derived class
  2. Return null instead of throwing in case of error

Breaking options:

  1. Move the method into IHasDirectives
  2. Make the GraphQLInputValueDefinition ctor internal
  3. Remove support for parsing into an GraphQLInputValueDefinition class

@Shane32
Shane32 requested a review from gao-artur August 19, 2024 21:09
@Shane32 Shane32 self-assigned this Aug 19, 2024
@Shane32

Shane32 commented Aug 19, 2024 •

Copy link
Copy Markdown
Member Author

@gao-artur Let's include this in v8 also (parser v9). I don't think I have any other changes to do.

result = (T)(object)context.ParseInputObjectTypeDefinition();
else if (typeof(T) == typeof(GraphQLInputValueDefinition))
result = (T)(object)context.ParseInputValueDefinition();
result = (T)(object)context.ParseInputValueDefinition(null);

Check warning

Code scanning / CodeQL

Useless upcast

There is no need to upcast from [GraphQLInputValueDefinition](1) to [Object](2) - the conversion can be done implicitly.
result = (T)(object)context.ParseInputValueDefinition();
result = (T)(object)context.ParseInputValueDefinition(null);
else if (typeof(T) == typeof(GraphQLInputFieldDefinition))
result = (T)(object)context.ParseInputValueDefinition(false);

Check warning

Code scanning / CodeQL

Useless upcast

There is no need to upcast from [GraphQLInputValueDefinition](1) to [Object](2) - the conversion can be done implicitly.
else if (typeof(T) == typeof(GraphQLInputFieldDefinition))
result = (T)(object)context.ParseInputValueDefinition(false);
else if (typeof(T) == typeof(GraphQLArgumentDefinition))
result = (T)(object)context.ParseInputValueDefinition(true);

Check warning

Code scanning / CodeQL

Useless upcast

There is no need to upcast from [GraphQLInputValueDefinition](1) to [Object](2) - the conversion can be done implicitly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Argument definitions and input field definitions use same class

3 participants