graphql-dotnet / parser

A lexer and parser for GraphQL in .NET
MIT License
216 stars 43 forks source link

Add GetDirectiveLocation extension method #396

Closed Shane32 closed 2 months ago

Shane32 commented 2 months ago

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 commented 2 months ago

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