From 2ef386d7d03d1887b42f3fe8e8ca26ff0c36d449 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Mon, 1 Feb 2021 21:52:17 +0300 Subject: [PATCH 1/2] Add xml documentation --- README.md | 2 ++ src/Directory.Build.props | 2 +- .../GraphQL-Parser.approved.txt | 1 - .../GraphQLParser.Benchmarks.csproj | 1 + .../GraphQLParser.Tests.csproj | 1 + src/GraphQLParser/AST/ASTNodeKind.cs | 17 +++++++++++++++++ src/GraphQLParser/AST/GraphQLArgument.cs | 5 +++-- src/GraphQLParser/AST/GraphQLDirective.cs | 4 ++++ .../AST/GraphQLDirectiveDefinition.cs | 16 ++++++++++++++-- .../AST/GraphQLEnumTypeDefinition.cs | 1 + .../AST/GraphQLEnumValueDefinition.cs | 1 + src/GraphQLParser/AST/GraphQLFieldDefinition.cs | 1 + src/GraphQLParser/AST/GraphQLFieldSelection.cs | 2 ++ .../AST/GraphQLFragmentDefinition.cs | 1 + src/GraphQLParser/AST/GraphQLFragmentSpread.cs | 2 ++ src/GraphQLParser/AST/GraphQLInlineFragment.cs | 1 + .../AST/GraphQLInputObjectTypeDefinition.cs | 1 + .../AST/GraphQLInputValueDefinition.cs | 1 + .../AST/GraphQLInterfaceTypeDefinition.cs | 1 + src/GraphQLParser/AST/GraphQLNamedType.cs | 1 + src/GraphQLParser/AST/GraphQLObjectField.cs | 1 + .../AST/GraphQLObjectTypeDefinition.cs | 1 + .../AST/GraphQLOperationDefinition.cs | 2 ++ .../AST/GraphQLScalarTypeDefinition.cs | 1 + .../AST/GraphQLSchemaDefinition.cs | 1 + src/GraphQLParser/AST/GraphQLTypeDefinition.cs | 5 +++-- .../AST/GraphQLUnionTypeDefinition.cs | 1 + src/GraphQLParser/AST/GraphQLVariable.cs | 1 + src/GraphQLParser/AST/IHasDirectivesNode.cs | 8 +++++++- src/GraphQLParser/AST/INamedNode.cs | 8 +++++++- 30 files changed, 81 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cdb0041c..547f84ab 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ **master**
[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=master)](https://coveralls.io/github/graphql-dotnet/parser?branch=master)
**develop**
[![Coverage Status](https://coveralls.io/repos/github/graphql-dotnet/parser/badge.svg?branch=develop)](https://coveralls.io/github/graphql-dotnet/parser?branch=develop)
+
+ [![NuGet](https://img.shields.io/nuget/v/GraphQL-Parser.svg)](https://www.nuget.org/packages/GraphQL-Parser) [![Nuget](https://img.shields.io/nuget/dt/GraphQL-Parser)](https://www.nuget.org/packages/GraphQL-Parser) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index dc86f7c9..68dcd4a5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -20,7 +20,7 @@ True true - $(NoWarn);1591 + $(NoWarn);1591 enable diff --git a/src/GraphQLParser.ApiTests/GraphQL-Parser.approved.txt b/src/GraphQLParser.ApiTests/GraphQL-Parser.approved.txt index a9a3c2db..4d50ec48 100644 --- a/src/GraphQLParser.ApiTests/GraphQL-Parser.approved.txt +++ b/src/GraphQLParser.ApiTests/GraphQL-Parser.approved.txt @@ -73,7 +73,6 @@ namespace GraphQLParser.AST { public GraphQLDirectiveDefinition() { } public System.Collections.Generic.List? Arguments { get; set; } - public System.Collections.Generic.List? Definitions { get; set; } public override GraphQLParser.AST.ASTNodeKind Kind { get; } public System.Collections.Generic.List? Locations { get; set; } public bool Repeatable { get; set; } diff --git a/src/GraphQLParser.Benchmarks/GraphQLParser.Benchmarks.csproj b/src/GraphQLParser.Benchmarks/GraphQLParser.Benchmarks.csproj index 53fa2af6..638c134e 100644 --- a/src/GraphQLParser.Benchmarks/GraphQLParser.Benchmarks.csproj +++ b/src/GraphQLParser.Benchmarks/GraphQLParser.Benchmarks.csproj @@ -4,6 +4,7 @@ net5 Exe false + $(NoWarn);1591 diff --git a/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj b/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj index d1376a86..cc11f1d0 100644 --- a/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj +++ b/src/GraphQLParser.Tests/GraphQLParser.Tests.csproj @@ -3,6 +3,7 @@ net5;netcoreapp3.1 disable + $(NoWarn);1591 diff --git a/src/GraphQLParser/AST/ASTNodeKind.cs b/src/GraphQLParser/AST/ASTNodeKind.cs index 6629312f..02229af0 100644 --- a/src/GraphQLParser/AST/ASTNodeKind.cs +++ b/src/GraphQLParser/AST/ASTNodeKind.cs @@ -46,10 +46,20 @@ public enum ASTNodeKind ListValue, ObjectValue, ObjectField, + + /// + /// Applied directive. Directives provide a way to describe alternate runtime execution + /// and type validation behavior in a GraphQL document. Directives can be used to describe + /// additional information for types, fields, fragments, operations, etc. + /// Directive, NamedType, ListType, NonNullType, + + /// + /// Null values are represented as the keyword null. + /// NullValue, SchemaDefinition, OperationTypeDefinition, @@ -63,6 +73,13 @@ public enum ASTNodeKind EnumValueDefinition, InputObjectTypeDefinition, TypeExtensionDefinition, + + + /// + /// Directive definition. Directives provide a way to describe alternate runtime execution + /// and type validation behavior in a GraphQL document. Directives can be used to describe + /// additional information for types, fields, fragments, operations, etc. + /// DirectiveDefinition, /// diff --git a/src/GraphQLParser/AST/GraphQLArgument.cs b/src/GraphQLParser/AST/GraphQLArgument.cs index a275f6fb..5411b362 100644 --- a/src/GraphQLParser/AST/GraphQLArgument.cs +++ b/src/GraphQLParser/AST/GraphQLArgument.cs @@ -5,6 +5,7 @@ public class GraphQLArgument : ASTNode, INamedNode /// public override ASTNodeKind Kind => ASTNodeKind.Argument; + /// public GraphQLName? Name { get; set; } public GraphQLValue? Value { get; set; } @@ -18,12 +19,12 @@ internal sealed class GraphQLArgumentFull : GraphQLArgument public override GraphQLLocation Location { get => _location; - set => _location = value; + set => _location = value; } public override GraphQLComment? Comment { - get => _comment; + get => _comment; set => _comment = value; } } diff --git a/src/GraphQLParser/AST/GraphQLDirective.cs b/src/GraphQLParser/AST/GraphQLDirective.cs index acc5e2b4..9715a80a 100644 --- a/src/GraphQLParser/AST/GraphQLDirective.cs +++ b/src/GraphQLParser/AST/GraphQLDirective.cs @@ -2,6 +2,9 @@ namespace GraphQLParser.AST { + /// + /// Represents a directive, applied to some GraphQL element. + /// public class GraphQLDirective : ASTNode, INamedNode { public List? Arguments { get; set; } @@ -9,6 +12,7 @@ public class GraphQLDirective : ASTNode, INamedNode /// public override ASTNodeKind Kind => ASTNodeKind.Directive; + /// public GraphQLName? Name { get; set; } } diff --git a/src/GraphQLParser/AST/GraphQLDirectiveDefinition.cs b/src/GraphQLParser/AST/GraphQLDirectiveDefinition.cs index dc6adc5a..4db3e61a 100644 --- a/src/GraphQLParser/AST/GraphQLDirectiveDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLDirectiveDefinition.cs @@ -2,17 +2,29 @@ namespace GraphQLParser.AST { + /// + /// Represents a directive definition. + /// public class GraphQLDirectiveDefinition : GraphQLTypeDefinition { public List? Arguments { get; set; } - public List? Definitions { get; set; } - /// public override ASTNodeKind Kind => ASTNodeKind.DirectiveDefinition; + /// + /// Returns a list of locations representing the valid locations this directive may be placed. + /// public List? Locations { get; set; } + /// + /// Indicates if the directive may be used repeatedly at a single location. + ///

+ /// Repeatable directives are often useful when the same directive + /// should be used with different arguments at a single location, + /// especially in cases where additional information needs to be + /// provided to a type or schema extension via a directive + ///
public bool Repeatable { get; set; } } diff --git a/src/GraphQLParser/AST/GraphQLEnumTypeDefinition.cs b/src/GraphQLParser/AST/GraphQLEnumTypeDefinition.cs index d0cbcec5..9fd18ad3 100644 --- a/src/GraphQLParser/AST/GraphQLEnumTypeDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLEnumTypeDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLEnumTypeDefinition : GraphQLTypeDefinition, IHasDirectivesNode { + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLEnumValueDefinition.cs b/src/GraphQLParser/AST/GraphQLEnumValueDefinition.cs index 41d292e5..3dc28fb2 100644 --- a/src/GraphQLParser/AST/GraphQLEnumValueDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLEnumValueDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLEnumValueDefinition : GraphQLTypeDefinition, IHasDirectivesNode { + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLFieldDefinition.cs b/src/GraphQLParser/AST/GraphQLFieldDefinition.cs index 9b6a4e53..003041c9 100644 --- a/src/GraphQLParser/AST/GraphQLFieldDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLFieldDefinition.cs @@ -6,6 +6,7 @@ public class GraphQLFieldDefinition : GraphQLTypeDefinition, IHasDirectivesNode { public List? Arguments { get; set; } + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLFieldSelection.cs b/src/GraphQLParser/AST/GraphQLFieldSelection.cs index 439f4fc1..4122b5b9 100644 --- a/src/GraphQLParser/AST/GraphQLFieldSelection.cs +++ b/src/GraphQLParser/AST/GraphQLFieldSelection.cs @@ -8,11 +8,13 @@ public class GraphQLFieldSelection : ASTNode, IHasDirectivesNode, INamedNode public List? Arguments { get; set; } + /// public List? Directives { get; set; } /// public override ASTNodeKind Kind => ASTNodeKind.Field; + /// public GraphQLName? Name { get; set; } public GraphQLSelectionSet? SelectionSet { get; set; } diff --git a/src/GraphQLParser/AST/GraphQLFragmentDefinition.cs b/src/GraphQLParser/AST/GraphQLFragmentDefinition.cs index 0b26b750..bdfd7ae2 100644 --- a/src/GraphQLParser/AST/GraphQLFragmentDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLFragmentDefinition.cs @@ -5,6 +5,7 @@ public class GraphQLFragmentDefinition : GraphQLInlineFragment, INamedNode /// public override ASTNodeKind Kind => ASTNodeKind.FragmentDefinition; + /// public GraphQLName? Name { get; set; } } diff --git a/src/GraphQLParser/AST/GraphQLFragmentSpread.cs b/src/GraphQLParser/AST/GraphQLFragmentSpread.cs index bf85b418..95524ca4 100644 --- a/src/GraphQLParser/AST/GraphQLFragmentSpread.cs +++ b/src/GraphQLParser/AST/GraphQLFragmentSpread.cs @@ -4,11 +4,13 @@ namespace GraphQLParser.AST { public class GraphQLFragmentSpread : ASTNode, IHasDirectivesNode, INamedNode { + /// public List? Directives { get; set; } /// public override ASTNodeKind Kind => ASTNodeKind.FragmentSpread; + /// public GraphQLName? Name { get; set; } } diff --git a/src/GraphQLParser/AST/GraphQLInlineFragment.cs b/src/GraphQLParser/AST/GraphQLInlineFragment.cs index 846c3c00..9ece5a4e 100644 --- a/src/GraphQLParser/AST/GraphQLInlineFragment.cs +++ b/src/GraphQLParser/AST/GraphQLInlineFragment.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLInlineFragment : ASTNode, IHasDirectivesNode { + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLInputObjectTypeDefinition.cs b/src/GraphQLParser/AST/GraphQLInputObjectTypeDefinition.cs index 4192a18a..02f7af8f 100644 --- a/src/GraphQLParser/AST/GraphQLInputObjectTypeDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLInputObjectTypeDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLInputObjectTypeDefinition : GraphQLTypeDefinition, IHasDirectivesNode { + /// public List? Directives { get; set; } public List? Fields { get; set; } diff --git a/src/GraphQLParser/AST/GraphQLInputValueDefinition.cs b/src/GraphQLParser/AST/GraphQLInputValueDefinition.cs index abe27ca3..f5388c71 100644 --- a/src/GraphQLParser/AST/GraphQLInputValueDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLInputValueDefinition.cs @@ -6,6 +6,7 @@ public class GraphQLInputValueDefinition : GraphQLTypeDefinition, IHasDirectives { public GraphQLValue? DefaultValue { get; set; } + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLInterfaceTypeDefinition.cs b/src/GraphQLParser/AST/GraphQLInterfaceTypeDefinition.cs index 395e0be9..7d78bfdd 100644 --- a/src/GraphQLParser/AST/GraphQLInterfaceTypeDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLInterfaceTypeDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLInterfaceTypeDefinition : GraphQLTypeDefinition, IHasDirectivesNode { + /// public List? Directives { get; set; } public List? Fields { get; set; } diff --git a/src/GraphQLParser/AST/GraphQLNamedType.cs b/src/GraphQLParser/AST/GraphQLNamedType.cs index 32d6943c..dfd3e225 100644 --- a/src/GraphQLParser/AST/GraphQLNamedType.cs +++ b/src/GraphQLParser/AST/GraphQLNamedType.cs @@ -5,6 +5,7 @@ public class GraphQLNamedType : GraphQLType, INamedNode /// public override ASTNodeKind Kind => ASTNodeKind.NamedType; + /// public GraphQLName? Name { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLObjectField.cs b/src/GraphQLParser/AST/GraphQLObjectField.cs index 96fa465e..92733a79 100644 --- a/src/GraphQLParser/AST/GraphQLObjectField.cs +++ b/src/GraphQLParser/AST/GraphQLObjectField.cs @@ -5,6 +5,7 @@ public class GraphQLObjectField : ASTNode, INamedNode /// public override ASTNodeKind Kind => ASTNodeKind.ObjectField; + /// public GraphQLName? Name { get; set; } public GraphQLValue? Value { get; set; } diff --git a/src/GraphQLParser/AST/GraphQLObjectTypeDefinition.cs b/src/GraphQLParser/AST/GraphQLObjectTypeDefinition.cs index 45f29096..708cd948 100644 --- a/src/GraphQLParser/AST/GraphQLObjectTypeDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLObjectTypeDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLObjectTypeDefinition : GraphQLTypeDefinition, IHasDirectivesNode { + /// public List? Directives { get; set; } public List? Fields { get; set; } diff --git a/src/GraphQLParser/AST/GraphQLOperationDefinition.cs b/src/GraphQLParser/AST/GraphQLOperationDefinition.cs index 62bcb46e..47e12466 100644 --- a/src/GraphQLParser/AST/GraphQLOperationDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLOperationDefinition.cs @@ -4,11 +4,13 @@ namespace GraphQLParser.AST { public class GraphQLOperationDefinition : ASTNode, IHasDirectivesNode, INamedNode { + /// public List? Directives { get; set; } /// public override ASTNodeKind Kind => ASTNodeKind.OperationDefinition; + /// public GraphQLName? Name { get; set; } public OperationType Operation { get; set; } diff --git a/src/GraphQLParser/AST/GraphQLScalarTypeDefinition.cs b/src/GraphQLParser/AST/GraphQLScalarTypeDefinition.cs index 7d122f8f..00d91e98 100644 --- a/src/GraphQLParser/AST/GraphQLScalarTypeDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLScalarTypeDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLScalarTypeDefinition : GraphQLTypeDefinition, IHasDirectivesNode { + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLSchemaDefinition.cs b/src/GraphQLParser/AST/GraphQLSchemaDefinition.cs index 3d967ef9..5679ec59 100644 --- a/src/GraphQLParser/AST/GraphQLSchemaDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLSchemaDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLSchemaDefinition : ASTNode, IHasDirectivesNode { + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLTypeDefinition.cs b/src/GraphQLParser/AST/GraphQLTypeDefinition.cs index 8410a642..3f0c7d12 100644 --- a/src/GraphQLParser/AST/GraphQLTypeDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLTypeDefinition.cs @@ -1,7 +1,8 @@ -namespace GraphQLParser.AST +namespace GraphQLParser.AST { public abstract class GraphQLTypeDefinition : ASTNode, INamedNode { + /// public GraphQLName? Name { get; set; } } -} \ No newline at end of file +} diff --git a/src/GraphQLParser/AST/GraphQLUnionTypeDefinition.cs b/src/GraphQLParser/AST/GraphQLUnionTypeDefinition.cs index 88c2995b..3ee86ab5 100644 --- a/src/GraphQLParser/AST/GraphQLUnionTypeDefinition.cs +++ b/src/GraphQLParser/AST/GraphQLUnionTypeDefinition.cs @@ -4,6 +4,7 @@ namespace GraphQLParser.AST { public class GraphQLUnionTypeDefinition : GraphQLTypeDefinition, IHasDirectivesNode { + /// public List? Directives { get; set; } /// diff --git a/src/GraphQLParser/AST/GraphQLVariable.cs b/src/GraphQLParser/AST/GraphQLVariable.cs index 86f135bc..0e4efe96 100644 --- a/src/GraphQLParser/AST/GraphQLVariable.cs +++ b/src/GraphQLParser/AST/GraphQLVariable.cs @@ -5,6 +5,7 @@ public class GraphQLVariable : GraphQLValue, INamedNode /// public override ASTNodeKind Kind => ASTNodeKind.Variable; + /// public GraphQLName? Name { get; set; } } diff --git a/src/GraphQLParser/AST/IHasDirectivesNode.cs b/src/GraphQLParser/AST/IHasDirectivesNode.cs index f2abdf19..f971a7af 100644 --- a/src/GraphQLParser/AST/IHasDirectivesNode.cs +++ b/src/GraphQLParser/AST/IHasDirectivesNode.cs @@ -1,9 +1,15 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace GraphQLParser.AST { + /// + /// Represents an AST node that may have directives applied to it (type, argument, field, enum, etc.). + /// public interface IHasDirectivesNode { + /// + /// Directives of the node represented as a list of nested nodes. + /// List? Directives { get; set; } } } diff --git a/src/GraphQLParser/AST/INamedNode.cs b/src/GraphQLParser/AST/INamedNode.cs index 341d78da..34df6bb7 100644 --- a/src/GraphQLParser/AST/INamedNode.cs +++ b/src/GraphQLParser/AST/INamedNode.cs @@ -1,7 +1,13 @@ -namespace GraphQLParser.AST +namespace GraphQLParser.AST { + /// + /// Represents an AST node that has a name (type, argument, directive, field, operation, variable, etc.). + /// public interface INamedNode { + /// + /// Name of the node represented as a nested node. + /// GraphQLName? Name { get; set; } } } From 5cc843edef9977d605ada3dfd6ceb65c4472c0ec Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Mon, 1 Feb 2021 22:03:27 +0300 Subject: [PATCH 2/2] Update src/GraphQLParser/AST/ASTNodeKind.cs --- src/GraphQLParser/AST/ASTNodeKind.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/GraphQLParser/AST/ASTNodeKind.cs b/src/GraphQLParser/AST/ASTNodeKind.cs index 02229af0..56f96543 100644 --- a/src/GraphQLParser/AST/ASTNodeKind.cs +++ b/src/GraphQLParser/AST/ASTNodeKind.cs @@ -74,7 +74,6 @@ public enum ASTNodeKind InputObjectTypeDefinition, TypeExtensionDefinition, - /// /// Directive definition. Directives provide a way to describe alternate runtime execution /// and type validation behavior in a GraphQL document. Directives can be used to describe