Skip to content

Conversation

@Shane32
Copy link
Member

@Shane32 Shane32 commented Aug 19, 2024

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
Copy link
Member Author

Shane32 commented Aug 19, 2024

@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.
@Shane32 Shane32 merged commit 9faa2bd into master Aug 20, 2024
@Shane32 Shane32 deleted the getdirectivelocation branch August 20, 2024 03:56
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

2 participants