From 06f4fb258a989fd08eaa60ca374ed2edcbddaeac Mon Sep 17 00:00:00 2001 From: Craig Smitham Date: Thu, 23 Apr 2026 21:44:13 -0500 Subject: [PATCH 1/3] Replace LibLog with Microsoft.Extensions.Logging (#40) Remove unmaintained LibLog dependency and replace with Microsoft.Extensions.Logging in the ASP.NET Core server project. Co-Authored-By: Claude Opus 4.6 (1M context) --- Directory.Packages.props | 1 - .../GraphZenApplicationBuilderExtensions.cs | 11 ++++++----- .../GraphZenServiceCollectionExtensions.cs | 13 +------------ .../GraphZen.Infrastructure.csproj | 12 ++---------- src/GraphZen.TypeSystem/GraphQLContext.cs | 5 +---- 5 files changed, 10 insertions(+), 32 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index ec0e81740..d60142889 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,7 +4,6 @@ - diff --git a/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs b/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs index c1a881cd6..e8bbe54ac 100644 --- a/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs +++ b/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs @@ -7,13 +7,13 @@ using GraphZen.Internal; using GraphZen.LanguageModel; using GraphZen.LanguageModel.Internal; -using GraphZen.Logging; using GraphZen.QueryEngine; using GraphZen.QueryEngine.Validation; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; // ReSharper disable once CheckNamespace namespace Microsoft.AspNetCore.Builder; @@ -23,7 +23,6 @@ public static class GraphZenApplicationBuilderExtensions private const int DefaultMemoryThreshold = 1024 * 30; private static string? _sTempDirectory; - private static ILog Logger { get; } = LogProvider.GetCurrentClassLogger(); public static string TempDirectory { @@ -52,6 +51,8 @@ public static IEndpointConventionBuilder MapGraphQL(this IEndpointRouteBuilder e { return endpoints.MapPost(path, async httpContext => { + var logger = httpContext.RequestServices.GetRequiredService() + .CreateLogger(typeof(GraphZenApplicationBuilderExtensions)); var request = httpContext.Request; var readStream = request.Body; if (!request.Body.CanSeek) @@ -112,12 +113,12 @@ public static IEndpointConventionBuilder MapGraphQL(this IEndpointRouteBuilder e } catch (GraphQLException gqlException) { - Logger.Error(gqlException, gqlException.Message); + logger.LogError(gqlException, "{Message}", gqlException.Message); result = new ExecutionResult(null, new[] { gqlException.GraphQLError }); } catch (Exception e) { - Logger.Error(e, e.Message); + logger.LogError(e, "{Message}", e.Message); var coreOptions = graphQLContext.Options.GetExtension(); var error = coreOptions.RevealInternalServerErrors ? new GraphQLServerError(e.Message, innerException: e) @@ -129,4 +130,4 @@ public static IEndpointConventionBuilder MapGraphQL(this IEndpointRouteBuilder e await httpContext.Response.WriteAsync(resp); }); } -} \ No newline at end of file +} diff --git a/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs b/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs index ee2deff3f..e26b656a7 100644 --- a/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs +++ b/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs @@ -4,7 +4,6 @@ using System.Reflection; using GraphZen; using GraphZen.Infrastructure; -using GraphZen.Logging; using GraphZen.QueryEngine.Validation; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -13,8 +12,6 @@ namespace Microsoft.Extensions.DependencyInjection; public static class GraphZenServiceCollectionExtensions { - private static ILog Logger { get; } = LogProvider.GetCurrentClassLogger(); - public static void AddGraphQLContext( this IServiceCollection serviceCollection, Action? optionsAction = null) @@ -37,7 +34,6 @@ public static void AddGraphQLContext( : (Action?)null; var contextType = typeof(TContext); - Logger.Debug($"Adding GraphQL context {contextType}"); if (optionsAction != null) { var declaredConstructors = contextType.GetTypeInfo().DeclaredConstructors.ToList(); @@ -46,33 +42,26 @@ public static void AddGraphQLContext( $"{nameof(AddGraphQLContext)} was called with configuration, but the context type '{contextType}' only declares a parameterless constructor. This means that the configuration passed to {nameof(AddGraphQLContext)} will never be used. If configuration is passed to {nameof(AddGraphQLContext)}, then '{contextType}' should declare a constructor that accepts a {nameof(GraphQLContextOptions)}<{contextType.Name}> and must pass it to the base constructor for {nameof(GraphQLContext)}."); } - Logger.Debug($"Registering {nameof(GraphQLContextOptions)}"); serviceCollection.TryAdd(new ServiceDescriptor(typeof(GraphQLContextOptions), p => GraphQLContextOptionsFactory(p, optionsActionImpl), ServiceLifetime.Scoped)); - Logger.Debug($"Registering {nameof(GraphQLContextOptions)}"); serviceCollection.Add(new ServiceDescriptor(typeof(GraphQLContextOptions), p => p.GetRequiredService>(), ServiceLifetime.Scoped)); - Logger.Debug($"Registering {typeof(TContext)}"); serviceCollection.TryAdd(new ServiceDescriptor(typeof(TContext), typeof(TContext), ServiceLifetime.Scoped)); - Logger.Debug($"Registering {nameof(GraphQLContext)}"); serviceCollection.TryAdd(new ServiceDescriptor(typeof(GraphQLContext), p => p.GetRequiredService(), ServiceLifetime.Scoped)); - Logger.Debug($"Registering {nameof(IQueryValidator)}"); serviceCollection.TryAddScoped(_ => new QueryValidator()); - Logger.Debug("Building temporary service provider"); var tempServiceProvider = serviceCollection.BuildServiceProvider(); - Logger.Debug("Building temporary service provider"); var context = tempServiceProvider.GetRequiredService(); var queryClrType = context.Schema.QueryType?.ClrType; if (queryClrType != null) serviceCollection.TryAddScoped(queryClrType); @@ -91,4 +80,4 @@ private static GraphQLContextOptions GraphQLContextOptionsFactory + Infrastructure code supporting the GraphZen SDK. Not intended for direct installation or use. - LIBLOG_EXCLUDE_CODE_COVERAGE;$(DefineConstants) - - - all - runtime; build; native; contentfiles; analyzers - - - - \ No newline at end of file + diff --git a/src/GraphZen.TypeSystem/GraphQLContext.cs b/src/GraphZen.TypeSystem/GraphQLContext.cs index 6084f1c88..5100788de 100644 --- a/src/GraphZen.TypeSystem/GraphQLContext.cs +++ b/src/GraphZen.TypeSystem/GraphQLContext.cs @@ -2,14 +2,12 @@ // Licensed under the GraphZen Community License. See the LICENSE file in the project root for license information. using System.Reflection; -using GraphZen.Logging; using GraphZen.TypeSystem; namespace GraphZen; public class GraphQLContext { - private static readonly ILog Logger = LogProvider.For(); private GraphQLContextOptions _options; private bool _optionsInitialized; @@ -47,7 +45,6 @@ public GraphQLContextOptions Options OnConfiguring(optionsBuilder); _options = optionsBuilder.Options; _optionsInitialized = true; - Logger.Debug("howdy from GraphZen"); } return _options; @@ -139,4 +136,4 @@ protected internal virtual void OnConfiguring(GraphQLContextOptionsBuilder optio protected internal virtual void OnSchemaCreating(SchemaBuilder schemaBuilder) { } -} \ No newline at end of file +} From 4ba27eb9dd24d2fd8db05ef1d677057943ca9e27 Mon Sep 17 00:00:00 2001 From: Craig Smitham Date: Thu, 23 Apr 2026 21:46:41 -0500 Subject: [PATCH 2/3] Run JetBrains code cleanup (reformat only) Co-Authored-By: Claude Opus 4.6 (1M context) --- examples/SimpleBlog/FakeBlogData.cs | 4 +- examples/SimpleBlog/Models/Mutation.cs | 16 +- src/Directory.Build.props | 54 ++--- .../Infrastructure/Check.cs | 2 +- .../LanguageModel/DirectiveLocation.cs | 54 ++--- .../Playground/Internal/Files/playground.html | 2 +- .../Internal/PlaygroundHtmlWriter.cs | 5 +- .../GraphZenApplicationBuilderExtensions.cs | 6 +- .../GraphZenServiceCollectionExtensions.cs | 2 +- .../PlaygroundApplicationBuilderExtensions.cs | 5 +- .../GraphQLRequestExtensions.cs | 6 +- src/GraphZen.DevCli/CodeGen/CodeGenTasks.cs | 10 +- .../Infrastructure/Json.cs | 5 +- .../GraphQLSyntaxVisitor.Generated.cs | 2 +- .../Grammar/DirectiveDefinitionsGrammar.cs | 26 +-- .../Internal/Grammar/DirectiveGrammar.cs | 8 +- .../Internal/Grammar/DocumentGrammar.cs | 18 +- .../Grammar/EnumTypeDefinitionGrammar.cs | 26 +-- .../Grammar/EnumTypeExtensionGrammar.cs | 22 +- .../Internal/Grammar/FieldGrammar.cs | 36 +-- .../Internal/Grammar/FragmentGrammar.cs | 40 ++-- .../LanguageModel/Internal/Grammar/Grammar.cs | 14 +- .../InputObjectTypeExtensionGrammar.cs | 22 +- .../Grammar/InputObjectTypeGrammar.cs | 18 +- .../Internal/Grammar/InputTypeGrammar.cs | 16 +- .../Internal/Grammar/InputValuesGrammar.cs | 24 +- .../Grammar/InterfaceTypeDefinitionGrammar.cs | 12 +- .../Grammar/InterfaceTypeExtensionGrammar.cs | 12 +- .../Grammar/ObjectTypeDefinitionGrammar.cs | 70 +++--- .../Grammar/ObjectTypeExtensionGrammar.cs | 38 +-- .../Grammar/OperationDefinitionGrammar.cs | 26 +-- .../Grammar/ScalarTypeExtensionGrammar.cs | 10 +- .../Internal/Grammar/ScalarTypeGrammar.cs | 10 +- .../Grammar/SchemaExtensionGrammar.cs | 12 +- .../Internal/Grammar/SchemaGrammar.cs | 22 +- .../Internal/Grammar/SelectionSetGrammar.cs | 8 +- .../Grammar/UnionTypeDefinitionGrammar.cs | 12 +- .../Grammar/UnionTypeExtensionGrammar.cs | 10 +- .../Internal/Grammar/VariablesGrammar.cs | 22 +- .../LanguageModel/Internal/Printer.cs | 5 +- .../Syntax/SyntaxNode.Generated.cs | 2 +- .../Validation/DocumentValidationRules.cs | 17 +- .../Validation/Rules/ObjectsMustHaveFields.cs | 5 +- .../Validation/QueryValidationRules.cs | 32 +-- .../TypeSystem/Introspection.cs | 5 +- src/GraphZen.TypeSystem/TypeSystem/Schema.cs | 5 +- .../TypeSystem/SpecDirectives.cs | 14 +- .../TypeSystem/TypeKind.cs | 18 +- .../TypeSystem/TypeKindHelpers.cs | 9 - .../TypeSystemAccessors.Generated.cs | 3 +- test/Directory.Build.props | 40 ++-- .../GraphQLRequestIntegrationTests.cs | 5 +- .../Internal/GraphQLSerializerTests.cs | 6 +- .../GraphZen.Tests/Error/GraphQLErrorTests.cs | 13 +- test/GraphZen.Tests/FixIndentTests.cs | 15 +- .../LanguageModel/BlockStringValueTests.cs | 84 ++----- .../Internal/Parser/DirectiveParserTests.cs | 10 +- .../Parser/EnumTypeDefinitionParsingTests.cs | 10 +- .../Parser/EnumTypeExtensionParserTests.cs | 6 +- .../Internal/Parser/FragmentParserTests.cs | 17 +- .../InterfaceTypeDefinitionParsingTests.cs | 6 +- .../ObjectTypeDefinitionParsingTests.cs | 9 +- .../Parser/OperationDefinitionParsingTests.cs | 16 +- .../Parser/QueryDocumentParserTests.cs | 5 +- .../Parser/SchemaTypeExtensionParsingTests.cs | 4 +- .../Parser/UnionTypeExtensionParsingTests.cs | 11 +- .../LanguageModel/ParserTestBase.cs | 7 +- .../QueryEngine/AbstractTests.cs | 92 ++------ .../QueryEngine/ExecutorHarness.cs | 5 +- .../QueryEngine/ExecutorTests.cs | 63 +---- .../QueryEngine/MutationsTests.cs | 10 +- .../QueryEngine/UnionInterfaceTests.cs | 31 +-- .../Variables/ArgumentDefaultValuesTests.cs | 32 +-- .../Variables/CustomEnumValuesTests.cs | 8 +- .../Variables/ListsAndNullabilityTests.cs | 94 ++------ .../Variables/NonNullableScalarsTests.cs | 55 +---- .../Variables/NullableScalarsTests.cs | 48 +--- .../Variables/UsingInlineStructs.cs | 45 +--- .../QueryEngine/Variables/UsingVariables.cs | 148 ++---------- .../StarWars/StarWarsIntrospectionTest.cs | 220 ++++-------------- .../StarWars/StarWarsQueryTest.cs | 167 +++---------- .../StarWars/StarWarsSchemaAndData.cs | 17 +- .../IntrospectionTests/IntrospectionTests.cs | 7 +- .../Utilities/AstFromValueTests.cs | 11 +- .../Utilities/SdlSchemaConfiguratorTests.cs | 83 +------ .../FieldArgumentsMustHaveInputTypesTests.cs | 12 +- ...nputObjectFieldsMustHaveInputTypesTests.cs | 12 +- ...InterfaceFieldsMustHaveOutputTypesTests.cs | 8 +- .../ObjectFieldsMustHaveOutputTypesTests.cs | 8 +- .../Validation/Rules/SdlValidationHelpers.cs | 3 +- .../GraphZen.TypeSystem.Tests/ClrTypeUtils.cs | 18 +- ...irectives_ViaObjectClrPropertyAttribute.cs | 3 +- .../Enum_ViaClrEnum_Description.cs | 6 +- .../EnumValue_ViaClrEnumValue_Description.cs | 3 +- .../InputObject_ViaClrClass_Description.cs | 6 +- .../Interface_ViaClrClass_Description.cs | 6 +- ...Field_Argument_ViaClrMethod_Description.cs | 6 +- .../Object_ViaClrClass_Description.cs | 6 +- ...Field_Argument_ViaClrMethod_Description.cs | 6 +- .../Scalar_ViaClrClass_Description.cs | 6 +- .../Union_ViaClrClass_Description.cs | 6 +- ...Union_ViaClrMarkerInterface_Description.cs | 6 +- .../SchemaToSyntaxTests.cs | 10 +- .../TaxonomyTests.cs | 150 +++--------- 104 files changed, 713 insertions(+), 1790 deletions(-) diff --git a/examples/SimpleBlog/FakeBlogData.cs b/examples/SimpleBlog/FakeBlogData.cs index ae08d29e2..5ae99b7de 100644 --- a/examples/SimpleBlog/FakeBlogData.cs +++ b/examples/SimpleBlog/FakeBlogData.cs @@ -13,7 +13,9 @@ public static class FakeBlogData new Post { Id = 2, Author = "Jane", Title = "Follow up post", Content = "This blog is really fun!" }, new Post { - Id = 3, Author = "Gene", Title = "Guest post", + Id = 3, + Author = "Gene", + Title = "Guest post", Content = "Jane has let me write a guest post for her blog." } }; diff --git a/examples/SimpleBlog/Models/Mutation.cs b/examples/SimpleBlog/Models/Mutation.cs index a5827935b..37627ab56 100644 --- a/examples/SimpleBlog/Models/Mutation.cs +++ b/examples/SimpleBlog/Models/Mutation.cs @@ -11,13 +11,7 @@ public class Mutation public bool AddPost(string author, string title, string post) { var newId = FakeBlogData.Posts.Max(_ => _.Id) + 1; - var postModel = new Post - { - Id = newId, - Author = author, - Title = title, - Content = post - }; + var postModel = new Post { Id = newId, Author = author, Title = title, Content = post }; FakeBlogData.Posts.Add(postModel); return true; } @@ -27,13 +21,7 @@ public bool AddPost(string author, string title, string post) public bool Comment(int postId, string author, string comment) { var newId = FakeBlogData.Comments.Max(_ => _.Id) + 1; - var commentModel = new Comment - { - Id = newId, - PostId = postId, - Author = author, - Content = comment - }; + var commentModel = new Comment { Id = newId, PostId = postId, Author = author, Content = comment }; FakeBlogData.Comments.Add(commentModel); return true; } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9163d7389..362bf71b0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,33 +1,33 @@ - + - - GraphZen - GraphZen - GraphZen LLC - Copyright (c) 2017-2026 GraphZen LLC. All Rights Reserved. - https://github.com/GraphZen/graphzen-dotnet - https://github.com/GraphZen/graphzen-dotnet - Git - LICENSE - true - true - snupkg - true - true - True - README.md - GraphZen - + + GraphZen + GraphZen + GraphZen LLC + Copyright (c) 2017-2026 GraphZen LLC. All Rights Reserved. + https://github.com/GraphZen/graphzen-dotnet + https://github.com/GraphZen/graphzen-dotnet + Git + LICENSE + true + true + snupkg + true + true + True + README.md + GraphZen + - - - + + + - - - - + + + + - \ No newline at end of file + diff --git a/src/GraphZen.Abstractions/Infrastructure/Check.cs b/src/GraphZen.Abstractions/Infrastructure/Check.cs index fccdca7bc..6b57ede77 100644 --- a/src/GraphZen.Abstractions/Infrastructure/Check.cs +++ b/src/GraphZen.Abstractions/Infrastructure/Check.cs @@ -10,7 +10,7 @@ internal static class Check { [ContractAnnotation("value:null => halt")] [return: NotNull] - public static T NotNull([NotNull][NoEnumeration] T value, [InvokerParameterName] string parameterName) + public static T NotNull([NotNull] [NoEnumeration] T value, [InvokerParameterName] string parameterName) { if (value is null) { diff --git a/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs b/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs index d3340ebc0..c366b2e78 100644 --- a/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs +++ b/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs @@ -12,75 +12,57 @@ namespace GraphZen.LanguageModel; [GraphQLName("__DirectiveLocation")] public enum DirectiveLocation { - [Description("Location adjacent to a query operation.")] - [GraphQLName("QUERY")] + [Description("Location adjacent to a query operation.")] [GraphQLName("QUERY")] Query, - [Description("Location adjacent to a mutation operation.")] - [GraphQLName("MUTATION")] + [Description("Location adjacent to a mutation operation.")] [GraphQLName("MUTATION")] Mutation, - [Description("Location adjacent to a subscription operation.")] - [GraphQLName("SUBSCRIPTION")] + [Description("Location adjacent to a subscription operation.")] [GraphQLName("SUBSCRIPTION")] Subscription, - [Description("Location adjacent to a field.")] - [GraphQLName("FIELD")] + [Description("Location adjacent to a field.")] [GraphQLName("FIELD")] Field, - [Description("Location adjacent to a fragment definition.")] - [GraphQLName("FRAGMENT_DEFINITION")] + [Description("Location adjacent to a fragment definition.")] [GraphQLName("FRAGMENT_DEFINITION")] FragmentDefinition, - [Description("Location adjacent to a fragment spread.")] - [GraphQLName("FRAGMENT_SPREAD")] + [Description("Location adjacent to a fragment spread.")] [GraphQLName("FRAGMENT_SPREAD")] FragmentSpread, - [Description("Location adjacent to an inline fragment.")] - [GraphQLName("INLINE_FRAGMENT")] + [Description("Location adjacent to an inline fragment.")] [GraphQLName("INLINE_FRAGMENT")] InlineFragment, - [Description("Location adjacent to a schema definition.")] - [GraphQLName("SCHEMA")] + [Description("Location adjacent to a schema definition.")] [GraphQLName("SCHEMA")] Schema, - [Description("Location adjacent to a scalar definition.")] - [GraphQLName("SCALAR")] + [Description("Location adjacent to a scalar definition.")] [GraphQLName("SCALAR")] Scalar, - [Description("Location adjacent to an object type definition.")] - [GraphQLName("OBJECT")] + [Description("Location adjacent to an object type definition.")] [GraphQLName("OBJECT")] Object, - [Description("Location adjacent to a field Definition.")] - [GraphQLName("FIELD_DEFINITION")] + [Description("Location adjacent to a field Definition.")] [GraphQLName("FIELD_DEFINITION")] FieldDefinition, - [Description("Location adjacent to an argument definition.")] - [GraphQLName("ARGUMENT_DEFINITION")] + [Description("Location adjacent to an argument definition.")] [GraphQLName("ARGUMENT_DEFINITION")] ArgumentDefinition, - [Description("Location adjacent to an interface definition.")] - [GraphQLName("INTERFACE")] + [Description("Location adjacent to an interface definition.")] [GraphQLName("INTERFACE")] Interface, - [Description("Location adjacent to a union Definition.")] - [GraphQLName("UNION")] + [Description("Location adjacent to a union Definition.")] [GraphQLName("UNION")] Union, - [Description("Location adjacent to an enum definition.")] - [GraphQLName("ENUM")] + [Description("Location adjacent to an enum definition.")] [GraphQLName("ENUM")] Enum, - [Description("Location adjacent to an enum value definition.")] - [GraphQLName("ENUM_VALUE")] + [Description("Location adjacent to an enum value definition.")] [GraphQLName("ENUM_VALUE")] EnumValue, - [Description("Location adjacent to an input object type Definition.")] - [GraphQLName("INPUT_OBJECT")] + [Description("Location adjacent to an input object type Definition.")] [GraphQLName("INPUT_OBJECT")] InputObject, - [Description("Location adjacent to an input object field definition.")] - [GraphQLName("INPUT_FIELD_DEFINITION")] + [Description("Location adjacent to an input object field definition.")] [GraphQLName("INPUT_FIELD_DEFINITION")] InputFieldDefinition } diff --git a/src/GraphZen.AspNetCore.Playground/Playground/Internal/Files/playground.html b/src/GraphZen.AspNetCore.Playground/Playground/Internal/Files/playground.html index 663d9a485..74b9048e0 100644 --- a/src/GraphZen.AspNetCore.Playground/Playground/Internal/Files/playground.html +++ b/src/GraphZen.AspNetCore.Playground/Playground/Internal/Files/playground.html @@ -62,4 +62,4 @@ }); - \ No newline at end of file + diff --git a/src/GraphZen.AspNetCore.Playground/Playground/Internal/PlaygroundHtmlWriter.cs b/src/GraphZen.AspNetCore.Playground/Playground/Internal/PlaygroundHtmlWriter.cs index cd1b53f75..594a03107 100644 --- a/src/GraphZen.AspNetCore.Playground/Playground/Internal/PlaygroundHtmlWriter.cs +++ b/src/GraphZen.AspNetCore.Playground/Playground/Internal/PlaygroundHtmlWriter.cs @@ -21,10 +21,7 @@ public class PlaygroundHtmlWriter private static JsonSerializerOptions SerializerOptions { get; } = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - Converters = - { - new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) - }, + Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, WriteIndented = true }; diff --git a/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs b/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs index 5c8e2fdbe..deae0fc6e 100644 --- a/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs +++ b/src/GraphZen.AspNetCore.Server/GraphZenApplicationBuilderExtensions.cs @@ -110,10 +110,8 @@ public static IEndpointConventionBuilder MapGraphQL(this IEndpointRouteBuilder e result = await new Executor().ExecuteAsync(graphQLContext.Schema, document, rootValue, - graphQLContext, req.Variables, req.OperationName, new ExecutionOptions - { - ThrowOnError = false - }); + graphQLContext, req.Variables, req.OperationName, + new ExecutionOptions { ThrowOnError = false }); } } catch (GraphQLException gqlException) diff --git a/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs b/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs index 42b13c8a6..2b76c435d 100644 --- a/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs +++ b/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs @@ -31,7 +31,7 @@ public static void AddGraphQLContext( optionsAction != null // ReSharper disable once ConstantConditionalAccessQualifier ? (p, b) => { optionsAction?.Invoke(b); } - : (Action?)null; + : (Action?)null; var contextType = typeof(TContext); if (optionsAction != null) diff --git a/src/GraphZen.AspNetCore.Server/PlaygroundApplicationBuilderExtensions.cs b/src/GraphZen.AspNetCore.Server/PlaygroundApplicationBuilderExtensions.cs index 4d33c4deb..94e535d04 100644 --- a/src/GraphZen.AspNetCore.Server/PlaygroundApplicationBuilderExtensions.cs +++ b/src/GraphZen.AspNetCore.Server/PlaygroundApplicationBuilderExtensions.cs @@ -13,10 +13,7 @@ public static class PlaygroundApplicationBuilderExtensions [UsedImplicitly] public static void UseGraphQLPlayground(this IApplicationBuilder app) { - var shared = new SharedOptions - { - RequestPath = "" - }; + var shared = new SharedOptions { RequestPath = "" }; var defaultFileOptions = new DefaultFilesOptions(shared); // ReSharper disable once PossibleNullReferenceException defaultFileOptions.DefaultFileNames.Clear(); diff --git a/src/GraphZen.Client/Infrastructure/GraphQLRequestExtensions.cs b/src/GraphZen.Client/Infrastructure/GraphQLRequestExtensions.cs index 5a426d1f9..61294389c 100644 --- a/src/GraphZen.Client/Infrastructure/GraphQLRequestExtensions.cs +++ b/src/GraphZen.Client/Infrastructure/GraphQLRequestExtensions.cs @@ -19,11 +19,7 @@ public static HttpRequestMessage ToHttpRequest(this GraphQLRequest request) var requestJson = JsonSerializer.Serialize(request); var requestJsonContent = new StringContent(requestJson, Encoding.UTF8, "application/json"); - var message = new HttpRequestMessage - { - Method = HttpMethod.Post, - Content = requestJsonContent - }; + var message = new HttpRequestMessage { Method = HttpMethod.Post, Content = requestJsonContent }; return message; } } diff --git a/src/GraphZen.DevCli/CodeGen/CodeGenTasks.cs b/src/GraphZen.DevCli/CodeGen/CodeGenTasks.cs index f79a9d3b2..ededa0e70 100644 --- a/src/GraphZen.DevCli/CodeGen/CodeGenTasks.cs +++ b/src/GraphZen.DevCli/CodeGen/CodeGenTasks.cs @@ -48,9 +48,7 @@ namespace GraphZen.TypeSystem { var fieldAccessors = new List<(string containerType, string valueType)> { - ("InterfaceType", "Field"), - ("ObjectType", "Field"), - ("InputObjectType", "InputField") + ("InterfaceType", "Field"), ("ObjectType", "Field"), ("InputObjectType", "InputField") }; foreach (var (containerType, valueType) in fieldAccessors) @@ -66,8 +64,7 @@ namespace GraphZen.TypeSystem { var argumentDefinitionAccessors = new List<(string containerType, string valueType)> { - ("FieldDefinition", "ArgumentDefinition"), - ("DirectiveDefinition", "ArgumentDefinition") + ("FieldDefinition", "ArgumentDefinition"), ("DirectiveDefinition", "ArgumentDefinition") }; foreach (var (containerType, valueType) in argumentDefinitionAccessors) @@ -78,8 +75,7 @@ namespace GraphZen.TypeSystem { var argumentAccessors = new List<(string containerType, string valueType)> { - ("Field", "Argument"), - ("IArguments", "Argument") + ("Field", "Argument"), ("IArguments", "Argument") }; foreach (var (containerType, valueType) in argumentAccessors) diff --git a/src/GraphZen.Infrastructure/Infrastructure/Json.cs b/src/GraphZen.Infrastructure/Infrastructure/Json.cs index ff572ee79..b691eed77 100644 --- a/src/GraphZen.Infrastructure/Infrastructure/Json.cs +++ b/src/GraphZen.Infrastructure/Infrastructure/Json.cs @@ -28,10 +28,7 @@ public static class Json [DebuggerStepThrough] public static string SerializeObject(object value) { - var options = new JsonSerializerOptions(SerializerOptions) - { - WriteIndented = true - }; + var options = new JsonSerializerOptions(SerializerOptions) { WriteIndented = true }; return JsonSerializer.Serialize(value, options); } } diff --git a/src/GraphZen.LanguageModel/LanguageModel/GraphQLSyntaxVisitor.Generated.cs b/src/GraphZen.LanguageModel/LanguageModel/GraphQLSyntaxVisitor.Generated.cs index ba29cbfc4..23ce705b1 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/GraphQLSyntaxVisitor.Generated.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/GraphQLSyntaxVisitor.Generated.cs @@ -549,4 +549,4 @@ public virtual TResult LeaveOperationTypeDefinition(OperationTypeDefinitionSynta /// Called when the visitor leaves a node. public virtual TResult LeaveVariable(VariableSyntax node) => OnLeave(node); -} \ No newline at end of file +} diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs index 9e944f524..8cd773a19 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs @@ -12,17 +12,17 @@ internal static partial class Grammar /// private static TokenListParser DirectiveDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from directive in Keyword("directive")! - from at in AtSymbol! - from name in Name! - from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() - from @on in Keyword("on")! - from locations in DirectiveLocations! - select new DirectiveDefinitionSyntax(name!, locations!, desc, args, - SyntaxLocation.FromMany(desc, directive, at, name!, - args?.GetLocation() - , @on, - locations!.GetLocation()))) + from directive in Keyword("directive")! + from at in AtSymbol! + from name in Name! + from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() + from @on in Keyword("on")! + from locations in DirectiveLocations! + select new DirectiveDefinitionSyntax(name!, locations!, desc, args, + SyntaxLocation.FromMany(desc, directive, at, name!, + args?.GetLocation() + , @on, + locations!.GetLocation()))) .Try() .Named("directive definition"); @@ -31,8 +31,8 @@ from locations in DirectiveLocations! /// private static TokenListParser DirectiveLocations { get; } = (from pipe in Parse.Ref(() => Pipe!).AsNullable().OptionalOrDefault() - from locations in DirectiveLocation!.ManyDelimitedBy(Pipe!) - select locations) + from locations in DirectiveLocation!.ManyDelimitedBy(Pipe!) + select locations) .Try() .Named("directive locations"); diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs index 242382e4d..c51e9ae75 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs @@ -18,9 +18,9 @@ internal static partial class Grammar /// internal static TokenListParser Directive { get; } = (from at in Parse.Ref(() => AtSymbol!.Named("directive symbol")) - from name in Name!.Named("directive name") - from args in Arguments!.AsNullable().OptionalOrDefault().Named("directive arguments") - select new DirectiveSyntax(name!, args, - SyntaxLocation.FromMany(at, name!, args.GetLocation()))).Try() + from name in Name!.Named("directive name") + from args in Arguments!.AsNullable().OptionalOrDefault().Named("directive arguments") + select new DirectiveSyntax(name!, args, + SyntaxLocation.FromMany(at, name!, args.GetLocation()))).Try() .Named("directive"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs index 2f0a1ff01..a85b17ab0 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs @@ -13,10 +13,10 @@ internal static partial class Grammar /// internal static TokenListParser Document { get; } = (from leadingComments in Parse.Ref(() => Comment!.Many()) - from definitions in Parse.Ref(() => Definition!).Many() - from trailingComments in Comment!.Many() - select new DocumentSyntax(definitions, - definitions.GetLocation().Location)) + from definitions in Parse.Ref(() => Definition!).Many() + from trailingComments in Comment!.Many() + select new DocumentSyntax(definitions, + definitions.GetLocation().Location)) .Named("document"); /// @@ -24,11 +24,11 @@ from definitions in Parse.Ref(() => Definition!).Many() /// private static TokenListParser Definition { get; } = (from leadingComments in Parse.Ref(() => Comment!.Many()) - from def in ExecutableDefinition!.Select(_ => (DefinitionSyntax)_) - .Or(TypeSystemDefinition!.Select(_ => (DefinitionSyntax)_)) - .Or(TypeSystemExtension!.Select(_ => (DefinitionSyntax)_)) - from trailingComments in Comment!.Many() - select def) + from def in ExecutableDefinition!.Select(_ => (DefinitionSyntax)_) + .Or(TypeSystemDefinition!.Select(_ => (DefinitionSyntax)_)) + .Or(TypeSystemExtension!.Select(_ => (DefinitionSyntax)_)) + from trailingComments in Comment!.Many() + select def) .Named("definition"); /// diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs index 889733ba1..093c4c366 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser EnumTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from @enum in Keyword("enum")! - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from values in EnumValuesDefinition!.AsNullable().OptionalOrDefault() - select new EnumTypeDefinitionSyntax(name!, desc, directives, values, - SyntaxLocation.FromMany(desc, @enum, name!, directives.GetLocation(), values.GetLocation()))) + from @enum in Keyword("enum")! + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from values in EnumValuesDefinition!.AsNullable().OptionalOrDefault() + select new EnumTypeDefinitionSyntax(name!, desc, directives, values, + SyntaxLocation.FromMany(desc, @enum, name!, directives.GetLocation(), values.GetLocation()))) .Named("enum type definition"); /// @@ -25,9 +25,9 @@ from directives in Directives.AsNullable().OptionalOrDefault() /// private static TokenListParser EnumValuesDefinition { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from values in EnumValueDefinition!.Many() - from rb in RightBrace! - select values) + from values in EnumValueDefinition!.Many() + from rb in RightBrace! + select values) .Try() .Named("enum values"); @@ -36,10 +36,10 @@ from rb in RightBrace! /// private static TokenListParser EnumValueDefinition { get; } = (from desc in Parse.Ref(() => Description!.AsNullable().OptionalOrDefault()) - from value in EnumValue! - from directives in Directives.AsNullable().OptionalOrDefault() - select new EnumValueDefinitionSyntax(value!, desc, directives, - SyntaxLocation.FromMany(desc, value!, directives.GetLocation()))) + from value in EnumValue! + from directives in Directives.AsNullable().OptionalOrDefault() + select new EnumValueDefinitionSyntax(value!, desc, directives, + SyntaxLocation.FromMany(desc, value!, directives.GetLocation()))) .Try() .Named("enum value"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs index fe79e0ef8..5ad529cee 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs @@ -13,18 +13,18 @@ internal static partial class Grammar /// private static TokenListParser EnumTypeExtension { get; } = (from extend in Keyword("extend") - from @enum in Keyword("enum")! - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from values in EnumValuesDefinition - select new EnumTypeExtensionSyntax(name!, directives, values!, - SyntaxLocation.FromMany(extend, name!, directives.GetLocation(), values!.GetLocation()))).Try() + from @enum in Keyword("enum")! + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from values in EnumValuesDefinition + select new EnumTypeExtensionSyntax(name!, directives, values!, + SyntaxLocation.FromMany(extend, name!, directives.GetLocation(), values!.GetLocation()))).Try() .Or((from extend in Keyword("extend") - from @enum in Keyword("enum")! - from name in Name! - from directives in Directives - select new EnumTypeExtensionSyntax(name!, directives!, null!, - SyntaxLocation.FromMany(extend, name!, directives!.GetLocation()))).Try()) + from @enum in Keyword("enum")! + from name in Name! + from directives in Directives + select new EnumTypeExtensionSyntax(name!, directives!, null!, + SyntaxLocation.FromMany(extend, name!, directives!.GetLocation()))).Try()) .Try() .Named("enum type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs index cef58952b..6054132c7 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs @@ -10,24 +10,24 @@ internal static partial class Grammar { internal static TokenListParser Field { get; } = (from firstName in Parse.Ref(() => Name!.AsNullable().OptionalOrDefault()) - from aliasedName in (from colon in Colon - from aliasedName in Name! - select aliasedName).AsNullable().OptionalOrDefault() - from arguments in Arguments!.AsNullable().OptionalOrDefault().Named("field arguments") - from directives in Directives.AsNullable().OptionalOrDefault().Named("field directives") - from selectionSet in SelectionSet!.AsNullable().OptionalOrDefault().Named("field selections") - let alias = aliasedName != null ? firstName : null - let name = aliasedName ?? firstName - where firstName != null - select new FieldSyntax(name!, - alias, - arguments, - directives, - selectionSet, - SyntaxLocation.FromMany(alias!, name!, arguments?.GetLocation(), - selectionSet, - directives?.GetLocation() - ))) + from aliasedName in (from colon in Colon + from aliasedName in Name! + select aliasedName).AsNullable().OptionalOrDefault() + from arguments in Arguments!.AsNullable().OptionalOrDefault().Named("field arguments") + from directives in Directives.AsNullable().OptionalOrDefault().Named("field directives") + from selectionSet in SelectionSet!.AsNullable().OptionalOrDefault().Named("field selections") + let alias = aliasedName != null ? firstName : null + let name = aliasedName ?? firstName + where firstName != null + select new FieldSyntax(name!, + alias, + arguments, + directives, + selectionSet, + SyntaxLocation.FromMany(alias!, name!, arguments?.GetLocation(), + selectionSet, + directives?.GetLocation() + ))) .Try() .Named("field"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs index 5e744a27e..241d55773 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs @@ -10,43 +10,43 @@ internal static partial class Grammar { private static TokenListParser TypeCondition { get; } = (from @on in Keyword("on") - from type in NamedType! - select type!) + from type in NamedType! + select type!) .Try() .Named("type condition"); private static TokenListParser FragmentName { get; } = (from name in Parse.Ref(() => Name!) - where !name.Value.Equals("on", StringComparison.OrdinalIgnoreCase) - select name) + where !name.Value.Equals("on", StringComparison.OrdinalIgnoreCase) + select name) .Try() .Named("fragment name"); internal static TokenListParser FragmentSpread { get; } = (from spread in Parse.Ref(() => Spread!) - from name in FragmentName.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - where name != null - select new FragmentSpreadSyntax(name, directives, - SyntaxLocation.FromMany(spread, name, directives.GetLocation()))) + from name in FragmentName.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + where name != null + select new FragmentSpreadSyntax(name, directives, + SyntaxLocation.FromMany(spread, name, directives.GetLocation()))) .Try() .Named("fragment spread"); internal static TokenListParser InlineFragment => (from spread in Spread - from typeCondition in TypeCondition.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from selectionSet in SelectionSet - select new InlineFragmentSyntax(selectionSet!, typeCondition, directives, - new SyntaxLocation(spread, selectionSet!))).Named("inline fragment"); + from typeCondition in TypeCondition.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from selectionSet in SelectionSet + select new InlineFragmentSyntax(selectionSet!, typeCondition, directives, + new SyntaxLocation(spread, selectionSet!))).Named("inline fragment"); internal static TokenListParser FragmentDefinition => (from fragment in Keyword("fragment") - from fragmentName in FragmentName - from type in TypeCondition.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from selectionSet in SelectionSet - select new FragmentDefinitionSyntax(fragmentName!, type, selectionSet!, directives, - new SyntaxLocation(fragment, selectionSet!))).Named("fragment definition"); + from fragmentName in FragmentName + from type in TypeCondition.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from selectionSet in SelectionSet + select new FragmentDefinitionSyntax(fragmentName!, type, selectionSet!, directives, + new SyntaxLocation(fragment, selectionSet!))).Named("fragment definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs index 926808acd..4f328130b 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs @@ -12,10 +12,10 @@ internal static partial class Grammar /// internal static TokenListParser Argument { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from name in Parse.Ref(() => Name!.Named("argument name")) - from colon in Colon! - from value in Value!.Named("argument value") - select new ArgumentSyntax(name!, desc, value, SyntaxLocation.FromMany(name!, value))).Try() + from name in Parse.Ref(() => Name!.Named("argument name")) + from colon in Colon! + from value in Value!.Named("argument value") + select new ArgumentSyntax(name!, desc, value, SyntaxLocation.FromMany(name!, value))).Try() .Named("argument"); /// @@ -23,8 +23,8 @@ from colon in Colon! /// internal static TokenListParser Arguments { get; } = (from lp in Parse.Ref(() => LeftParen!) - from args in Argument!.Many() - from rp in RightParen! - select args).Try() + from args in Argument!.Many() + from rp in RightParen! + select args).Try() .Named("arguments"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs index 30277cca7..709fd59de 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs @@ -12,19 +12,19 @@ internal static partial class Grammar /// private static TokenListParser InputObjectTypeExtension { get; } = (from extend in Keyword("extend") - from input in Keyword("input") - from name in Parse.Ref(() => Name!) - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in InputFieldsDefinition! - select new InputObjectTypeExtensionSyntax(name!, directives, fields!, - SyntaxLocation.FromMany(extend, fields!.GetLocation()))) + from input in Keyword("input") + from name in Parse.Ref(() => Name!) + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in InputFieldsDefinition! + select new InputObjectTypeExtensionSyntax(name!, directives, fields!, + SyntaxLocation.FromMany(extend, fields!.GetLocation()))) .Try().Or ((from extend in Keyword("extend") - from input in Keyword("input") - from name in Parse.Ref(() => Name!) - from directives in Directives - select new InputObjectTypeExtensionSyntax(name!, directives!, null, - SyntaxLocation.FromMany(extend, directives!.GetLocation()))) + from input in Keyword("input") + from name in Parse.Ref(() => Name!) + from directives in Directives + select new InputObjectTypeExtensionSyntax(name!, directives!, null, + SyntaxLocation.FromMany(extend, directives!.GetLocation()))) .Try()) .Named("input object type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs index dc3f4f02e..9c85aef38 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser InputObjectTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from input in Keyword("input")! - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in InputFieldsDefinition!.AsNullable().OptionalOrDefault() - select new InputObjectTypeDefinitionSyntax(name!, desc, directives, fields, - SyntaxLocation.FromMany(desc, input, name!, directives.GetLocation(), fields.GetLocation()))) + from input in Keyword("input")! + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in InputFieldsDefinition!.AsNullable().OptionalOrDefault() + select new InputObjectTypeDefinitionSyntax(name!, desc, directives, fields, + SyntaxLocation.FromMany(desc, input, name!, directives.GetLocation(), fields.GetLocation()))) .Named("input object type definition"); /// @@ -25,9 +25,9 @@ from directives in Directives.AsNullable().OptionalOrDefault() /// private static TokenListParser InputFieldsDefinition { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from values in InputValueDefinition!.Many() - from rb in RightBrace! - select values) + from values in InputValueDefinition!.Many() + from rb in RightBrace! + select values) .Try() .Named("input fields definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs index 9296a867a..4abb5de0a 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs @@ -9,14 +9,14 @@ internal static partial class Grammar { private static TokenListParser NamedType { get; } = (from name in Parse.Ref(() => Name!) - select new NamedTypeSyntax(name, name.Location)) + select new NamedTypeSyntax(name, name.Location)) .Named("named type"); private static TokenListParser ListType { get; } = (from leftBracket in Parse.Ref(() => LeftBracket!) - from type in Type! - from rightBracket in RightBracket! - select new ListTypeSyntax(type!, new SyntaxLocation(leftBracket, rightBracket))) + from type in Type! + from rightBracket in RightBracket! + select new ListTypeSyntax(type!, new SyntaxLocation(leftBracket, rightBracket))) .Try() .Named("list type"); @@ -24,10 +24,10 @@ from rightBracket in RightBracket! (from type in ListType .Select(n => (NullableTypeSyntax)n) .Or(NamedType.Select(n => (NullableTypeSyntax)n)) - from bang in Bang!.AsNullable().OptionalOrDefault() - select bang == null - ? type! - : new NonNullTypeSyntax(type!, SyntaxLocation.FromMany(type!, bang)) as TypeSyntax) + from bang in Bang!.AsNullable().OptionalOrDefault() + select bang == null + ? type! + : new NonNullTypeSyntax(type!, SyntaxLocation.FromMany(type!, bang)) as TypeSyntax) .Try() .Named("type"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs index d4d4ac6c9..5fbd2e9fb 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs @@ -11,7 +11,7 @@ internal static partial class Grammar { private static TokenListParser NullValue { get; } = (from @null in Keyword("null") - select SyntaxFactory.NullValue()) + select SyntaxFactory.NullValue()) .Try() .Named("null value"); @@ -20,33 +20,33 @@ select SyntaxFactory.NullValue()) /// private static TokenListParser EnumValue { get; } = (from name in Parse.Ref(() => Name!) - where EnumValueSyntax.IsValidValue(name.Value) - select new EnumValueSyntax(name)) + where EnumValueSyntax.IsValidValue(name.Value) + select new EnumValueSyntax(name)) .Try() .Named("enum value"); private static TokenListParser ListValue { get; } = (from leftBracket in Parse.Ref(() => LeftBracket!) - from values in Value!.Many() - from rightBracket in RightBracket! - select new ListValueSyntax(values!, new SyntaxLocation(leftBracket, rightBracket))) + from values in Value!.Many() + from rightBracket in RightBracket! + select new ListValueSyntax(values!, new SyntaxLocation(leftBracket, rightBracket))) .Try() .Named("list value"); private static TokenListParser ObjectField { get; } = (from n in Parse.Ref(() => Name!) - from c in Colon! - from v in Value! - select SyntaxFactory.ObjectField(n, v!)) + from c in Colon! + from v in Value! + select SyntaxFactory.ObjectField(n, v!)) .Try() .Named("object field"); private static TokenListParser ObjectValue { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from fields in ObjectField!.Many() - from rb in RightBrace! - select new ObjectValueSyntax(fields!, new SyntaxLocation(lb, rb))) + from fields in ObjectField!.Many() + from rb in RightBrace! + select new ObjectValueSyntax(fields!, new SyntaxLocation(lb, rb))) .Try().Named("object value"); private static TokenListParser IntValue { get; } = diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs index 9c62a5781..6e7bb9606 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs @@ -12,11 +12,11 @@ internal static partial class Grammar /// private static TokenListParser InterfaceTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!.AsNullable().OptionalOrDefault()) - from @interface in Keyword("interface") - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() - select new InterfaceTypeDefinitionSyntax(name!, desc, directives, fields, - SyntaxLocation.FromMany(desc, @interface, name!, directives.GetLocation(), fields.GetLocation()))) + from @interface in Keyword("interface") + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() + select new InterfaceTypeDefinitionSyntax(name!, desc, directives, fields, + SyntaxLocation.FromMany(desc, @interface, name!, directives.GetLocation(), fields.GetLocation()))) .Named("interface"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs index b24dbab2b..f4aeff56d 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser InterfaceTypeExtension { get; } = (from extend in Keyword("extend") - from iface in Keyword("interface") - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition! - select new InterfaceTypeExtensionSyntax(name!, directives, fields!, - SyntaxLocation.FromMany(extend, fields!.GetLocation()))).Try().Or( + from iface in Keyword("interface") + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition! + select new InterfaceTypeExtensionSyntax(name!, directives, fields!, + SyntaxLocation.FromMany(extend, fields!.GetLocation()))).Try().Or( from extend in Keyword("extend") from iface in Keyword("interface") from name in Name! diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs index b2b7d1492..e868b37de 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs @@ -12,26 +12,26 @@ internal static partial class Grammar /// private static TokenListParser ObjectTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from type in Keyword("type") - from typeName in Name - from interfaces in ImplementsIntefaces!.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() - select new ObjectTypeDefinitionSyntax(typeName!, - desc, - interfaces, directives, fields, - SyntaxLocation.FromMany(desc, type, typeName!, interfaces?.GetLocation(), - directives?.GetLocation(), - fields?.GetLocation()))).Named("object type definition"); + from type in Keyword("type") + from typeName in Name + from interfaces in ImplementsIntefaces!.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() + select new ObjectTypeDefinitionSyntax(typeName!, + desc, + interfaces, directives, fields, + SyntaxLocation.FromMany(desc, type, typeName!, interfaces?.GetLocation(), + directives?.GetLocation(), + fields?.GetLocation()))).Named("object type definition"); /// /// http://facebook.github.io/graphql/June2018/#ImplementsInterfaces /// private static TokenListParser ImplementsIntefaces { get; } = (from impl in Keyword("implements") - from amp in Ampersand.Optional() - from ifaces in NamedType.Select(nt => nt).ManyDelimitedBy(Ampersand.OptionalOrDefault()) - select ifaces!) + from amp in Ampersand.Optional() + from ifaces in NamedType.Select(nt => nt).ManyDelimitedBy(Ampersand.OptionalOrDefault()) + select ifaces!) .Named("implements interfaces"); /// @@ -39,9 +39,9 @@ from ifaces in NamedType.Select(nt => nt).ManyDelimitedBy(Ampersand.OptionalOrDe /// private static TokenListParser FieldsDefinition { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from defs in FieldDefinition!.Many() - from rb in RightBrace - select defs) + from defs in FieldDefinition!.Many() + from rb in RightBrace + select defs) .Try() .Named("fields definition"); @@ -51,35 +51,35 @@ from rb in RightBrace /// private static TokenListParser FieldDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from name in Name - from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() - from c in Colon - from type in Type - from directives in Directives.AsNullable().OptionalOrDefault() - select new FieldDefinitionSyntax(name!, type!, desc, args, directives, - SyntaxLocation.FromMany(desc, name!, args?.GetLocation(), c, type!))) + from name in Name + from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() + from c in Colon + from type in Type + from directives in Directives.AsNullable().OptionalOrDefault() + select new FieldDefinitionSyntax(name!, type!, desc, args, directives, + SyntaxLocation.FromMany(desc, name!, args?.GetLocation(), c, type!))) .Try() .Named("field definition"); private static TokenListParser ArgumentsDefinition { get; } = (from lp in Parse.Ref(() => LeftParen!) - from defs in InputValueDefinition!.Many() - from rp in RightParen - select defs) + from defs in InputValueDefinition!.Many() + from rp in RightParen + select defs) .Try() .Named("arguments definition"); private static TokenListParser InputValueDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from name in Name - from c in Colon - from type in Type - from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - select new InputValueDefinitionSyntax(name!, type!, desc, defaultValue, directives, - SyntaxLocation.FromMany( - desc, name!, type!, defaultValue, directives?.GetLocation()))) + from name in Name + from c in Colon + from type in Type + from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + select new InputValueDefinitionSyntax(name!, type!, desc, defaultValue, directives, + SyntaxLocation.FromMany( + desc, name!, type!, defaultValue, directives?.GetLocation()))) .Try() .Named("input value definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs index b0a07549f..6a449564b 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs @@ -9,30 +9,30 @@ internal static partial class Grammar { private static TokenListParser ObjectTypeExtension { get; } = (from extend in Keyword("extend") - from type in Keyword("type") - from name in Name - from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition - select new ObjectTypeExtensionSyntax(name!, ifaces, directives, fields!, - SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation(), - fields?.GetLocation()))).Try() + from type in Keyword("type") + from name in Name + from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition + select new ObjectTypeExtensionSyntax(name!, ifaces, directives, fields!, + SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation(), + fields?.GetLocation()))).Try() .Or( (from extend in Keyword("extend") - from type in Keyword("type") - from name in Name - from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() - from directives in Directives - select new ObjectTypeExtensionSyntax(name!, ifaces, directives!, null, - SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation()))) + from type in Keyword("type") + from name in Name + from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() + from directives in Directives + select new ObjectTypeExtensionSyntax(name!, ifaces, directives!, null, + SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation()))) .Try() ).Or( (from extend in Keyword("extend") - from type in Keyword("type") - from name in Name - from ifaces in ImplementsIntefaces - select new ObjectTypeExtensionSyntax(name!, ifaces!, null, null, - SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation()))).Try() + from type in Keyword("type") + from name in Name + from ifaces in ImplementsIntefaces + select new ObjectTypeExtensionSyntax(name!, ifaces!, null, null, + SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation()))).Try() ) .Named("object type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs index a97a0f1b3..b58d71e71 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs @@ -24,22 +24,22 @@ from selectionSet in SelectionSet! private static TokenListParser OperationType { get; } = (from name in Token.EqualTo(TokenKind.Name).Named("operation type") - let nameValue = name.ToStringValue() - let isQuery = nameValue?.Equals("query", StringComparison.OrdinalIgnoreCase) ?? false - let isMutation = nameValue?.Equals("mutation", StringComparison.OrdinalIgnoreCase) ?? false - let isSubscription = nameValue?.Equals("subscription", StringComparison.OrdinalIgnoreCase) ?? false - where isQuery || isMutation || isSubscription - let type = isQuery - ? LanguageModel.OperationType.Query - : isMutation - ? LanguageModel.OperationType.Mutation - : LanguageModel.OperationType.Subscription - select (type, name.Span.ToLocation())) + let nameValue = name.ToStringValue() + let isQuery = nameValue?.Equals("query", StringComparison.OrdinalIgnoreCase) ?? false + let isMutation = nameValue?.Equals("mutation", StringComparison.OrdinalIgnoreCase) ?? false + let isSubscription = nameValue?.Equals("subscription", StringComparison.OrdinalIgnoreCase) ?? false + where isQuery || isMutation || isSubscription + let type = isQuery + ? LanguageModel.OperationType.Query + : isMutation + ? LanguageModel.OperationType.Mutation + : LanguageModel.OperationType.Subscription + select (type, name.Span.ToLocation())) .Named("operation type"); private static TokenListParser QueryShorthandOpeartion { get; } = (from selectionSet in Parse.Ref(() => SelectionSet!) - select new OperationDefinitionSyntax(LanguageModel.OperationType.Query, selectionSet, - location: selectionSet.Location)) + select new OperationDefinitionSyntax(LanguageModel.OperationType.Query, selectionSet, + location: selectionSet.Location)) .Named("query shortand operation"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs index b97e5cba1..3a2d38b5d 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs @@ -12,11 +12,11 @@ internal static partial class Grammar /// private static TokenListParser ScalarTypeExtension { get; } = (from extend in Keyword("extend") - from scalar in Keyword("scalar") - from name in Parse.Ref(() => Name!) - from directives in Directives - select new ScalarTypeExtensionSyntax(name!, directives!, - SyntaxLocation.FromMany(extend, directives!.GetLocation()))) + from scalar in Keyword("scalar") + from name in Parse.Ref(() => Name!) + from directives in Directives + select new ScalarTypeExtensionSyntax(name!, directives!, + SyntaxLocation.FromMany(extend, directives!.GetLocation()))) .Try() .Named("scalar type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs index 4e6bb4e5c..b8650ece4 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs @@ -9,11 +9,11 @@ internal static partial class Grammar { private static TokenListParser ScalarTypeDefinitionSyntax { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from scalar in Keyword("scalar") - from name in Name - from directives in Directives.AsNullable().OptionalOrDefault() - select new ScalarTypeDefinitionSyntax(name!, desc, directives, - SyntaxLocation.FromMany(desc, scalar, name!, directives.GetLocation()))) + from scalar in Keyword("scalar") + from name in Name + from directives in Directives.AsNullable().OptionalOrDefault() + select new ScalarTypeDefinitionSyntax(name!, desc, directives, + SyntaxLocation.FromMany(desc, scalar, name!, directives.GetLocation()))) .Try() .Named("scalar type"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs index 6425a79d5..9c416a8f5 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser SchemaExtension { get; } = (from extend in Keyword("extend") - from schema in Keyword("schema") - from directives in Directives.AsNullable().OptionalOrDefault() - from lb in Parse.Ref(() => LeftBrace!) - from defs in OperationTypeDefinition!.Many() - from rb in RightBrace - select new SchemaExtensionSyntax(directives, defs!, SyntaxLocation.FromMany(extend, rb))).Try().Or( + from schema in Keyword("schema") + from directives in Directives.AsNullable().OptionalOrDefault() + from lb in Parse.Ref(() => LeftBrace!) + from defs in OperationTypeDefinition!.Many() + from rb in RightBrace + select new SchemaExtensionSyntax(directives, defs!, SyntaxLocation.FromMany(extend, rb))).Try().Or( from extend in Keyword("extend") from schema in Keyword("schema") from directives in Directives diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs index 4b691b840..d24366732 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs @@ -9,20 +9,20 @@ internal static partial class Grammar { private static TokenListParser SchemaDefinition { get; } = (from schema in Keyword("schema") - from directives in Directives.AsNullable().OptionalOrDefault() - from leftBrace in Parse.Ref(() => LeftBrace!) - from operationTypeDefinitionNodes in OperationTypeDefinition!.Many() - from rightBrace in RightBrace - select new SchemaDefinitionSyntax(operationTypeDefinitionNodes!, directives, - SyntaxLocation.FromMany(schema, rightBrace))).Try().Named("schema definition"); + from directives in Directives.AsNullable().OptionalOrDefault() + from leftBrace in Parse.Ref(() => LeftBrace!) + from operationTypeDefinitionNodes in OperationTypeDefinition!.Many() + from rightBrace in RightBrace + select new SchemaDefinitionSyntax(operationTypeDefinitionNodes!, directives, + SyntaxLocation.FromMany(schema, rightBrace))).Try().Named("schema definition"); private static TokenListParser OperationTypeDefinition { get; } = (from opType in Parse.Ref(() => OperationType!) - from colon in Colon - from type in NamedType - select new OperationTypeDefinitionSyntax(opType.type, - type!, - SyntaxLocation.FromMany(opType.location, type!.Location))) + from colon in Colon + from type in NamedType + select new OperationTypeDefinitionSyntax(opType.type, + type!, + SyntaxLocation.FromMany(opType.location, type!.Location))) .Try() .Named("operation type definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs index c4b2f5714..253894b21 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs @@ -12,10 +12,10 @@ internal static partial class Grammar /// internal static TokenListParser SelectionSet { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from selections in Selection! - .AtLeastOnce() - from rb in RightBrace - select new SelectionSetSyntax(selections, new SyntaxLocation(lb, rb))) + from selections in Selection! + .AtLeastOnce() + from rb in RightBrace + select new SelectionSetSyntax(selections, new SyntaxLocation(lb, rb))) .Named("selection set"); diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs index b924a401f..3135da22e 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs @@ -9,12 +9,12 @@ internal static partial class Grammar { private static TokenListParser UnionTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from union in Keyword("union") - from name in Name - from directives in Directives.AsNullable().OptionalOrDefault() - from types in UnionMemberTypes!.AsNullable().OptionalOrDefault() - select new UnionTypeDefinitionSyntax(name!, desc, directives, types, - SyntaxLocation.FromMany(desc, union, name!, directives?.GetLocation(), types?.GetLocation()))) + from union in Keyword("union") + from name in Name + from directives in Directives.AsNullable().OptionalOrDefault() + from types in UnionMemberTypes!.AsNullable().OptionalOrDefault() + select new UnionTypeDefinitionSyntax(name!, desc, directives, types, + SyntaxLocation.FromMany(desc, union, name!, directives?.GetLocation(), types?.GetLocation()))) .Named("union type definition"); /// diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs index 9de0e0b6b..7053c91b2 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs @@ -12,11 +12,11 @@ internal static partial class Grammar /// private static TokenListParser UnionTypeExtension { get; } = (from extend in Keyword("extend") - from union in Keyword("union") - from name in Parse.Ref(() => Name!) - from directives in Directives - select new UnionTypeExtensionSyntax(name!, directives!, null, - SyntaxLocation.FromMany(extend, directives!.GetLocation()))) + from union in Keyword("union") + from name in Parse.Ref(() => Name!) + from directives in Directives + select new UnionTypeExtensionSyntax(name!, directives!, null, + SyntaxLocation.FromMany(extend, directives!.GetLocation()))) .Select(_ => { return _; }) .Try() .Or(from extend in Keyword("extend") diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs index a3bf9cd14..485a05962 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs @@ -12,9 +12,9 @@ internal static partial class Grammar /// private static TokenListParser VariableDefinitions { get; } = (from lp in Parse.Ref(() => LeftParen!) - from variableDefinitionNodes in VariableDefinition!.Many() - from rp in RightParen - select variableDefinitionNodes) + from variableDefinitionNodes in VariableDefinition!.Many() + from rp in RightParen + select variableDefinitionNodes) .Named("variable definitions"); /// @@ -22,10 +22,10 @@ from rp in RightParen /// internal static TokenListParser VariableDefinition { get; } = (from v in Parse.Ref(() => Variable!) - from c in Colon - from t in Type - from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() - select new VariableDefinitionSyntax(v, t!, defaultValue, SyntaxLocation.FromMany(v, c, t!, defaultValue))) + from c in Colon + from t in Type + from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() + select new VariableDefinitionSyntax(v, t!, defaultValue, SyntaxLocation.FromMany(v, c, t!, defaultValue))) .Named("variable definition"); /// @@ -33,8 +33,8 @@ from t in Type /// internal static TokenListParser Variable { get; } = (from d in Parse.Ref(() => DollarSign!) - from n in Name!.Named("variable name") - select new VariableSyntax(n, new SyntaxLocation(d, n))) + from n in Name!.Named("variable name") + select new VariableSyntax(n, new SyntaxLocation(d, n))) .Named("variable"); /// @@ -42,7 +42,7 @@ from t in Type /// private static TokenListParser DefaultValue { get; } = (from assignment in Parse.Ref(() => Assignment!).Named("assignment") - from value in Value!.Named("default value") - select value!) + from value in Value!.Named("default value") + select value!) .Named("default value"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs index 0f53eb8d3..2b0ebd4fa 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs @@ -519,8 +519,9 @@ public void Join(IReadOnlyList nodes, Action? seperatorAction = null private void Join(IReadOnlyList nodes, string? seperator = null) { - Join(nodes, seperator != null ? () => { Append(seperator); } - : null); + Join(nodes, seperator != null + ? () => { Append(seperator); } + : null); } #endregion diff --git a/src/GraphZen.LanguageModel/LanguageModel/Syntax/SyntaxNode.Generated.cs b/src/GraphZen.LanguageModel/LanguageModel/Syntax/SyntaxNode.Generated.cs index 325505f69..c75502ca1 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Syntax/SyntaxNode.Generated.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Syntax/SyntaxNode.Generated.cs @@ -1380,4 +1380,4 @@ public override TResult VisitEnter(GraphQLSyntaxVisitor visito /// Called when a leaves a node. public override TResult VisitLeave(GraphQLSyntaxVisitor visitor) => visitor.LeaveVariable(this); -} \ No newline at end of file +} diff --git a/src/GraphZen.LanguageModel/LanguageModel/Validation/DocumentValidationRules.cs b/src/GraphZen.LanguageModel/LanguageModel/Validation/DocumentValidationRules.cs index 37ffe7b4b..a02aa0f77 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Validation/DocumentValidationRules.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Validation/DocumentValidationRules.cs @@ -76,18 +76,11 @@ public static class DocumentValidationRules SpecifiedSdlRules.Concat( new[] { - SchemaMustHaveRootObjectTypes, - FieldArgsMustBeProperlyNamed, - UnionTypesMustBeValid, - InputObjectsMustHaveFields, - EnumTypesMustBeWellDefined, - ObjectFieldsMustHaveOutputTypes, - ObjectsCanOnlyImplementUniqueInterfaces, - InterfaceExtensionsShouldBeValid, - InterfaceFieldsMustHaveOutputTypes, - FieldArgumentsMustHaveInputTypes, - ObjectsMustAdhereToInterfaceTheyImplement, - ObjectsMustHaveFields, + SchemaMustHaveRootObjectTypes, FieldArgsMustBeProperlyNamed, UnionTypesMustBeValid, + InputObjectsMustHaveFields, EnumTypesMustBeWellDefined, ObjectFieldsMustHaveOutputTypes, + ObjectsCanOnlyImplementUniqueInterfaces, InterfaceExtensionsShouldBeValid, + InterfaceFieldsMustHaveOutputTypes, FieldArgumentsMustHaveInputTypes, + ObjectsMustAdhereToInterfaceTheyImplement, ObjectsMustHaveFields, InputObjectFieldsMustHaveInputTypes }).ToList(); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Validation/Rules/ObjectsMustHaveFields.cs b/src/GraphZen.LanguageModel/LanguageModel/Validation/Rules/ObjectsMustHaveFields.cs index f778b8c5d..ad95f791e 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Validation/Rules/ObjectsMustHaveFields.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Validation/Rules/ObjectsMustHaveFields.cs @@ -44,10 +44,7 @@ public override VisitAction LeaveDocument(DocumentSyntax node) return n.Fields; }).Any()) { - var nodes = new List - { - objectTypeNode.Name - }; + var nodes = new List { objectTypeNode.Name }; // ReSharper disable once PossibleNullReferenceException nodes.AddRange(extensionNodes.Select(_ => _.Name)); ReportError($"Type {objectTypeName} must define one or more fields.", nodes); diff --git a/src/GraphZen.QueryEngine/QueryEngine/Validation/QueryValidationRules.cs b/src/GraphZen.QueryEngine/QueryEngine/Validation/QueryValidationRules.cs index 4671cf889..53eca5b4b 100644 --- a/src/GraphZen.QueryEngine/QueryEngine/Validation/QueryValidationRules.cs +++ b/src/GraphZen.QueryEngine/QueryEngine/Validation/QueryValidationRules.cs @@ -114,31 +114,11 @@ public static class QueryValidationRules public static IReadOnlyList SpecifiedQueryRules { get; } = new[] { - ExecutableDefinitions, - UniqueOperationNames, - LoneAnonymousOperation, - SingleFieldSubscriptions, - KnownTypeNames, - FragmentsOnCompositeTypes, - VariablesAreInputTypes, - ScalarLeafs, - FieldsOnCorrectType, - UniqueFragmentNames, - KnownFragmentNames, - NoUnusedFragments, - PossibleFragmentSpreads, - NoFragmentCycles, - UniqueVariableNames, - NoUndefinedVariables, - NoUnusedVariables, - KnownDirectives, - UniqueDirectivesPerLocation, - KnownArgumentNames, - UniqueArgumentNames, - ValuesOfCorrectType, - ProvidedRequiredArguments, - VariablesInAllowedPosition, - OverlappingFieldsCanBeMerged, - UniqueInputFieldNames + ExecutableDefinitions, UniqueOperationNames, LoneAnonymousOperation, SingleFieldSubscriptions, + KnownTypeNames, FragmentsOnCompositeTypes, VariablesAreInputTypes, ScalarLeafs, FieldsOnCorrectType, + UniqueFragmentNames, KnownFragmentNames, NoUnusedFragments, PossibleFragmentSpreads, NoFragmentCycles, + UniqueVariableNames, NoUndefinedVariables, NoUnusedVariables, KnownDirectives, UniqueDirectivesPerLocation, + KnownArgumentNames, UniqueArgumentNames, ValuesOfCorrectType, ProvidedRequiredArguments, + VariablesInAllowedPosition, OverlappingFieldsCanBeMerged, UniqueInputFieldNames }; } diff --git a/src/GraphZen.TypeSystem/TypeSystem/Introspection.cs b/src/GraphZen.TypeSystem/TypeSystem/Introspection.cs index 4a35d5e56..9ac90d09b 100644 --- a/src/GraphZen.TypeSystem/TypeSystem/Introspection.cs +++ b/src/GraphZen.TypeSystem/TypeSystem/Introspection.cs @@ -112,10 +112,7 @@ type is InputObjectType inputObject public static Field TypeMetaFieldDef { get; } = new("__type", "Request the type information of a single type.", null, Schema.GetObject("__Type"), - new[] - { - new Argument("name", null, NonNullType.Of(SpecScalars.String), null, null, false) - }, + new[] { new Argument("name", null, NonNullType.Of(SpecScalars.String), null, null, false) }, (source, args, context, info) => info.Schema.GetType(args.name), null); diff --git a/src/GraphZen.TypeSystem/TypeSystem/Schema.cs b/src/GraphZen.TypeSystem/TypeSystem/Schema.cs index 2cbbaf5f2..4468a46b2 100644 --- a/src/GraphZen.TypeSystem/TypeSystem/Schema.cs +++ b/src/GraphZen.TypeSystem/TypeSystem/Schema.cs @@ -116,10 +116,7 @@ public Schema(SchemaDefinition schemaDefinition, IEnumerable? types = } else { - _implementations[iface.Name] = new List - { - objectType - }; + _implementations[iface.Name] = new List { objectType }; } } } diff --git a/src/GraphZen.TypeSystem/TypeSystem/SpecDirectives.cs b/src/GraphZen.TypeSystem/TypeSystem/SpecDirectives.cs index d81d45f37..40bf39cb3 100644 --- a/src/GraphZen.TypeSystem/TypeSystem/SpecDirectives.cs +++ b/src/GraphZen.TypeSystem/TypeSystem/SpecDirectives.cs @@ -9,11 +9,7 @@ public static class SpecDirectives public static Directive Deprecated { get; } = new("deprecated", "Marks an element of a GraphQL schema as no longer supported.", - new[] - { - DirectiveLocation.EnumValue, - DirectiveLocation.FieldDefinition - }, + new[] { DirectiveLocation.EnumValue, DirectiveLocation.FieldDefinition }, new[] { new Argument("reason", "Explains why this element was deprecated, usually also including a " + @@ -46,10 +42,6 @@ public static class SpecDirectives }, null!); - public static IReadOnlyList All { get; } = new List - { - Deprecated, - Include, - Skip - }.AsReadOnly(); + public static IReadOnlyList All { get; } = + new List { Deprecated, Include, Skip }.AsReadOnly(); } diff --git a/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs b/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs index ad6150176..cc2bbf809 100644 --- a/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs +++ b/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs @@ -9,35 +9,29 @@ namespace GraphZen.TypeSystem; [Description("An enum describing what kind of type a given `__Type` is.")] public enum TypeKind { - [Description("Indicates this type is a scalar.")] - [GraphQLName("SCALAR")] + [Description("Indicates this type is a scalar.")] [GraphQLName("SCALAR")] Scalar, - [Description("Indicates this type is an object fields` and `interfaces` are valid fields.")] - [GraphQLName("OBJECT")] + [Description("Indicates this type is an object fields` and `interfaces` are valid fields.")] [GraphQLName("OBJECT")] Object, [Description("Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.")] [GraphQLName("INTERFACE")] Interface, - [Description("Indicates this type is a union. `possibleTypes` is a valid field.")] - [GraphQLName("UNION")] + [Description("Indicates this type is a union. `possibleTypes` is a valid field.")] [GraphQLName("UNION")] Union, - [Description("Indicates this type is an enum. `enumValues` is a valid field.")] - [GraphQLName("ENUM")] + [Description("Indicates this type is an enum. `enumValues` is a valid field.")] [GraphQLName("ENUM")] Enum, [Description("Indicates this type is an input object. `inputFields` is a valid field.")] [GraphQLName("INPUT_OBJECT")] InputObject, - [Description("Indicates this type is a list. `ofType` is a valid field.")] - [GraphQLName("LIST")] + [Description("Indicates this type is a list. `ofType` is a valid field.")] [GraphQLName("LIST")] List, - [Description("Indicates this type is a non-null. `ofType` is a valid field.")] - [GraphQLName("NON_NULL")] + [Description("Indicates this type is a non-null. `ofType` is a valid field.")] [GraphQLName("NON_NULL")] NonNull } diff --git a/src/GraphZen.TypeSystem/TypeSystem/TypeKindHelpers.cs b/src/GraphZen.TypeSystem/TypeSystem/TypeKindHelpers.cs index a30092607..3d290be26 100644 --- a/src/GraphZen.TypeSystem/TypeSystem/TypeKindHelpers.cs +++ b/src/GraphZen.TypeSystem/TypeSystem/TypeKindHelpers.cs @@ -13,37 +13,28 @@ public static class TypeKindHelpers { typeof(ScalarType), TypeKind.Scalar }, { typeof(IScalarType), TypeKind.Scalar }, { typeof(IScalarTypeDefinition), TypeKind.Scalar }, - - { typeof(UnionTypeDefinition), TypeKind.Union }, { typeof(UnionType), TypeKind.Union }, { typeof(IUnionType), TypeKind.Union }, { typeof(IUnionTypeDefinition), TypeKind.Union }, - { typeof(ObjectTypeDefinition), TypeKind.Object }, { typeof(ObjectType), TypeKind.Object }, { typeof(IObjectType), TypeKind.Object }, { typeof(IObjectTypeDefinition), TypeKind.Object }, - { typeof(InputObjectTypeDefinition), TypeKind.InputObject }, { typeof(InputObjectType), TypeKind.InputObject }, { typeof(IInputObjectType), TypeKind.InputObject }, { typeof(IInputObjectTypeDefinition), TypeKind.InputObject }, - - { typeof(EnumTypeDefinition), TypeKind.Enum }, { typeof(EnumType), TypeKind.Enum }, { typeof(IEnumType), TypeKind.Enum }, { typeof(IEnumTypeDefinition), TypeKind.Enum }, - { typeof(InterfaceTypeDefinition), TypeKind.Interface }, { typeof(InterfaceType), TypeKind.Interface }, { typeof(IInterfaceType), TypeKind.Interface }, { typeof(IInterfaceTypeDefinition), TypeKind.Interface }, - { typeof(ListType), TypeKind.List }, { typeof(IListType), TypeKind.List }, - { typeof(INonNullType), TypeKind.NonNull }, { typeof(NonNullType), TypeKind.NonNull } }.ToImmutableDictionary(); diff --git a/src/Linked/TypeSystem/TypeSystemAccessors.Generated.cs b/src/Linked/TypeSystem/TypeSystemAccessors.Generated.cs index 5497084e4..0c73a22dc 100644 --- a/src/Linked/TypeSystem/TypeSystemAccessors.Generated.cs +++ b/src/Linked/TypeSystem/TypeSystemAccessors.Generated.cs @@ -2,7 +2,6 @@ // Licensed under the GraphZen Community License. See the LICENSE file in the project root for license information. - // ReSharper disable PartialTypeWithSinglePart // ReSharper disable UnusedMember.Global @@ -265,4 +264,4 @@ public static Argument GetArgument(this IArguments source, string name) public static bool TryGetArgument(this IArguments source, string name, [NotNullWhen(true)] out Argument? argument) => source.Arguments.TryGetValue(Check.NotNull(name, nameof(name)), out argument); -} \ No newline at end of file +} diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 8daa1942e..9f5d1ad58 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,26 +1,26 @@ - + - - False - + + False + - - - + + + - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - \ No newline at end of file + diff --git a/test/GraphZen.Client.IntegrationTests/GraphQLRequestIntegrationTests.cs b/test/GraphZen.Client.IntegrationTests/GraphQLRequestIntegrationTests.cs index d8781c498..0aed00b3b 100644 --- a/test/GraphZen.Client.IntegrationTests/GraphQLRequestIntegrationTests.cs +++ b/test/GraphZen.Client.IntegrationTests/GraphQLRequestIntegrationTests.cs @@ -26,10 +26,7 @@ public GraphQLRequestIntegrationTests() [Fact] public async Task it_can_be_used_to_execute_graphql_request() { - var graphqlRequest = new GraphQLRequest - { - Query = @"{ message }" - }; + var graphqlRequest = new GraphQLRequest { Query = @"{ message }" }; var expected = new { message = "Hello world" }; var response = await _gql.SendAsync(graphqlRequest); diff --git a/test/GraphZen.Client.Tests/Internal/GraphQLSerializerTests.cs b/test/GraphZen.Client.Tests/Internal/GraphQLSerializerTests.cs index bb2807f15..bf28bd2b2 100644 --- a/test/GraphZen.Client.Tests/Internal/GraphQLSerializerTests.cs +++ b/test/GraphZen.Client.Tests/Internal/GraphQLSerializerTests.cs @@ -61,10 +61,6 @@ public void parse_typed_data_should_return_typed_data() { var result = GraphQLJsonSerializer.ParseData("{\"data\":{\"number\": 1, \"message\":\"hello\"}}"); - JsonAssert.EquivalentToJsonFromObject(result, new TypedQueryResult - { - Message = "hello", - Number = 1 - }); + JsonAssert.EquivalentToJsonFromObject(result, new TypedQueryResult { Message = "hello", Number = 1 }); } } diff --git a/test/GraphZen.Tests/Error/GraphQLErrorTests.cs b/test/GraphZen.Tests/Error/GraphQLErrorTests.cs index 4fb338599..f6c2deeda 100644 --- a/test/GraphZen.Tests/Error/GraphQLErrorTests.cs +++ b/test/GraphZen.Tests/Error/GraphQLErrorTests.cs @@ -58,11 +58,7 @@ public void ItSerializesToIncludeMessageAndLocations() var node = ((OperationDefinitionSyntax)ast.Definitions[0]).SelectionSet.Selections.First(); var e = new GraphQLServerError("msg", new SyntaxNode[] { node }); JsonAssert.EquivalentToJsonFromObject(e, - new - { - message = "msg", - locations = new object[] { new { line = 1, column = 3 } } - }); + new { message = "msg", locations = new object[] { new { line = 1, column = 3 } } }); } [Fact] @@ -70,10 +66,7 @@ public void ItSerializesToIncludePath() { var e = new GraphQLServerError("msg", null, null, null, new object[] { "path", 3, "to", "field" }); Assert.Equal(new object[] { "path", 3, "to", "field" }, e.Path); - JsonAssert.EquivalentToJsonFromObject(e, new - { - message = "msg", - path = new object[] { "path", 3, "to", "field" } - }); + JsonAssert.EquivalentToJsonFromObject(e, + new { message = "msg", path = new object[] { "path", 3, "to", "field" } }); } } diff --git a/test/GraphZen.Tests/FixIndentTests.cs b/test/GraphZen.Tests/FixIndentTests.cs index 7cdd8c31e..0da137abf 100644 --- a/test/GraphZen.Tests/FixIndentTests.cs +++ b/test/GraphZen.Tests/FixIndentTests.cs @@ -24,15 +24,7 @@ type User { var expected = new[] { - "type Query {", - " me: User", - "}", - "", - "type User {", - " id: ID", - " name: String", - "}", - "" + "type Query {", " me: User", "}", "", "type User {", " id: ID", " name: String", "}", "" }.ToMultiLineString(); Assert.Equal(expected, result); @@ -47,10 +39,7 @@ public void RemovesOnlyFirstLevelOfIndentation() quuux quuuux".Dedent(); - var expected = new[] - { - "qux", " quux", " quuux", " quuuux" - }.ToMultiLineString(); + var expected = new[] { "qux", " quux", " quuux", " quuuux" }.ToMultiLineString(); Assert.Equal(expected, result); } } diff --git a/test/GraphZen.Tests/LanguageModel/BlockStringValueTests.cs b/test/GraphZen.Tests/LanguageModel/BlockStringValueTests.cs index 8837fd752..1387f3967 100644 --- a/test/GraphZen.Tests/LanguageModel/BlockStringValueTests.cs +++ b/test/GraphZen.Tests/LanguageModel/BlockStringValueTests.cs @@ -13,25 +13,14 @@ public void DoesNotALterTrailingSpaces() { var rawValue = new[] { - " ", - " Hello, ", - " World! ", - " ", - " Yours, ", - " GraphQL. ", - " " + " ", " Hello, ", " World! ", " ", " Yours, ", + " GraphQL. ", " " }.ToMultiLineString(); var result = LanguageHelpers.BlockStringValue(rawValue); - var expected = new[] - { - "Hello, ", - " World! ", - " ", - "Yours, ", - " GraphQL. " - }.ToMultiLineString(); + var expected = new[] { "Hello, ", " World! ", " ", "Yours, ", " GraphQL. " } + .ToMultiLineString(); Assert.Equal(expected, result); } @@ -41,24 +30,13 @@ public void RemovesBlankLeadingAndTrailingLines() { var rawValue = new[] { - " ", - " ", - "", - " Hello,", - " World!", - "", - " Yours,", - " GraphQL.", - " ", + " ", " ", "", " Hello,", " World!", "", " Yours,", " GraphQL.", " ", " " }.ToMultiLineString(); var result = LanguageHelpers.BlockStringValue(rawValue); - var expected = new[] - { - "Hello,", " World!", "", "Yours,", " GraphQL." - }.ToMultiLineString(); + var expected = new[] { "Hello,", " World!", "", "Yours,", " GraphQL." }.ToMultiLineString(); Assert.Equal(expected, result); } @@ -66,26 +44,12 @@ public void RemovesBlankLeadingAndTrailingLines() [Fact] public void RemovesEmptyLeadingAndTrailingLines() { - var rawValue = new[] - { - "", - "", - "", - " Hello,", - " World!", - "", - " Yours,", - " GraphQL.", - "", - "" - }.ToMultiLineString(); + var rawValue = new[] { "", "", "", " Hello,", " World!", "", " Yours,", " GraphQL.", "", "" } + .ToMultiLineString(); var result = LanguageHelpers.BlockStringValue(rawValue); - var expected = new[] - { - "Hello,", " World!", "", "Yours,", " GraphQL." - }.ToMultiLineString(); + var expected = new[] { "Hello,", " World!", "", "Yours,", " GraphQL." }.ToMultiLineString(); Assert.Equal(expected, result); } @@ -93,22 +57,12 @@ public void RemovesEmptyLeadingAndTrailingLines() [Fact] public void RemovesUniformIndentationFromAString() { - var rawValue = new[] - { - "", - " Hello,", - " World!", - "", - " Yours,", - " GraphQL." - }.ToMultiLineString(); + var rawValue = + new[] { "", " Hello,", " World!", "", " Yours,", " GraphQL." }.ToMultiLineString(); var result = LanguageHelpers.BlockStringValue(rawValue); - var expected = new[] - { - "Hello,", " World!", "", "Yours,", " GraphQL." - }.ToMultiLineString(); + var expected = new[] { "Hello,", " World!", "", "Yours,", " GraphQL." }.ToMultiLineString(); Assert.Equal(expected, result); } @@ -116,21 +70,11 @@ public void RemovesUniformIndentationFromAString() [Fact] public void RetainsIndentationFromFirstLine() { - var rawValue = new[] - { - " Hello,", - " World!", - "", - " Yours,", - " GraphQL." - }.ToMultiLineString(); + var rawValue = new[] { " Hello,", " World!", "", " Yours,", " GraphQL." }.ToMultiLineString(); var result = LanguageHelpers.BlockStringValue(rawValue); - var expected = new[] - { - " Hello,", " World!", "", "Yours,", " GraphQL." - }.ToMultiLineString(); + var expected = new[] { " Hello,", " World!", "", "Yours,", " GraphQL." }.ToMultiLineString(); Assert.Equal(expected, result); } diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/DirectiveParserTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/DirectiveParserTests.cs index b11c03032..89fb99d85 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/DirectiveParserTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/DirectiveParserTests.cs @@ -16,10 +16,7 @@ public void NameOnly() { var tokens = _tokenizer.Tokenize("@skip"); var testResult = Grammar.Directives(tokens); - var expectedValue = new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("skip")) - }; + var expectedValue = new[] { SyntaxFactory.Directive(SyntaxFactory.Name("skip")) }; Assert.Equal(expectedValue, testResult.Value); } @@ -32,10 +29,7 @@ public void NameWithArguments() new[] { new DirectiveSyntax(SyntaxFactory.Name("skip"), - new[] - { - SyntaxFactory.Argument(SyntaxFactory.Name("count"), SyntaxFactory.IntValue(1)) - }) + new[] { SyntaxFactory.Argument(SyntaxFactory.Name("count"), SyntaxFactory.IntValue(1)) }) }; Assert.Equal(expectedValue, testResult.Value); } diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeDefinitionParsingTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeDefinitionParsingTests.cs index a0cb4066c..6ab62a4cd 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeDefinitionParsingTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeDefinitionParsingTests.cs @@ -43,11 +43,7 @@ enum Site { } "); var expected = Document(new EnumTypeDefinitionSyntax(Name("Site"), null, null, - new[] - { - EnumValueDefinition(EnumValue(Name("DESKTOP"))), - EnumValueDefinition(EnumValue(Name("MOBILE"))) - })); + new[] { EnumValueDefinition(EnumValue(Name("DESKTOP"))), EnumValueDefinition(EnumValue(Name("MOBILE"))) })); Assert.Equal(expected, result); Assert.Equal(expected, PrintAndParse(result)); @@ -80,8 +76,8 @@ enum DescribedEnum { SyntaxHelpers.Description("Enum description"), null, new[ ] { - EnumValueDefinition(EnumValue(Name("UNDESCRIBED"))), - new EnumValueDefinitionSyntax(EnumValue(Name("DESCRIBED")), + EnumValueDefinition(EnumValue(Name("UNDESCRIBED"))), new EnumValueDefinitionSyntax( + EnumValue(Name("DESCRIBED")), SyntaxHelpers.Description("Enum value description")) })); diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeExtensionParserTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeExtensionParserTests.cs index 3b3478e9b..cc3dcc6c0 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeExtensionParserTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/EnumTypeExtensionParserTests.cs @@ -24,10 +24,8 @@ public void ExtendEnumValue() extend enum Site { VR }"); - var expected = SyntaxFactory.Document(new EnumTypeExtensionSyntax(SyntaxFactory.Name("Site"), null, new[] - { - SyntaxFactory.EnumValueDefinition(SyntaxFactory.EnumValue(SyntaxFactory.Name("VR"))) - })); + var expected = SyntaxFactory.Document(new EnumTypeExtensionSyntax(SyntaxFactory.Name("Site"), null, + new[] { SyntaxFactory.EnumValueDefinition(SyntaxFactory.EnumValue(SyntaxFactory.Name("VR"))) })); Assert.Equal(expected, result); Assert.Equal(expected, PrintAndParse(result)); diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/FragmentParserTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/FragmentParserTests.cs index 21d9418bd..eb037a668 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/FragmentParserTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/FragmentParserTests.cs @@ -31,10 +31,7 @@ public void FragmentSpreadWithDirectives() var tokens = _sut.Tokenize(source); var test = Grammar.FragmentSpread(tokens); var expectedValue = new FragmentSpreadSyntax(SyntaxFactory.Name("address"), - new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("include")) - }); + new[] { SyntaxFactory.Directive(SyntaxFactory.Name("include")) }); Assert.Equal(expectedValue, test.Value); } @@ -49,10 +46,8 @@ public void InlineFragmentFull() SyntaxFactory.NamedType(SyntaxFactory.Name("Bar")), new[] { - new DirectiveSyntax(SyntaxFactory.Name("include"), new[] - { - SyntaxFactory.Argument(SyntaxFactory.Name("times"), SyntaxFactory.IntValue(1)) - }) + new DirectiveSyntax(SyntaxFactory.Name("include"), + new[] { SyntaxFactory.Argument(SyntaxFactory.Name("times"), SyntaxFactory.IntValue(1)) }) }); Assert.Equal(expectedValue, test.Value); } @@ -100,10 +95,8 @@ fragment address on User @directive { var test = Grammar.FragmentDefinition(tokens); var expectedValue = new FragmentDefinitionSyntax(SyntaxFactory.Name("address"), SyntaxFactory.NamedType(SyntaxFactory.Name("User")), - SyntaxFactory.SelectionSet(SyntaxFactory.Field(SyntaxFactory.Name("line1"))), new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("directive")) - }); + SyntaxFactory.SelectionSet(SyntaxFactory.Field(SyntaxFactory.Name("line1"))), + new[] { SyntaxFactory.Directive(SyntaxFactory.Name("directive")) }); Assert.Equal(expectedValue, test.Value); } } diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/InterfaceTypeDefinitionParsingTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/InterfaceTypeDefinitionParsingTests.cs index 3a6cac798..5becc9aad 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/InterfaceTypeDefinitionParsingTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/InterfaceTypeDefinitionParsingTests.cs @@ -17,10 +17,8 @@ interface AnnotatedInterface @onInterface { } "); var expected = SyntaxFactory.Document(new InterfaceTypeDefinitionSyntax( - SyntaxFactory.Name("AnnotatedInterface"), null, new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("onInterface")) - }, new[] + SyntaxFactory.Name("AnnotatedInterface"), null, + new[] { SyntaxFactory.Directive(SyntaxFactory.Name("onInterface")) }, new[] { new FieldDefinitionSyntax(SyntaxFactory.Name("annotatedField"), SyntaxFactory.NamedType(SyntaxFactory.Name("Type")), null, new[] diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/ObjectTypeDefinitionParsingTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/ObjectTypeDefinitionParsingTests.cs index 8be848a46..c8da7b533 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/ObjectTypeDefinitionParsingTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/ObjectTypeDefinitionParsingTests.cs @@ -27,10 +27,8 @@ type AnnotatedObject @onObject(arg: ""value"") { { new InputValueDefinitionSyntax(SyntaxFactory.Name("arg"), SyntaxFactory.NamedType(SyntaxFactory.Name("Type")), null, - SyntaxFactory.StringValue("default"), new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("onArg")) - }) + SyntaxFactory.StringValue("default"), + new[] { SyntaxFactory.Directive(SyntaxFactory.Name("onArg")) }) }, new[] { SyntaxFactory.Directive(SyntaxFactory.Name("onField")) }) })); Assert.Equal(expected, result); @@ -69,7 +67,8 @@ This is a description of the `argument` argument. var expected = SyntaxFactory.Document(new ObjectTypeDefinitionSyntax(SyntaxFactory.Name("Foo"), SyntaxFactory.StringValue(@"This is a description -of the `Foo` type.", true), new[] +of the `Foo` type.", true), + new[] { SyntaxFactory.NamedType(SyntaxFactory.Name("Bar")), SyntaxFactory.NamedType(SyntaxFactory.Name("Baz")) diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/OperationDefinitionParsingTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/OperationDefinitionParsingTests.cs index 813b82d67..5dc4637f3 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/OperationDefinitionParsingTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/OperationDefinitionParsingTests.cs @@ -61,10 +61,8 @@ ... @skip(unless: $foo) { }, SyntaxFactory.SelectionSet(SyntaxFactory.Field(SyntaxFactory.Name("id")), SyntaxFactory.FragmentSpread(SyntaxFactory.Name("frag"))))))), - SyntaxFactory.NamedType(SyntaxFactory.Name("User")), new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("defer")) - }), new InlineFragmentSyntax( + SyntaxFactory.NamedType(SyntaxFactory.Name("User")), + new[] { SyntaxFactory.Directive(SyntaxFactory.Name("defer")) }), new InlineFragmentSyntax( SyntaxFactory.SelectionSet(SyntaxFactory.Field(SyntaxFactory.Name("id"))), null, new[] { new DirectiveSyntax(SyntaxFactory.Name("skip"), @@ -103,13 +101,9 @@ mutation likeStory { var result = ParseDocument(query); var expected = SyntaxFactory.Document(new OperationDefinitionSyntax(OperationType.Mutation, SyntaxFactory.SelectionSet(new FieldSyntax( - SyntaxFactory.Name("like"), null, new[] - { - SyntaxFactory.Argument(SyntaxFactory.Name("story"), SyntaxFactory.IntValue(123)) - }, new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("defer")) - }, + SyntaxFactory.Name("like"), null, + new[] { SyntaxFactory.Argument(SyntaxFactory.Name("story"), SyntaxFactory.IntValue(123)) }, + new[] { SyntaxFactory.Directive(SyntaxFactory.Name("defer")) }, SyntaxFactory.SelectionSet(new FieldSyntax(SyntaxFactory.Name("story"), SyntaxFactory.SelectionSet(SyntaxFactory.Field(SyntaxFactory.Name("id"))))))), SyntaxFactory.Name("likeStory"))); diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/QueryDocumentParserTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/QueryDocumentParserTests.cs index 32e2ba45f..b16631b9d 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/QueryDocumentParserTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/QueryDocumentParserTests.cs @@ -34,10 +34,7 @@ query testQuery($var1: String! = ""Foo"") @queryDirective { SyntaxFactory.VariableDefinition(SyntaxFactory.Variable(SyntaxFactory.Name("var1")), SyntaxFactory.NonNull(SyntaxFactory.NamedType(SyntaxFactory.Name("String"))), SyntaxFactory.StringValue("Foo")) - }, new[] - { - SyntaxFactory.Directive(SyntaxFactory.Name("queryDirective")) - })); + }, new[] { SyntaxFactory.Directive(SyntaxFactory.Name("queryDirective")) })); Assert.Equal(expectedValue, test.Value); } diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/SchemaTypeExtensionParsingTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/SchemaTypeExtensionParsingTests.cs index e9487703a..445c8d1fd 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/SchemaTypeExtensionParsingTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/SchemaTypeExtensionParsingTests.cs @@ -13,7 +13,9 @@ public void SchemaExtendedWithDirective() var result = ParseDocument("extend schema @onSchema"); var expected = SyntaxFactory.Document(new SchemaExtensionSyntax(new[] - { SyntaxFactory.Directive(SyntaxFactory.Name("onSchema")) })); + { + SyntaxFactory.Directive(SyntaxFactory.Name("onSchema")) + })); Assert.Equal(expected, result); Assert.Equal(expected, PrintAndParse(result)); } diff --git a/test/GraphZen.Tests/LanguageModel/Internal/Parser/UnionTypeExtensionParsingTests.cs b/test/GraphZen.Tests/LanguageModel/Internal/Parser/UnionTypeExtensionParsingTests.cs index 2243ef522..746d7bdda 100644 --- a/test/GraphZen.Tests/LanguageModel/Internal/Parser/UnionTypeExtensionParsingTests.cs +++ b/test/GraphZen.Tests/LanguageModel/Internal/Parser/UnionTypeExtensionParsingTests.cs @@ -21,11 +21,12 @@ public void UnionExtendedWithDirective() public void UnionWithExtendedTypes() { var result = ParseDocument("extend union Feed = Photo | Video"); - var expected = SyntaxFactory.Document(new UnionTypeExtensionSyntax(SyntaxFactory.Name("Feed"), null, new[] - { - SyntaxFactory.NamedType(SyntaxFactory.Name("Photo")), - SyntaxFactory.NamedType(SyntaxFactory.Name("Video")) - })); + var expected = SyntaxFactory.Document(new UnionTypeExtensionSyntax(SyntaxFactory.Name("Feed"), null, + new[] + { + SyntaxFactory.NamedType(SyntaxFactory.Name("Photo")), + SyntaxFactory.NamedType(SyntaxFactory.Name("Video")) + })); Assert.Equal(expected, result); Assert.Equal(expected, PrintAndParse(result)); } diff --git a/test/GraphZen.Tests/LanguageModel/ParserTestBase.cs b/test/GraphZen.Tests/LanguageModel/ParserTestBase.cs index 54a708462..566ccaea7 100644 --- a/test/GraphZen.Tests/LanguageModel/ParserTestBase.cs +++ b/test/GraphZen.Tests/LanguageModel/ParserTestBase.cs @@ -29,10 +29,7 @@ protected void AssertSyntaxError(string document, string expectedMessage, params (int line, int column)[] locations) { var ex = Assert.Throws(() => ParseDocument(document)); - JsonAssert.EquivalentToJsonFromObject(ex.GraphQLError, new - { - message = expectedMessage, - locations = locations.Select(l => new { l.line, l.column }) - }); + JsonAssert.EquivalentToJsonFromObject(ex.GraphQLError, + new { message = expectedMessage, locations = locations.Select(l => new { l.line, l.column }) }); } } diff --git a/test/GraphZen.Tests/QueryEngine/AbstractTests.cs b/test/GraphZen.Tests/QueryEngine/AbstractTests.cs index 2efa820b3..389279cb5 100644 --- a/test/GraphZen.Tests/QueryEngine/AbstractTests.cs +++ b/test/GraphZen.Tests/QueryEngine/AbstractTests.cs @@ -47,11 +47,11 @@ public Task IsTypeOfUsedToResolveRuntimeTypeForInterface() .Field("meows", "Boolean"); sb.Object("Query") - .Field("pets", "[Pet]", _ => _.Resolve(() => new object[] - { - new Dog { Name = "Odie", Woofs = true }, - new Cat { Name = "Garfield", Meows = false } - })); + .Field("pets", "[Pet]", + _ => _.Resolve(() => new object[] + { + new Dog { Name = "Odie", Woofs = true }, new Cat { Name = "Garfield", Meows = false } + })); }); var query = @" @@ -72,16 +72,7 @@ ... on Cat { { pets = new object[] { - new - { - name = "Odie", - woofs = true - }, - new - { - name = "Garfield", - meows = false - } + new { name = "Odie", woofs = true }, new { name = "Garfield", meows = false } } } }); @@ -121,12 +112,12 @@ public Task ResolveTypeOnInterfaceYielsUsefulError() .Field("meows", "Boolean"); sb.Object("Query") - .Field("pets", "[Pet]", _ => _.Resolve(() => new object[] - { - new Dog { Name = "Odie", Woofs = true }, - new Cat { Name = "Garfield", Meows = false }, - new Human { Name = "Jon" } - })); + .Field("pets", "[Pet]", + _ => _.Resolve(() => new object[] + { + new Dog { Name = "Odie", Woofs = true }, new Cat { Name = "Garfield", Meows = false }, + new Human { Name = "Jon" } + })); }); var query = @" { @@ -147,17 +138,7 @@ ... on Cat { { pets = new object[] { - new - { - name = "Odie", - woofs = true - }, - new - { - name = "Garfield", - meows = false - }, - null! + new { name = "Odie", woofs = true }, new { name = "Garfield", meows = false }, null! } }, errors = new object[] @@ -207,12 +188,12 @@ public Task ResolveTypeOnUnionYieldsUsefulError() sb.Object("Query") - .Field("pets", "[Pet]", _ => _.Resolve(() => new object[] - { - new Dog { Name = "Odie", Woofs = true }, - new Cat { Name = "Garfield", Meows = false }, - new Human { Name = "Jon" } - })); + .Field("pets", "[Pet]", + _ => _.Resolve(() => new object[] + { + new Dog { Name = "Odie", Woofs = true }, new Cat { Name = "Garfield", Meows = false }, + new Human { Name = "Jon" } + })); }); var query = @" { @@ -233,17 +214,7 @@ ... on Cat { { pets = new object[] { - new - { - name = "Odie", - woofs = true - }, - new - { - name = "Garfield", - meows = false - }, - null! + new { name = "Odie", woofs = true }, new { name = "Garfield", meows = false }, null! } }, errors = new object[] @@ -285,14 +256,7 @@ public Task ReturningInvalidValueFromResolveTypeYieldsUsefulError() { message = "Abstract type FooInterface must resolve to an Object type at runtime for field Query.foo with value \"dummy\", received \"null\". Either the FooInterface type should provide a \"resolveType\" function or each possible types should provide an \"IsTypeOf\" function.", - locations = new object[] - { - new - { - line = 1, - column = 3 - } - }, + locations = new object[] { new { line = 1, column = 3 } }, path = new object[] { "foo" } } } @@ -331,8 +295,7 @@ public Task ResolveTypeAllowsResolvingWithTypeName() .Field("pets", "[Pet]", _ => _.Resolve(() => new object[] { - new Dog { Name = "Odie", Woofs = true }, - new Cat { Name = "Garfield", Meows = false } + new Dog { Name = "Odie", Woofs = true }, new Cat { Name = "Garfield", Meows = false } })); }); @@ -355,16 +318,7 @@ ... on Cat { { pets = new object[] { - new - { - name = "Odie", - woofs = true - }, - new - { - name = "Garfield", - meows = false - } + new { name = "Odie", woofs = true }, new { name = "Garfield", meows = false } } } }); diff --git a/test/GraphZen.Tests/QueryEngine/ExecutorHarness.cs b/test/GraphZen.Tests/QueryEngine/ExecutorHarness.cs index 1d3b11973..ede1c0819 100644 --- a/test/GraphZen.Tests/QueryEngine/ExecutorHarness.cs +++ b/test/GraphZen.Tests/QueryEngine/ExecutorHarness.cs @@ -28,9 +28,6 @@ public Task ExecuteAsync(Schema schema, string doc, object? roo var vars = variables != null ? TestHelpers.ToDictionary(variables) : null; var ast = doc != null ? Parser.ParseDocument(doc) : null; return Executor.ExecuteAsync(schema, ast!, rootValue, null, vars, - operationName, new ExecutionOptions - { - ThrowOnError = throwOnError - }); + operationName, new ExecutionOptions { ThrowOnError = throwOnError }); } } diff --git a/test/GraphZen.Tests/QueryEngine/ExecutorTests.cs b/test/GraphZen.Tests/QueryEngine/ExecutorTests.cs index d620c3f54..ff49ad941 100644 --- a/test/GraphZen.Tests/QueryEngine/ExecutorTests.cs +++ b/test/GraphZen.Tests/QueryEngine/ExecutorTests.cs @@ -25,13 +25,7 @@ public Task AcceptsAnObjectWithNamedPropertiesAsArguments() sb.QueryType("Type"); }); - return ExecuteAsync(schema, doc, data).ShouldEqual(new - { - data = new - { - a = "rootValue" - } - }); + return ExecuteAsync(schema, doc, data).ShouldEqual(new { data = new { a = "rootValue" } }); } @@ -138,11 +132,9 @@ fragment c on DataType { b = "Boring", c = new object[] { "Contrived", null!, "Confusing" }, deeper = new object[] - { - new { a = "Apple", b = "Banana" }, - null!, - new { a = "Apple", b = "Banana" } - } + { + new { a = "Apple", b = "Banana" }, null!, new { a = "Apple", b = "Banana" } + } } } }; @@ -205,16 +197,7 @@ await ExecuteAsync(schema, doc).ShouldEqual(new a = "Apple", b = "Banana", c = "Cherry", - deep = new - { - b = "Banana", - c = "Cherry", - deeper = new - { - b = "Banana", - c = "Cherry" - } - } + deep = new { b = "Banana", c = "Cherry", deeper = new { b = "Banana", c = "Cherry" } } } }); } @@ -344,13 +327,7 @@ fragment Frag on Type { _.QueryType("Type"); }); - await ExecuteAsync(schema, doc, data).ShouldEqual(new - { - data = new - { - a = "b" - } - }); + await ExecuteAsync(schema, doc, data).ShouldEqual(new { data = new { a = "b" } }); } [Fact] @@ -392,10 +369,7 @@ public Task DoesNotIncludeArgumentsThatWereNotSet() return ExecuteAsync(schema, "{ field(a: true, c: false, e: 0) }").ShouldEqual(new { - data = new - { - field = "{\"a\":true,\"c\":false,\"e\":0}" - } + data = new { field = "{\"a\":true,\"c\":false,\"e\":0}" } }); } @@ -432,23 +406,14 @@ public Task FailsWhenIsTypeOfCheckIsNotMet() return ExecuteAsync(schema, "{specials { value } }", rootValue).ShouldEqual(new { - data = new - { - specials = new object[] { new { value = "foo" }, null! } - }, + data = new { specials = new object[] { new { value = "foo" }, null! } }, errors = new object[] { new { message = "Expected value of type \"SpecialType\" but got: {value: \"bar\"}.", - locations = new object[] - { - new { line = 1, column = 2 } - }, - path = new object[] - { - "specials", 1 - } + locations = new object[] { new { line = 1, column = 2 } }, + path = new object[] { "specials", 1 } } } }); @@ -464,13 +429,7 @@ public Task ExecutesIgnoringInvalidNonExecutableDefinitions() "; var schema = Schema.Create(_ => { _.Object("Query").Field("foo", "String"); }); - return ExecuteAsync(schema, query, throwOnError: true).ShouldEqual(new - { - data = new - { - foo = (object?)null - } - }); + return ExecuteAsync(schema, query, throwOnError: true).ShouldEqual(new { data = new { foo = (object?)null } }); } [Fact(Skip = "TODO")] diff --git a/test/GraphZen.Tests/QueryEngine/MutationsTests.cs b/test/GraphZen.Tests/QueryEngine/MutationsTests.cs index 088a0ace6..cd290de9c 100644 --- a/test/GraphZen.Tests/QueryEngine/MutationsTests.cs +++ b/test/GraphZen.Tests/QueryEngine/MutationsTests.cs @@ -138,19 +138,13 @@ mutation M { new { message = "Cannot change the number", - locations = new object[] - { - new { line = 9, column = 15 } - }, + locations = new object[] { new { line = 9, column = 15 } }, path = new object[] { "third" } }, new { message = "Cannot change the number", - locations = new object[] - { - new { line = 18, column = 15 } - }, + locations = new object[] { new { line = 18, column = 15 } }, path = new object[] { "sixth" } } } diff --git a/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs b/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs index e0d6a6edc..1b4b5e2db 100644 --- a/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs +++ b/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs @@ -76,9 +76,7 @@ public class Dog public static Person John { get; } = new() { - Name = "John", - Pets = new object[] { Garfield, Odie }, - Friends = new object[] { Liz, Odie } + Name = "John", Pets = new object[] { Garfield, Odie }, Friends = new object[] { Liz, Odie } }; [Fact] @@ -115,12 +113,11 @@ public Task ItCanIntrospectOnUnionAndIntersectionTypes() name = "Named", fields = new object[] { new { name = "name" } }, interfaces = (object?)null, - possibleTypes = new object[] - { - new { name = "Cat" }, - new { name = "Dog" }, - new { name = "Person" } - }, + possibleTypes = + new object[] + { + new { name = "Cat" }, new { name = "Dog" }, new { name = "Person" } + }, enumValues = (object?)null, inputFields = (object?)null }, @@ -129,13 +126,8 @@ public Task ItCanIntrospectOnUnionAndIntersectionTypes() kind = "UNION", name = "Pet", fields = (object?)null, - interfaces = (object?)null, - possibleTypes = new object[] - { - new { name = "Dog" }, - new { name = "Cat" } - }, + possibleTypes = new object[] { new { name = "Dog" }, new { name = "Cat" } }, enumValues = (object?)null, inputFields = (object?)null } @@ -371,14 +363,7 @@ public async Task GetsExecutionInfoInResolver() var ast = Parser.ParseDocument("{ name, friends { name } }"); await Executor.ExecuteAsync(schema, ast, john, cxt).ShouldEqual(new { - data = new - { - name = "John", - friends = new object[] - { - new { name = "Liz" } - } - } + data = new { name = "John", friends = new object[] { new { name = "Liz" } } } }); Assert.Equal(cxt, encounteredContext); diff --git a/test/GraphZen.Tests/QueryEngine/Variables/ArgumentDefaultValuesTests.cs b/test/GraphZen.Tests/QueryEngine/Variables/ArgumentDefaultValuesTests.cs index 952504fb9..5def8e37b 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/ArgumentDefaultValuesTests.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/ArgumentDefaultValuesTests.cs @@ -15,18 +15,11 @@ public Task NotWhenArugmentCannotBeCoerced() => } ").ShouldEqual(new { - data = new - { - fieldWithDefaultArgumentValue = (object?)null - }, + data = new { fieldWithDefaultArgumentValue = (object?)null }, errors = Array(new { message = "Argument \"input\" has invalid value \"WRONG_TYPE\".", - locations = Array(new - { - column = 17, - line = 3 - }), + locations = Array(new { column = 17, line = 3 }), path = Array("fieldWithDefaultArgumentValue") }) }); @@ -34,13 +27,7 @@ public Task NotWhenArugmentCannotBeCoerced() => [Fact] public Task WhenNoArgumentProvided() => ExecuteAsync("{fieldWithDefaultArgumentValue}") - .ShouldEqual(new - { - data = new - { - fieldWithDefaultArgumentValue = "\"Hello World\"" - } - }); + .ShouldEqual(new { data = new { fieldWithDefaultArgumentValue = "\"Hello World\"" } }); [Fact] public Task WhenNoRuntimeValueIsProvidedToANonNullArgument() => @@ -50,10 +37,7 @@ query optionalVariable($optional: String) { } ").ShouldEqual(new { - data = new - { - fieldWithNonNullableStringInputAndDefaultArgumentValue = "\"Hello World\"" - } + data = new { fieldWithNonNullableStringInputAndDefaultArgumentValue = "\"Hello World\"" } }); [Fact] @@ -62,13 +46,7 @@ public Task WhenOmittedVariableProvided() => query ($optional: String) { fieldWithDefaultArgumentValue(input: $optional) } - ").ShouldEqual(new - { - data = new - { - fieldWithDefaultArgumentValue = "\"Hello World\"" - } - }); + ").ShouldEqual(new { data = new { fieldWithDefaultArgumentValue = "\"Hello World\"" } }); [UsedImplicitly] private class StaticDslTests : ArgumentDefaultValuesTests diff --git a/test/GraphZen.Tests/QueryEngine/Variables/CustomEnumValuesTests.cs b/test/GraphZen.Tests/QueryEngine/Variables/CustomEnumValuesTests.cs index 19ec1960b..2803d3d61 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/CustomEnumValuesTests.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/CustomEnumValuesTests.cs @@ -33,13 +33,7 @@ public Task AllowsNonNullableInputsToHaveNullAsCustomEnumValue() => ExecuteAsync(@" { fieldWithNonNullableEnumInput(input: NULL) - }").ShouldEqual(new - { - data = new - { - fieldWithNonNullableEnumInput = "null" - } - }); + }").ShouldEqual(new { data = new { fieldWithNonNullableEnumInput = "null" } }); [UsedImplicitly] private class StaticDslTests : CustomEnumValuesTests diff --git a/test/GraphZen.Tests/QueryEngine/Variables/ListsAndNullabilityTests.cs b/test/GraphZen.Tests/QueryEngine/Variables/ListsAndNullabilityTests.cs index 612ef01f5..bbc170700 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/ListsAndNullabilityTests.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/ListsAndNullabilityTests.cs @@ -14,10 +14,7 @@ public Task AllowsListsOfNonNullsToBeNull() => listNN(input: $input) } ", new { input = (object?)null }).ShouldEqual( - new - { - data = new { listNN = "null" } - }); + new { data = new { listNN = "null" } }); [Fact] public Task AllowsListsOfNonNullsToContainValues() => @@ -26,10 +23,7 @@ public Task AllowsListsOfNonNullsToContainValues() => listNN(input: $input) } ", new { input = Array("A") }).ShouldEqual( - new - { - data = new { listNN = "[\"A\"]" } - }); + new { data = new { listNN = "[\"A\"]" } }); [Fact] public Task AllowsListsToBeNull() => @@ -37,13 +31,7 @@ public Task AllowsListsToBeNull() => query ($input: [String]) { list(input: $input) } - ", new { input = (object?)null }).ShouldEqual(new - { - data = new - { - list = "null" - } - }); + ", new { input = (object?)null }).ShouldEqual(new { data = new { list = "null" } }); [Fact] public Task AllowsListsToContainNull() => @@ -51,13 +39,7 @@ public Task AllowsListsToContainNull() => query ($input: [String]) { list(input: $input) } - ", new { input = Array("A", null, "B") }).ShouldEqual(new - { - data = new - { - list = "[\"A\",null,\"B\"]" - } - }); + ", new { input = Array("A", null, "B") }).ShouldEqual(new { data = new { list = "[\"A\",null,\"B\"]" } }); [Fact] public Task AllowsListsToContainValues() => @@ -65,13 +47,7 @@ public Task AllowsListsToContainValues() => query ($input: [String]) { list(input: $input) } - ", new { input = Array("A") }).ShouldEqual(new - { - data = new - { - list = "[\"A\"]" - } - }); + ", new { input = Array("A") }).ShouldEqual(new { data = new { list = "[\"A\"]" } }); [Fact] public Task AllowsNonNullListsOfNonNullsToContainValues() => @@ -80,13 +56,7 @@ public Task AllowsNonNullListsOfNonNullsToContainValues() => nnListNN(input: $input) } ", new { input = Array("A") }).ShouldEqual( - new - { - data = new - { - nnListNN = "[\"A\"]" - } - }); + new { data = new { nnListNN = "[\"A\"]" } }); [Fact] public Task AllowsNonNullListsToContainValues() => @@ -94,13 +64,7 @@ public Task AllowsNonNullListsToContainValues() => query ($input: [String]!) { nnList(input: $input) } - ", new { input = Array("A") }).ShouldEqual(new - { - data = new - { - nnList = "[\"A\"]" - } - }); + ", new { input = Array("A") }).ShouldEqual(new { data = new { nnList = "[\"A\"]" } }); [Fact] public Task DoesNotAllowInvalidTypesToBeUsedAsValues() => @@ -114,11 +78,7 @@ public Task DoesNotAllowInvalidTypesToBeUsedAsValues() => { message = "Variable \"$input\" expected value of type \"TestType!\" which cannot be used as an input type.", - locations = Array(new - { - line = 2, - column = 30 - }) + locations = Array(new { line = 2, column = 30 }) }) }); @@ -135,11 +95,7 @@ public Task DoesNotAllowListsOfNonNullsToContainNull() => { message = "Variable \"$input\" got invalid value `[\"A\", null, \"B\"]`; Expected non-nullable type String! not to be null at value[1].", - locations = Array(new - { - line = 2, - column = 22 - }) + locations = Array(new { line = 2, column = 22 }) }) }); @@ -155,11 +111,7 @@ public Task DoesNotAllowNonNullListsOfNonNullsToBeNull() => errors = Array(new { message = "Variable \"$input\" of non-null type \"[String!]!\" must not be null.", - locations = Array(new - { - line = 2, - column = 22 - }) + locations = Array(new { line = 2, column = 22 }) }) }); @@ -174,11 +126,7 @@ public Task DoesNotAllowNonNullListsToBeNull() => errors = Array(new { message = "Variable \"$input\" of non-null type \"[String]!\" must not be null.", - locations = Array(new - { - line = 2, - column = 22 - }) + locations = Array(new { line = 2, column = 22 }) }) }); @@ -195,11 +143,7 @@ public Task DoesNotAllowsNonNullListsOfNonNullsToContainNull() => { message = "Variable \"$input\" got invalid value `[\"A\", null, \"B\"]`; Expected non-nullable type String! not to be null at value[1].", - locations = Array(new - { - line = 2, - column = 22 - }) + locations = Array(new { line = 2, column = 22 }) }) }); @@ -215,11 +159,7 @@ public Task DoesNotAllowUnknownTypesToBeUsedAsValues() => { message = "Variable \"$input\" expected value of type \"UnknownType!\" which cannot be used as an input type.", - locations = Array(new - { - line = 2, - column = 30 - }) + locations = Array(new { line = 2, column = 30 }) }) }); @@ -229,13 +169,7 @@ public Task ItAllowsNonNullListsToContainNull() => query ($input: [String]!) { nnList(input: $input) } - ", new { input = Array("A", null, "B") }).ShouldEqual(new - { - data = new - { - nnList = "[\"A\",null,\"B\"]" - } - }); + ", new { input = Array("A", null, "B") }).ShouldEqual(new { data = new { nnList = "[\"A\",null,\"B\"]" } }); [UsedImplicitly] private class StaticDslTests : ListsAndNullabilityTests diff --git a/test/GraphZen.Tests/QueryEngine/Variables/NonNullableScalarsTests.cs b/test/GraphZen.Tests/QueryEngine/Variables/NonNullableScalarsTests.cs index 71d597317..9b0223216 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/NonNullableScalarsTests.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/NonNullableScalarsTests.cs @@ -13,10 +13,7 @@ public Task AllowsNonNullableInputsToBeOmittedGivenADefault() => query ($value: String = ""default"") { fieldWithNonNullableStringInput(input: $value) } - ").ShouldEqual(new - { - data = new { fieldWithNonNullableStringInput = "\"default\"" } - }); + ").ShouldEqual(new { data = new { fieldWithNonNullableStringInput = "\"default\"" } }); [Fact] public Task AllowsNonNullableInputsToBeSetToAValueDirectly() => @@ -24,13 +21,7 @@ public Task AllowsNonNullableInputsToBeSetToAValueDirectly() => { fieldWithNonNullableStringInput(input: ""a"") } - ").ShouldEqual(new - { - data = new - { - fieldWithNonNullableStringInput = "\"a\"" - } - }); + ").ShouldEqual(new { data = new { fieldWithNonNullableStringInput = "\"a\"" } }); [Fact] public Task AllowsNonNullableInputsToBeSetToAValueInAVariable() => @@ -38,13 +29,7 @@ public Task AllowsNonNullableInputsToBeSetToAValueInAVariable() => query ($value: String!) { fieldWithNonNullableStringInput(input: $value) } - ", new { value = "a" }).ShouldEqual(new - { - data = new - { - fieldWithNonNullableStringInput = "\"a\"" - } - }); + ", new { value = "a" }).ShouldEqual(new { data = new { fieldWithNonNullableStringInput = "\"a\"" } }); [Fact] public Task DoesNotAllowNonNullableInputsToBeOmittedInAVariable() => @@ -57,11 +42,7 @@ public Task DoesNotAllowNonNullableInputsToBeOmittedInAVariable() => errors = Array(new { message = "Variable \"$value\" of required type \"String!\" was not provided.", - locations = Array(new - { - line = 2, - column = 22 - }) + locations = Array(new { line = 2, column = 22 }) }) }); @@ -76,11 +57,7 @@ public Task DoesNotAllowNonNullableInputsToBeSetToNullInAVairable() => errors = Array(new { message = "Variable \"$value\" of non-null type \"String!\" must not be null.", - locations = Array(new - { - line = 2, - column = 22 - }) + locations = Array(new { line = 2, column = 22 }) }) }); @@ -108,18 +85,11 @@ public async Task ReportsErrorForArrayPassedIntoStringInput() public Task ReportsErrorForMissingNonNullabeInputs() => ExecuteAsync("{ fieldWithNonNullableStringInput }").ShouldEqual(new { - data = new - { - fieldWithNonNullableStringInput = (object?)null - }, + data = new { fieldWithNonNullableStringInput = (object?)null }, errors = Array(new { message = "Argument \"input\" of required type \"String!\" was not provided.", - locations = Array(new - { - line = 1, - column = 3 - }), + locations = Array(new { line = 1, column = 3 }), path = Array("fieldWithNonNullableStringInput") }) }); @@ -132,19 +102,12 @@ public Task ReportsErrorForNonProvidedVariablesForNonNullableInputs() => } ").ShouldEqual(new { - data = new - { - fieldWithNonNullableStringInput = (object?)null - }, + data = new { fieldWithNonNullableStringInput = (object?)null }, errors = Array(new { message = "Argument \"input\" of required type \"String!\" was provided the variable \"$foo\" which was not provided a runtime value.", - locations = Array(new - { - line = 3, - column = 56 - }), + locations = Array(new { line = 3, column = 56 }), path = Array("fieldWithNonNullableStringInput") }) }); diff --git a/test/GraphZen.Tests/QueryEngine/Variables/NullableScalarsTests.cs b/test/GraphZen.Tests/QueryEngine/Variables/NullableScalarsTests.cs index 83eeb1524..634a73ed6 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/NullableScalarsTests.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/NullableScalarsTests.cs @@ -13,13 +13,7 @@ public Task AllowsNullableInputsToBeOmitted() => { fieldWithNullableStringInput } - ").ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = (string?)null - } - }); + ").ShouldEqual(new { data = new { fieldWithNullableStringInput = (string?)null } }); [Fact] public Task AllowsNullableInputsToBeOmittedInAnUnlistedVariable() => @@ -27,13 +21,7 @@ public Task AllowsNullableInputsToBeOmittedInAnUnlistedVariable() => query { fieldWithNullableStringInput(input: $value) } - ").ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = (string?)null - } - }); + ").ShouldEqual(new { data = new { fieldWithNullableStringInput = (string?)null } }); [Fact] public Task AllowsNullableInputsToBeOmittedInAVariable() => @@ -41,13 +29,7 @@ public Task AllowsNullableInputsToBeOmittedInAVariable() => query ($value: String) { fieldWithNullableStringInput(input: $value) } - ").ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = (string?)null - } - }); + ").ShouldEqual(new { data = new { fieldWithNullableStringInput = (string?)null } }); [Fact] public Task AllowsNullableInputsToBeSetInAVariable() => @@ -55,13 +37,7 @@ public Task AllowsNullableInputsToBeSetInAVariable() => query ($value: String) { fieldWithNullableStringInput(input: $value) } - ", new { value = "a" }).ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = "\"a\"" - } - }); + ", new { value = "a" }).ShouldEqual(new { data = new { fieldWithNullableStringInput = "\"a\"" } }); [Fact] public Task AllowsNullableInputsToBeSetToNullInAVariable() => @@ -69,13 +45,7 @@ public Task AllowsNullableInputsToBeSetToNullInAVariable() => query ($value: String) { fieldWithNullableStringInput(input: $value) } - ", new { value = (string?)null }).ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = "null" - } - }); + ", new { value = (string?)null }).ShouldEqual(new { data = new { fieldWithNullableStringInput = "null" } }); [Fact] public Task AllowsNullableInputsToBeSetToValueDirectly() => @@ -83,13 +53,7 @@ public Task AllowsNullableInputsToBeSetToValueDirectly() => { fieldWithNullableStringInput(input: ""a"") } - ", new { value = "a" }).ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = "\"a\"" - } - }); + ", new { value = "a" }).ShouldEqual(new { data = new { fieldWithNullableStringInput = "\"a\"" } }); [UsedImplicitly] private class StaticDslTests : NullableScalarsTests diff --git a/test/GraphZen.Tests/QueryEngine/Variables/UsingInlineStructs.cs b/test/GraphZen.Tests/QueryEngine/Variables/UsingInlineStructs.cs index 5e4c8950e..2fd942e41 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/UsingInlineStructs.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/UsingInlineStructs.cs @@ -16,10 +16,7 @@ public Task DoesNotUseIncorrectValue() } ").ShouldEqual(new { - data = new - { - fieldWithObjectInput = (object?)null - }, + data = new { fieldWithObjectInput = (object?)null }, errors = new object[] { new @@ -39,13 +36,7 @@ public Task ExecutesWithComplextInput() => fieldWithObjectInput(input: { a: ""foo"", b: [""bar""], c: ""baz""}) } ").ShouldEqual( - new - { - data = new - { - fieldWithObjectInput = @"{""a"":""foo"",""b"":[""bar""],""c"":""baz""}" - } - } + new { data = new { fieldWithObjectInput = @"{""a"":""foo"",""b"":[""bar""],""c"":""baz""}" } } ); [Fact] @@ -55,13 +46,7 @@ public Task ProperlyParsesNullValueInList() => fieldWithObjectInput(input: {b: [""A"",null,""C""], c: ""C""}) } ") - .ShouldEqual(new - { - data = new - { - fieldWithObjectInput = @"{""b"":[""A"",null,""C""],""c"":""C""}" - } - }); + .ShouldEqual(new { data = new { fieldWithObjectInput = @"{""b"":[""A"",null,""C""],""c"":""C""}" } }); [Fact] public Task ProperlyParsesNullValueToNull() => @@ -70,13 +55,7 @@ public Task ProperlyParsesNullValueToNull() => fieldWithObjectInput(input: {a: null, b: null, c: ""C"", d: null}) } ").ShouldEqual( - new - { - data = new - { - fieldWithObjectInput = @"{""a"":null,""b"":null,""c"":""C"",""d"":null}" - } - }); + new { data = new { fieldWithObjectInput = @"{""a"":null,""b"":null,""c"":""C"",""d"":null}" } }); [Fact] public Task ProperlyParsesSingleValueToList() => @@ -85,13 +64,7 @@ public Task ProperlyParsesSingleValueToList() => fieldWithObjectInput(input: {a: ""foo"", b: ""bar"", c: ""baz""}) } ").ShouldEqual( - new - { - data = new - { - fieldWithObjectInput = @"{""a"":""foo"",""b"":[""bar""],""c"":""baz""}" - } - } + new { data = new { fieldWithObjectInput = @"{""a"":""foo"",""b"":[""bar""],""c"":""baz""}" } } ); [Fact] @@ -100,13 +73,7 @@ public Task ProperlyRunsParseLiteralOnComplexScalarTypes() => { fieldWithObjectInput(input: {c: ""foo"", d: ""SerializedValue""}) }") - .ShouldEqual(new - { - data = new - { - fieldWithObjectInput = @"{""c"":""foo"",""d"":""DeserializedValue""}" - } - }); + .ShouldEqual(new { data = new { fieldWithObjectInput = @"{""c"":""foo"",""d"":""DeserializedValue""}" } }); [UsedImplicitly] private class StaticDslTests : UsingInlineStructs diff --git a/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs b/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs index 4ad6153c8..b4fbf45f6 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs @@ -22,11 +22,7 @@ public Task ErrorsOnAdditionOfUnkownInputField() => { message = "Variable \"$input\" got invalid value `{a: \"foo\", b: \"bar\", c: \"baz\", extra: \"dog\"}`; Field \"extra\" is not defined by type TestInputObject; Did you mean to select another field?", - locations = Array(new - { - line = 2, - column = 25 - }) + locations = Array(new { line = 2, column = 25 }) }) }); @@ -35,68 +31,39 @@ public Task ErrorsOnDeepNestedErrorsAndWithmanyErrors() => ExecuteAsync(@" query ($input: TestNestedInputObject) { fieldWithNestedObjectInput(input: $input) - }", new - { - input = new - { - na = new { a = "foo" } - } - }) + }", new { input = new { na = new { a = "foo" } } }) .ShouldEqual(new { errors = Array(new - { - message = - "Variable \"$input\" got invalid value `{na: {a: \"foo\"}}`; Field value.nb of required type String! was not provided.", - locations = Array(new { - line = 2, - column = 20 - }) - }, + message = + "Variable \"$input\" got invalid value `{na: {a: \"foo\"}}`; Field value.nb of required type String! was not provided.", + locations = Array(new { line = 2, column = 20 }) + }, new { message = "Variable \"$input\" got invalid value `{na: {a: \"foo\"}}`; Field value.na.c of required type String! was not provided.", - locations = Array(new - { - line = 2, - column = 20 - }) + locations = Array(new { line = 2, column = 20 }) } ) }); [Fact] public Task ErrorsOnIncorrectType() => - ExecuteAsync(Doc, new - { - input = "foo bar" - }).ShouldEqual(new + ExecuteAsync(Doc, new { input = "foo bar" }).ShouldEqual(new { errors = Array(new { message = "Variable \"$input\" got invalid value `\"foo bar\"`; Expected TestInputObject to be an object.", - locations = Array(new - { - line = 2, - column = 25 - }) + locations = Array(new { line = 2, column = 25 }) }) }); [Fact] public Task ErrorsOnNullForNestedNonNull() => - ExecuteAsync(Doc, new - { - input = new - { - a = "foo", - b = "bar", - c = (string?)null - } - }).ShouldEqual(new + ExecuteAsync(Doc, new { input = new { a = "foo", b = "bar", c = (string?)null } }).ShouldEqual(new { errors = Array( new @@ -116,11 +83,7 @@ public Task ErrorsOnOmissionOfNestedNonNull() => { message = "Variable \"$input\" got invalid value `{a: \"foo\", b: \"bar\"}`; Field value.c of required type String! was not provided.", - locations = Array(new - { - line = 2, - column = 25 - }) + locations = Array(new { line = 2, column = 25 }) }) }); @@ -130,46 +93,20 @@ public Task ItDoesNotUseDefaultValueWhenProvided() => query q($input: String = ""Default value"") { fieldWithNullableStringInput(input: $input) } - ", new - { - input = "Variable value" - }) - .ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = "\"Variable value\"" - } - }); + ", new { input = "Variable value" }) + .ShouldEqual(new { data = new { fieldWithNullableStringInput = "\"Variable value\"" } }); [Fact] public Task ItExecutesWithComplexInput() => ExecuteAsync(Doc, - new - { - input = new - { - a = "foo", - b = Array("bar"), - c = "baz" - } - } - ).ShouldEqual(new - { - data = new - { - fieldWithObjectInput = @"{""a"":""foo"",""b"":[""bar""],""c"":""baz""}" - } - }); + new { input = new { a = "foo", b = Array("bar"), c = "baz" } } + ).ShouldEqual(new { data = new { fieldWithObjectInput = @"{""a"":""foo"",""b"":[""bar""],""c"":""baz""}" } }); [Fact] public Task ItExecutesWithComplexScalarInput() => ExecuteAsync(Doc, new { input = new { c = "foo", d = "SerializedValue" } }).ShouldEqual(new { - data = new - { - fieldWithObjectInput = "{\"c\":\"foo\",\"d\":\"DeserializedValue\"}" - } + data = new { fieldWithObjectInput = "{\"c\":\"foo\",\"d\":\"DeserializedValue\"}" } }); [Fact] @@ -178,13 +115,7 @@ public Task ItUsesDefaultValueWhenNotProvided() => query ($input: TestInputObject = {a: ""foo"", b: [""bar""], c: ""baz""}) { fieldWithObjectInput(input: $input) }") - .ShouldEqual(new - { - data = new - { - fieldWithObjectInput = "{\"a\":\"foo\",\"b\":[\"bar\"],\"c\":\"baz\"}" - } - }); + .ShouldEqual(new { data = new { fieldWithObjectInput = "{\"a\":\"foo\",\"b\":[\"bar\"],\"c\":\"baz\"}" } }); [Fact] @@ -193,17 +124,8 @@ public Task ItUsesExplicitNullValueInsteadOfDefaultValue() => query q($input: String = ""Default value"") { fieldWithNullableStringInput(input: $input) } - ", new - { - input = (string?)null - }) - .ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = "null" - } - }); + ", new { input = (string?)null }) + .ShouldEqual(new { data = new { fieldWithNullableStringInput = "null" } }); [Fact] public Task ItUsesNullDefaultValueWhenNotProvided() => @@ -212,13 +134,7 @@ query q($input: String = null) { fieldWithNullableStringInput(input: $input) } ") - .ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = "null" - } - }); + .ShouldEqual(new { data = new { fieldWithNullableStringInput = "null" } }); [Fact] public Task ItUsesNullWhenVariableProvidedExplicitNullValue() => @@ -226,13 +142,7 @@ public Task ItUsesNullWhenVariableProvidedExplicitNullValue() => query q($input: String) { fieldWithNullableStringInput(input: $input) }", new { input = (string?)null }) - .ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = "null" - } - }); + .ShouldEqual(new { data = new { fieldWithNullableStringInput = "null" } }); [Fact] public Task ItUsesUndefinedWhenVariableNotProvided() => @@ -240,24 +150,12 @@ public Task ItUsesUndefinedWhenVariableNotProvided() => query q($input: String) { fieldWithNullableStringInput(input: $input) }", new { }) - .ShouldEqual(new - { - data = new - { - fieldWithNullableStringInput = (string?)null - } - }); + .ShouldEqual(new { data = new { fieldWithNullableStringInput = (string?)null } }); [Fact] public Task ProperlyParsesSingleValueToList() => ExecuteAsync(Doc, new { input = new { a = "foo", b = "bar", c = "baz" } }) - .ShouldEqual(new - { - data = new - { - fieldWithObjectInput = "{\"a\":\"foo\",\"b\":[\"bar\"],\"c\":\"baz\"}" - } - }); + .ShouldEqual(new { data = new { fieldWithObjectInput = "{\"a\":\"foo\",\"b\":[\"bar\"],\"c\":\"baz\"}" } }); [UsedImplicitly] private class StaticDslTests : UsingVariables diff --git a/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs b/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs index 4ad561be6..447dc5efc 100644 --- a/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs +++ b/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs @@ -21,39 +21,27 @@ query IntrospectionTypeQuery { } } - ").ShouldEqual(new - { - data = new + ").ShouldEqual( + new { - __schema = new + data = new { - types = new object[] + __schema = new { - new { name = "Query" }, - new { name = "Episode" }, - new { name = "Character" }, - new { name = "String" }, - new { name = "Human" }, - new { name = "Droid" }, - new { name = "__Schema" }, - new { name = "__Type" }, - new { name = "__TypeKind" }, - new { name = "Boolean" }, - new { name = "Float" }, - new { name = "ID" }, - new { name = "Int" }, - new { name = "__Field" }, - new { name = "__InputValue" }, - new { name = "__EnumValue" }, - new { name = "__Directive" }, - new { name = "__DirectiveLocation" } + types = new object[] + { + new { name = "Query" }, new { name = "Episode" }, + new { name = "Character" }, new { name = "String" }, new { name = "Human" }, + new { name = "Droid" }, new { name = "__Schema" }, new { name = "__Type" }, + new { name = "__TypeKind" }, new { name = "Boolean" }, + new { name = "Float" }, new { name = "ID" }, new { name = "Int" }, + new { name = "__Field" }, new { name = "__InputValue" }, + new { name = "__EnumValue" }, new { name = "__Directive" }, + new { name = "__DirectiveLocation" } + } } } - } - }, new JsonDiffOptions - { - SortBeforeCompare = true - }); + }, new JsonDiffOptions { SortBeforeCompare = true }); } [Fact] @@ -68,19 +56,7 @@ query IntrospectionQueryTypeQuery { } } - ").ShouldEqual(new - { - data = new - { - __schema = new - { - queryType = new - { - name = "Query" - } - } - } - }); + ").ShouldEqual(new { data = new { __schema = new { queryType = new { name = "Query" } } } }); [Fact] public Task AllowsQueryingTheSchemaForASpecificType() => @@ -92,16 +68,7 @@ query IntrospectionDroidTypeQuery { } } - ").ShouldEqual(new - { - data = new - { - __type = new - { - name = "Droid" - } - } - }); + ").ShouldEqual(new { data = new { __type = new { name = "Droid" } } }); [Fact] public Task AllowsQueryingTheSchemaForAnObjectKind() => @@ -114,17 +81,7 @@ query IntrospectionDroidKindQuery { } } - ").ShouldEqual(new - { - data = new - { - __type = new - { - name = "Droid", - kind = "OBJECT" - } - } - }); + ").ShouldEqual(new { data = new { __type = new { name = "Droid", kind = "OBJECT" } } }); [Fact] public Task AllowsQueryingTheSchemaForAnInterfaceKind() => @@ -137,17 +94,7 @@ query IntrospectionCharacterKindQuery { } } - ").ShouldEqual(new - { - data = new - { - __type = new - { - name = "Character", - kind = "INTERFACE" - } - } - }); + ").ShouldEqual(new { data = new { __type = new { name = "Character", kind = "INTERFACE" } } }); [Fact] public Task AllowsQueryingTheSchemaForObjectFields() @@ -176,60 +123,19 @@ query IntrospectionDroidFieldsQuery { name = "Droid", fields = new object[] { - new - { - name = "id", - type = new - { - name = (string?)null, - kind = "NON_NULL" - } - }, - new - { - name = "name", - type = new - { - name = "String", - kind = "SCALAR" - } - }, - new - { - name = "friends", - type = new - { - name = (string?)null, - kind = "LIST" - } - }, - new - { - name = "appearsIn", - type = new - { - name = (string?)null, - kind = "LIST" - } - }, - + new { name = "id", type = new { name = (string?)null, kind = "NON_NULL" } }, + new { name = "name", type = new { name = "String", kind = "SCALAR" } }, + new { name = "friends", type = new { name = (string?)null, kind = "LIST" } }, + new { name = "appearsIn", type = new { name = (string?)null, kind = "LIST" } }, new { name = "secretBackstory", - type = new - { - name = "String", - kind = "SCALAR" - } + type = new { name = "String", kind = "SCALAR" } }, new { name = "primaryFunction", - type = new - { - name = "String", - kind = "SCALAR" - } + type = new { name = "String", kind = "SCALAR" } } } } @@ -271,26 +177,18 @@ query IntrospectionDroidNestedFieldsQuery { new { name = "id", - type = new - { - name = (string?)null, - kind = "NON_NULL", - ofType = new + type = + new { - name = "String", - kind = "SCALAR" + name = (string?)null, + kind = "NON_NULL", + ofType = new { name = "String", kind = "SCALAR" } } - } }, new { name = "name", - type = new - { - name = "String", - kind = "SCALAR", - ofType = (object?)null - } + type = new { name = "String", kind = "SCALAR", ofType = (object?)null } }, new { @@ -299,11 +197,7 @@ query IntrospectionDroidNestedFieldsQuery { { name = (string?)null, kind = "LIST", - ofType = new - { - name = "Character", - kind = "INTERFACE" - } + ofType = new { name = "Character", kind = "INTERFACE" } } }, new @@ -313,33 +207,18 @@ query IntrospectionDroidNestedFieldsQuery { { name = (string?)null, kind = "LIST", - ofType = new - { - name = "Episode", - kind = "ENUM" - } + ofType = new { name = "Episode", kind = "ENUM" } } }, - new { name = "secretBackstory", - type = new - { - name = "String", - kind = "SCALAR", - ofType = (object?)null - } + type = new { name = "String", kind = "SCALAR", ofType = (object?)null } }, new { name = "primaryFunction", - type = new - { - name = "String", - kind = "SCALAR", - ofType = (object?)null - } + type = new { name = "String", kind = "SCALAR", ofType = (object?)null } } } } @@ -393,12 +272,7 @@ query IntrospectionQueryTypeQuery { description = "If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.", name = "episode", - type = new - { - kind = "ENUM", - name = "Episode", - ofType = (object?)null - }, + type = new { kind = "ENUM", name = "Episode", ofType = (object?)null }, defaultValue = (object?)null } } @@ -416,11 +290,7 @@ query IntrospectionQueryTypeQuery { { kind = "NON_NULL", name = (string?)null, - ofType = new - { - kind = "SCALAR", - name = "String" - } + ofType = new { kind = "SCALAR", name = "String" } }, defaultValue = (object?)null } @@ -439,11 +309,7 @@ query IntrospectionQueryTypeQuery { { kind = "NON_NULL", name = (string?)null, - ofType = new - { - kind = "SCALAR", - name = "String" - } + ofType = new { kind = "SCALAR", name = "String" } }, defaultValue = (object?)null } @@ -453,10 +319,7 @@ query IntrospectionQueryTypeQuery { } } } - }, new JsonDiffOptions - { - SortBeforeCompare = true - }); + }, new JsonDiffOptions { SortBeforeCompare = true }); } [Fact] @@ -476,8 +339,7 @@ query IntrospectionDroidDescriptionQuery { { __type = new { - name = "Droid", - description = "A mechanical creature in the Star Wars universe." + name = "Droid", description = "A mechanical creature in the Star Wars universe." } } }); diff --git a/test/GraphZen.Tests/StarWars/StarWarsQueryTest.cs b/test/GraphZen.Tests/StarWars/StarWarsQueryTest.cs index 8c86079e2..ecd78dab7 100644 --- a/test/GraphZen.Tests/StarWars/StarWarsQueryTest.cs +++ b/test/GraphZen.Tests/StarWars/StarWarsQueryTest.cs @@ -10,13 +10,7 @@ public class StarWarsQueryTest : StarWarsSchemaAndData public Task CorrectlyIdentifiesR2D2AsTHeHeroOfTheStarWarsSaga() => ExecuteAsync(StarWarsSchema, "query HeroNameQuery { hero { name } }").ShouldEqual(new { - data = new - { - hero = new - { - name = "R2-D2" - } - } + data = new { hero = new { name = "R2-D2" } } }); [Fact(Skip = "Not applicable to .NET implementation")] @@ -44,8 +38,7 @@ query HeroNameAndFriendsQuery { name = "R2-D2", friends = new object[] { - new { name = "Luke Skywalker" }, - new { name = "Han Solo" }, + new { name = "Luke Skywalker" }, new { name = "Han Solo" }, new { name = "Leia Organa" } } } @@ -82,13 +75,12 @@ query NestedQuery { { name = "Luke Skywalker", appearsIn = new object[] { "NEW_HOPE", "EMPIRE", "JEDI" }, - friends = new object[] - { - new { name = "Han Solo" }, - new { name = "Leia Organa" }, - new { name = "C-3P0" }, - new { name = "R2-D2" } - } + friends = + new object[] + { + new { name = "Han Solo" }, new { name = "Leia Organa" }, + new { name = "C-3P0" }, new { name = "R2-D2" } + } }, new { @@ -96,8 +88,7 @@ query NestedQuery { appearsIn = new object[] { "NEW_HOPE", "EMPIRE", "JEDI" }, friends = new object[] { - new { name = "Luke Skywalker" }, - new { name = "Leia Organa" }, + new { name = "Luke Skywalker" }, new { name = "Leia Organa" }, new { name = "R2-D2" } } }, @@ -107,10 +98,8 @@ query NestedQuery { appearsIn = new object[] { "NEW_HOPE", "EMPIRE", "JEDI" }, friends = new object[] { - new { name = "Luke Skywalker" }, - new { name = "Han Solo" }, - new { name = "C-3P0" }, - new { name = "R2-D2" } + new { name = "Luke Skywalker" }, new { name = "Han Solo" }, + new { name = "C-3P0" }, new { name = "R2-D2" } } } } @@ -126,16 +115,7 @@ query FetchLukeQuery { human(id: ""1000"") { name } - }").ShouldEqual(new - { - data = new - { - human = new - { - name = "Luke Skywalker" - } - } - }); + }").ShouldEqual(new { data = new { human = new { name = "Luke Skywalker" } } }); [Theory] [InlineData("1000", "Luke Skywalker")] @@ -149,13 +129,7 @@ query FetchSomeIDQuery($someId: String!) { human(id: $someId) { name } - }", null, new { someId = id }).ShouldEqual(new - { - data = new - { - human - } - }); + }", null, new { someId = id }).ShouldEqual(new { data = new { human } }); } [Fact] @@ -165,13 +139,7 @@ query FetchLukeAliased { luke: human(id: ""1000"") { name } - }").ShouldEqual(new - { - data = new - { - luke = new { name = "Luke Skywalker" } - } - }); + }").ShouldEqual(new { data = new { luke = new { name = "Luke Skywalker" } } }); [Fact] public Task QueryForLukeAndLeiaOnRootWithAliases() => @@ -185,11 +153,7 @@ query FetchLukeAndLeiaAliased { } }").ShouldEqual(new { - data = new - { - luke = new { name = "Luke Skywalker" }, - leia = new { name = "Leia Organa" } - } + data = new { luke = new { name = "Luke Skywalker" }, leia = new { name = "Leia Organa" } } }); [Fact] @@ -247,17 +211,7 @@ query CheckTypeOfR2{ name } } - ").ShouldEqual(new - { - data = new - { - hero = new - { - __typename = "Droid", - name = "R2-D2" - } - } - }); + ").ShouldEqual(new { data = new { hero = new { __typename = "Droid", name = "R2-D2" } } }); [Fact] public Task UsingTypenameToVerifyLukeIsAHuman() => @@ -268,17 +222,7 @@ query CheckTypeOfLuke { name } } - ").ShouldEqual(new - { - data = new - { - hero = new - { - __typename = "Human", - name = "Luke Skywalker" - } - } - }); + ").ShouldEqual(new { data = new { hero = new { __typename = "Human", name = "Luke Skywalker" } } }); [Fact] public Task CorrectlyReportsErrorOnAccessingSecretBackstory() @@ -292,23 +236,13 @@ query HeroNameQuery { } ").ShouldEqual(new { - data = new - { - hero = new - { - name = "R2-D2", - secretBackstory = (string?)null - } - }, + data = new { hero = new { name = "R2-D2", secretBackstory = (string?)null } }, errors = new object[] { new { message = "secretBackstory is secret", - locations = new object[] - { - new { line = 5, column = 17 } - }, + locations = new object[] { new { line = 5, column = 17 } }, path = new object[] { "hero", "secretBackstory" } } } @@ -330,58 +264,39 @@ query HeroNameQuery { } ").ShouldEqual(new { - data = new - { - hero = new + data = + new { - name = "R2-D2", - friends = new object[] + hero = new { - new - { - name = "Luke Skywalker", - secretBackstory = (string?)null - }, - new - { - name = "Han Solo", - secretBackstory = (string?)null - }, - new - { - name = "Leia Organa", - secretBackstory = (string?)null - } + name = "R2-D2", + friends = + new object[] + { + new { name = "Luke Skywalker", secretBackstory = (string?)null }, + new { name = "Han Solo", secretBackstory = (string?)null }, + new { name = "Leia Organa", secretBackstory = (string?)null } + } } - } - }, + }, errors = new object[] { new { message = "secretBackstory is secret", - locations = new object[] - { - new { line = 7, column = 19 } - }, + locations = new object[] { new { line = 7, column = 19 } }, path = new object[] { "hero", "friends", 0, "secretBackstory" } }, new { message = "secretBackstory is secret", - locations = new object[] - { - new { line = 7, column = 19 } - }, + locations = new object[] { new { line = 7, column = 19 } }, path = new object[] { "hero", "friends", 1, "secretBackstory" } }, new { message = "secretBackstory is secret", - locations = new object[] - { - new { line = 7, column = 19 } - }, + locations = new object[] { new { line = 7, column = 19 } }, path = new object[] { "hero", "friends", 2, "secretBackstory" } } } @@ -400,23 +315,13 @@ query HeroNameQuery { } ").ShouldEqual(new { - data = new - { - mainHero = new - { - name = "R2-D2", - story = (string?)null - } - }, + data = new { mainHero = new { name = "R2-D2", story = (string?)null } }, errors = new object[] { new { message = "secretBackstory is secret", - locations = new object[] - { - new { line = 5, column = 17 } - }, + locations = new object[] { new { line = 5, column = 17 } }, path = new object[] { "mainHero", "story" } } } diff --git a/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs b/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs index 981c237c4..77c566ffb 100644 --- a/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs +++ b/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs @@ -144,10 +144,7 @@ public class Droid : ICharacter private static Human Tarkin { get; } = new() { - Id = "1004", - Name = "Wilhuff Tarkin", - FriendIds = new[] { "1001" }, - AppearsIn = new[] { Episode.Empire } + Id = "1004", Name = "Wilhuff Tarkin", FriendIds = new[] { "1001" }, AppearsIn = new[] { Episode.Empire } }; private static readonly IReadOnlyDictionary HumanData = new Dictionary @@ -179,8 +176,7 @@ public class Droid : ICharacter private static readonly IReadOnlyDictionary DroidData = new Dictionary { - { "2000", ThreePio }, - { "2001", Artoo } + { "2000", ThreePio }, { "2001", Artoo } }; protected static Task GetCharacterAsync(string id) => @@ -275,16 +271,13 @@ public class Droid : ICharacter [Description("One of the films in the Star Wars Trilogy")] public enum Episode { - [Description("Released in 1977")] - [GraphQLName("NEW_HOPE")] + [Description("Released in 1977")] [GraphQLName("NEW_HOPE")] NewHope = 4, - [Description("Released in 1980")] - [GraphQLName("EMPIRE")] + [Description("Released in 1980")] [GraphQLName("EMPIRE")] Empire = 5, - [Description("Released in 1983")] - [GraphQLName("JEDI")] + [Description("Released in 1983")] [GraphQLName("JEDI")] Jedi = 6 } diff --git a/test/GraphZen.Tests/TypeSystem/IntrospectionTests/IntrospectionTests.cs b/test/GraphZen.Tests/TypeSystem/IntrospectionTests/IntrospectionTests.cs index a94c9deb4..7d36fbf60 100644 --- a/test/GraphZen.Tests/TypeSystem/IntrospectionTests/IntrospectionTests.cs +++ b/test/GraphZen.Tests/TypeSystem/IntrospectionTests/IntrospectionTests.cs @@ -43,12 +43,7 @@ await ExecuteAsync(schema, query, throwOnError: true) new JsonDiffOptions { SortBeforeCompare = true, - StringDiffOptions = - { - ShowExpected = false, - ShowActual = false, - ShowDiffs = true - } + StringDiffOptions = { ShowExpected = false, ShowActual = false, ShowDiffs = true } }); } } diff --git a/test/GraphZen.Tests/Utilities/AstFromValueTests.cs b/test/GraphZen.Tests/Utilities/AstFromValueTests.cs index 8bbf95716..a81dca7f4 100644 --- a/test/GraphZen.Tests/Utilities/AstFromValueTests.cs +++ b/test/GraphZen.Tests/Utilities/AstFromValueTests.cs @@ -170,20 +170,13 @@ public void ItConvertsInputObjects() { Assert.Equal(ObjectValue(ObjectField(Name("foo"), IntValue(3)), ObjectField(Name("bar"), EnumValue(Name("HELLO")))), - Get(Some(new - { - foo = 3, - bar = "HELLO" - }), MyInputObj)); + Get(Some(new { foo = 3, bar = "HELLO" }), MyInputObj)); } [Fact] public void ItConvertsInputObjectsWithExplicitNulls() { Assert.Equal(ObjectValue(ObjectField(Name("foo"), NullValue())), - Get(Some(new - { - foo = (string?)null - }), MyInputObj)); + Get(Some(new { foo = (string?)null }), MyInputObj)); } } diff --git a/test/GraphZen.Tests/Utilities/SdlSchemaConfiguratorTests.cs b/test/GraphZen.Tests/Utilities/SdlSchemaConfiguratorTests.cs index 982b42348..96db60f6b 100644 --- a/test/GraphZen.Tests/Utilities/SdlSchemaConfiguratorTests.cs +++ b/test/GraphZen.Tests/Utilities/SdlSchemaConfiguratorTests.cs @@ -22,13 +22,7 @@ type Query { } "); - return ExecuteAsync(schema, " { str } ", new { str = 123 }).ShouldEqual(new - { - data = new - { - str = "123" - } - }); + return ExecuteAsync(schema, " { str } ", new { str = 123 }).ShouldEqual(new { data = new { str = "123" } }); } @@ -41,18 +35,9 @@ type Query { } "); - var root = new - { - add = (Func)(args => args.x + args.y) - }; + var root = new { add = (Func)(args => args.x + args.y) }; - return ExecuteAsync(schema, "{ add(x: 34, y: 55) }", root).ShouldEqual(new - { - data = new - { - add = 89 - } - }); + return ExecuteAsync(schema, "{ add(x: 34, y: 55) }", root).ShouldEqual(new { data = new { add = 89 } }); } private static void ShouldRoundTrip(string sdl, StringDiffOptions? options = null) @@ -390,34 +375,12 @@ ... on Banana { { fruits = new object[] { - new - { - color = "green", - __typename = "Apple" - }, - new - { - length = 5, - __typename = "Banana" - } + new { color = "green", __typename = "Apple" }, new { length = 5, __typename = "Banana" } } }; await ExecuteAsync(schema, query, root).ShouldEqual(new { - data = new - { - fruits = new object[] - { - new - { - color = "green" - }, - new - { - length = 5 - } - } - } + data = new { fruits = new object[] { new { color = "green" }, new { length = 5 } } } }); } @@ -462,18 +425,8 @@ ... on Droid { { characters = new object[] { - new - { - name = "Han Solo", - totalCredits = 10, - __typename = "Human" - }, - new - { - name = "R2-D2", - primaryFunction = "Astromech", - __typename = "Droid" - } + new { name = "Han Solo", totalCredits = 10, __typename = "Human" }, + new { name = "R2-D2", primaryFunction = "Astromech", __typename = "Droid" } } }; @@ -483,16 +436,8 @@ await ExecuteAsync(schema, query, root).ShouldEqual(new { characters = new object[] { - new - { - name = "Han Solo", - totalCredits = 10 - }, - new - { - name = "R2-D2", - primaryFunction = "Astromech" - } + new { name = "Han Solo", totalCredits = 10 }, + new { name = "R2-D2", primaryFunction = "Astromech" } } } }); @@ -690,15 +635,7 @@ directive @test(arg: TestScalar) on FIELD var restoredSchemaAST = SyntaxFactory.Document( new ISyntaxConvertable[] { - schema, - query, - testInput, - testEnum, - testUnion, - testInterface, - testType, - testScalar, - testDirective! + schema, query, testInput, testEnum, testUnion, testInterface, testType, testScalar, testDirective! }.ToSyntaxNodes().ToArray() ); Assert.Equal(schemaAST.ToSyntaxString(), restoredSchemaAST.ToSyntaxString()); diff --git a/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs index 6503663e5..21cd69e19 100644 --- a/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs @@ -16,9 +16,9 @@ public class FieldArgumentsMustHaveInputTypesTests : ValidationRuleHarness public static IEnumerable GetInputTypeData(string typeName) { return from fieldsType in OutputFieldsTypes - from inputType in InputTypes - from fieldType in typeName.WithModifiers() - select new object[] { fieldsType, inputType, fieldType }; + from inputType in InputTypes + from fieldType in typeName.WithModifiers() + select new object[] { fieldsType, inputType, fieldType }; } [Theory] @@ -37,9 +37,9 @@ public void AcceptsInputTypeAsFieldArgType(string fieldsType, string inputType, public static IEnumerable GetNonInputTypeData(string typeName) { return from fieldsType in OutputFieldsTypes - from inputType in NonInputTypes - from fieldType in typeName.WithModifiers() - select new object[] { fieldsType, inputType, fieldType }; + from inputType in NonInputTypes + from fieldType in typeName.WithModifiers() + select new object[] { fieldsType, inputType, fieldType }; } [Theory] diff --git a/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs index d9f8105e3..37c545e8d 100644 --- a/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs @@ -15,9 +15,9 @@ public class InputObjectFieldsMustHaveInputTypesTests : ValidationRuleHarness public static IEnumerable GetValidInputFieldScenarios() { return from inputType in InputTypes - from fieldsType in InputFieldsTypes - from fieldType in "SomeInputType".WithModifiers() - select new object[] { inputType, fieldsType, fieldType }; + from fieldsType in InputFieldsTypes + from fieldType in "SomeInputType".WithModifiers() + select new object[] { inputType, fieldsType, fieldType }; } [Theory] @@ -36,9 +36,9 @@ public void AcceptsAnInputTypeAsAnInputFieldType(string inputType, string inputF public static IEnumerable GetInvalidInputFieldScenarios() { return from nonInputType in NonInputTypes - from inputFieldsType in InputFieldsTypes - from fieldType in "SomeOutputType".WithModifiers() - select new object[] { nonInputType, inputFieldsType, fieldType }; + from inputFieldsType in InputFieldsTypes + from fieldType in "SomeOutputType".WithModifiers() + select new object[] { nonInputType, inputFieldsType, fieldType }; } [Theory] diff --git a/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs index 9391ca637..77660ed45 100644 --- a/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs @@ -15,8 +15,8 @@ public class InterfaceFieldsMustHaveOutputTypesTests : ValidationRuleHarness public static IEnumerable GetValidInterfaceFieldTypeScenarios() { return from outputType in OutputTypes - from fieldType in "SomeOutputType".WithModifiers() - select new object[] { outputType, fieldType }; + from fieldType in "SomeOutputType".WithModifiers() + select new object[] { outputType, fieldType }; } [Theory] @@ -35,8 +35,8 @@ interface SomeInterface {{ public static IEnumerable GetInvalidInterfaceFieldTypeScenarios() { return from nonOutputType in NonOutputTypes - from fieldType in "SomeInputType".WithModifiers() - select new object[] { nonOutputType, fieldType }; + from fieldType in "SomeInputType".WithModifiers() + select new object[] { nonOutputType, fieldType }; } [Theory] diff --git a/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs index 1b0ad231e..39a1d5cb9 100644 --- a/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs @@ -14,8 +14,8 @@ public class ObjectFieldsMustHaveOutputTypesTests : ValidationRuleHarness public static IEnumerable GetValidFieldScenarios() { return from outputType in OutputTypes - from fieldType in "SomeOutputType".WithModifiers() - select new[] { outputType, fieldType }; + from fieldType in "SomeOutputType".WithModifiers() + select new[] { outputType, fieldType }; } [Theory] @@ -34,8 +34,8 @@ type SomeObject {{ public static IEnumerable GetInvalidFieldScenarios() { return from nonOutputType in NonOutputTypes - from fieldType in "SomeInputType".WithModifiers() - select new[] { nonOutputType, fieldType }; + from fieldType in "SomeInputType".WithModifiers() + select new[] { nonOutputType, fieldType }; } diff --git a/test/GraphZen.Tests/Validation/Rules/SdlValidationHelpers.cs b/test/GraphZen.Tests/Validation/Rules/SdlValidationHelpers.cs index ddee19d46..62a311eb9 100644 --- a/test/GraphZen.Tests/Validation/Rules/SdlValidationHelpers.cs +++ b/test/GraphZen.Tests/Validation/Rules/SdlValidationHelpers.cs @@ -5,8 +5,7 @@ namespace GraphZen.Tests.Validation.Rules; public static class SdlValidationHelpers { - public static readonly IReadOnlyList OutputTypes = new[] - { "scalar", "enum", "union", "interface", "type" }; + public static readonly IReadOnlyList OutputTypes = new[] { "scalar", "enum", "union", "interface", "type" }; public static readonly IReadOnlyList InputTypes = new[] { "scalar", "enum", "input" }; public static readonly IReadOnlyList NonInputTypes = new[] { "type", "union", "interface" }; diff --git a/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs b/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs index be72d243b..e7de78a6c 100644 --- a/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs +++ b/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs @@ -32,14 +32,14 @@ public static IEnumerable GetTypesImplementingOpenGenericType(Type openGen { var assembly = openGenericType.Assembly; return from x in assembly.GetTypes() - from z in x.GetInterfaces() - let y = x.BaseType - where - (y != null && y.IsGenericType && - openGenericType.IsAssignableFrom(y.GetGenericTypeDefinition())) || - (z.IsGenericType && - openGenericType.IsAssignableFrom(z.GetGenericTypeDefinition())) - where !isAbstract.HasValue || x.IsAbstract == isAbstract.Value - select x; + from z in x.GetInterfaces() + let y = x.BaseType + where + (y != null && y.IsGenericType && + openGenericType.IsAssignableFrom(y.GetGenericTypeDefinition())) || + (z.IsGenericType && + openGenericType.IsAssignableFrom(z.GetGenericTypeDefinition())) + where !isAbstract.HasValue || x.IsAbstract == isAbstract.Value + select x; } } diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs index b297b82c8..0e7eb0413 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs @@ -12,8 +12,7 @@ public class Schema_Directives_ViaObjectClrPropertyAttribute : Schema_Directives { public CollectionConventionContext GetContext() => new() { - ItemNamedByConvention = nameof(FieldDefinition), - ItemNamedByDataAnnotation = "hello" + ItemNamedByConvention = nameof(FieldDefinition), ItemNamedByDataAnnotation = "hello" }; public void ConfigureContextConventionally(SchemaBuilder sb) diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/Description/Enum_ViaClrEnum_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/Description/Enum_ViaClrEnum_Description.cs index 75355feea..ee3e8bc89 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/Description/Enum_ViaClrEnum_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/Description/Enum_ViaClrEnum_Description.cs @@ -17,11 +17,7 @@ public enum ExampleEnum public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = nameof(ExampleEnum), - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = nameof(ExampleEnum), DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs index 3986c32b5..8da859433 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs @@ -21,8 +21,7 @@ public enum ExampleEnum public LeafConventionContext GetContext() => new() { - ParentName = nameof(ExampleEnum.ExampleEnumValue), - DataAnnotationValue = DataAnnotationDescriptionValue + ParentName = nameof(ExampleEnum.ExampleEnumValue), DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/InputObjects/Description/InputObject_ViaClrClass_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/InputObjects/Description/InputObject_ViaClrClass_Description.cs index b2cda3a58..e8d59ffb9 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/InputObjects/Description/InputObject_ViaClrClass_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/InputObjects/Description/InputObject_ViaClrClass_Description.cs @@ -13,11 +13,7 @@ public class InputObject_ViaClrClass_Description : InputObject_Description, ILea public LeafConventionContext GetContext() => - new() - { - ParentName = nameof(ExampleInputObject), - DataAnnotationValue = DataAnnotationDescription - }; + new() { ParentName = nameof(ExampleInputObject), DataAnnotationValue = DataAnnotationDescription }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Description/Interface_ViaClrClass_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Description/Interface_ViaClrClass_Description.cs index 34efa5528..713fd2156 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Description/Interface_ViaClrClass_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Description/Interface_ViaClrClass_Description.cs @@ -12,11 +12,7 @@ public class Interface_ViaClrClass_Description : Interface_Description, ILeafCon public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = nameof(IExampleInterface), - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = nameof(IExampleInterface), DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Fields/Arguments/Description/Interface_Field_Argument_ViaClrMethod_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Fields/Arguments/Description/Interface_Field_Argument_ViaClrMethod_Description.cs index cdd826fd1..65be464f6 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Fields/Arguments/Description/Interface_Field_Argument_ViaClrMethod_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Interfaces/Fields/Arguments/Description/Interface_Field_Argument_ViaClrMethod_Description.cs @@ -13,11 +13,7 @@ public class Interface_Field_Argument_ViaClrMethod_Description : Interface_Field public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = "argName", - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = "argName", DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Description/Object_ViaClrClass_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Description/Object_ViaClrClass_Description.cs index 92f31a07d..4731f1b6b 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Description/Object_ViaClrClass_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Description/Object_ViaClrClass_Description.cs @@ -12,11 +12,7 @@ public class Object_ViaClrClass_Description : Object_Description, ILeafConventio public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = nameof(ExampleObject), - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = nameof(ExampleObject), DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Fields/Arguments/Description/Object_Field_Argument_ViaClrMethod_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Fields/Arguments/Description/Object_Field_Argument_ViaClrMethod_Description.cs index 01d086451..711f48fd4 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Fields/Arguments/Description/Object_Field_Argument_ViaClrMethod_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Objects/Fields/Arguments/Description/Object_Field_Argument_ViaClrMethod_Description.cs @@ -13,11 +13,7 @@ public class Object_Field_Argument_ViaClrMethod_Description : Object_Field_Argum public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = "argName", - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = "argName", DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Scalars/Description/Scalar_ViaClrClass_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Scalars/Description/Scalar_ViaClrClass_Description.cs index a5c8767f8..2c2f1ac9c 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Scalars/Description/Scalar_ViaClrClass_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Scalars/Description/Scalar_ViaClrClass_Description.cs @@ -12,11 +12,7 @@ public class Scalar_ViaClrClass_Description : Scalar_Description, ILeafConventio public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = nameof(ExampleScalar), - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = nameof(ExampleScalar), DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrClass_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrClass_Description.cs index 4ad1675db..2837b07b3 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrClass_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrClass_Description.cs @@ -12,11 +12,7 @@ public class Union_ViaClrClass_Description : Union_Description, ILeafConventionC public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = nameof(ExampleUnion), - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = nameof(ExampleUnion), DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrMarkerInterface_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrMarkerInterface_Description.cs index 62e67a842..cfb188c37 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrMarkerInterface_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Unions/Description/Union_ViaClrMarkerInterface_Description.cs @@ -12,11 +12,7 @@ public class Union_ViaClrMarkerInterface_Description : Union_Description, ILeafC public const string DataAnnotationDescriptionValue = nameof(DataAnnotationDescriptionValue); public LeafConventionContext GetContext() => - new() - { - ParentName = nameof(IExampleUnion), - DataAnnotationValue = DataAnnotationDescriptionValue - }; + new() { ParentName = nameof(IExampleUnion), DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb) { diff --git a/test/GraphZen.TypeSystem.Tests/SchemaToSyntaxTests.cs b/test/GraphZen.TypeSystem.Tests/SchemaToSyntaxTests.cs index 4c147d834..696e82fb0 100644 --- a/test/GraphZen.TypeSystem.Tests/SchemaToSyntaxTests.cs +++ b/test/GraphZen.TypeSystem.Tests/SchemaToSyntaxTests.cs @@ -66,10 +66,7 @@ public void object_type_to_sytnax_node() var expected = new ObjectTypeDefinitionSyntax( Name("Object"), Description("object description") - , new[] - { - NamedType(Name("Interface")) - }, null, new[] + , new[] { NamedType(Name("Interface")) }, null, new[] { new FieldDefinitionSyntax(Name("field"), NamedType(Name("String")), @@ -95,10 +92,7 @@ public void interface_type_to_syntax_node() var objectType = Schema.GetType("Interface"); var expected = new InterfaceTypeDefinitionSyntax( Name("Interface"), - StringValue("interface description", true), new[] - { - Directive(Name("onInterface")) - }, new[] + StringValue("interface description", true), new[] { Directive(Name("onInterface")) }, new[] { new FieldDefinitionSyntax(Name("field"), NamedType(Name("String")), diff --git a/test/GraphZen.TypeSystem.Tests/TaxonomyTests.cs b/test/GraphZen.TypeSystem.Tests/TaxonomyTests.cs index bf87eeb45..fe5f76d46 100644 --- a/test/GraphZen.TypeSystem.Tests/TaxonomyTests.cs +++ b/test/GraphZen.TypeSystem.Tests/TaxonomyTests.cs @@ -14,20 +14,10 @@ public void graphql_type_references(Type type) var types = ClrTypeUtils.GetImplementedTypes(type).DumpTypes(); var expected = new[] { - typeof(EnumType), - typeof(EnumTypeDefinition), - typeof(InputObjectType), - typeof(InputObjectTypeDefinition), - typeof(InterfaceType), - typeof(InterfaceTypeDefinition), - typeof(ListType), - typeof(NonNullType), - typeof(ObjectType), - typeof(ObjectTypeDefinition), - typeof(ScalarType), - typeof(ScalarTypeDefinition), - typeof(TypeReference), - typeof(UnionType), + typeof(EnumType), typeof(EnumTypeDefinition), typeof(InputObjectType), + typeof(InputObjectTypeDefinition), typeof(InterfaceType), typeof(InterfaceTypeDefinition), + typeof(ListType), typeof(NonNullType), typeof(ObjectType), typeof(ObjectTypeDefinition), + typeof(ScalarType), typeof(ScalarTypeDefinition), typeof(TypeReference), typeof(UnionType), typeof(UnionTypeDefinition) }; @@ -41,18 +31,10 @@ public void graphql_type_definitions(Type type) var types = ClrTypeUtils.GetImplementedTypes(type).DumpTypes(); var expected = new[] { - typeof(EnumType), - typeof(EnumTypeDefinition), - typeof(InputObjectType), - typeof(InputObjectTypeDefinition), - typeof(InterfaceType), - typeof(InterfaceTypeDefinition), - typeof(ObjectType), - typeof(ObjectTypeDefinition), - typeof(ScalarType), - typeof(ScalarTypeDefinition), - typeof(UnionType), - typeof(UnionTypeDefinition) + typeof(EnumType), typeof(EnumTypeDefinition), typeof(InputObjectType), + typeof(InputObjectTypeDefinition), typeof(InterfaceType), typeof(InterfaceTypeDefinition), + typeof(ObjectType), typeof(ObjectTypeDefinition), typeof(ScalarType), typeof(ScalarTypeDefinition), + typeof(UnionType), typeof(UnionTypeDefinition) }; Assert.Equal(expected, types); @@ -65,14 +47,8 @@ public void graphql_types(Type type) var types = ClrTypeUtils.GetImplementedTypes(type).DumpTypes(); var expected = new[] { - typeof(EnumType), - typeof(InputObjectType), - typeof(InterfaceType), - typeof(ListType), - typeof(NonNullType), - typeof(ObjectType), - typeof(ScalarType), - typeof(UnionType) + typeof(EnumType), typeof(InputObjectType), typeof(InterfaceType), typeof(ListType), typeof(NonNullType), + typeof(ObjectType), typeof(ScalarType), typeof(UnionType) }; Assert.Equal(expected, types); @@ -87,12 +63,8 @@ public void graphql_named_types(Type type) var expected = new[] { - typeof(EnumType), - typeof(InputObjectType), - typeof(InterfaceType), - typeof(ObjectType), - typeof(ScalarType), - typeof(UnionType) + typeof(EnumType), typeof(InputObjectType), typeof(InterfaceType), typeof(ObjectType), + typeof(ScalarType), typeof(UnionType) }; Assert.Equal(expected, types); @@ -106,18 +78,10 @@ public void named_type_definitions(Type type) var expected = new[] { - typeof(EnumType), - typeof(EnumTypeDefinition), - typeof(InputObjectType), - typeof(InputObjectTypeDefinition), - typeof(InterfaceType), - typeof(InterfaceTypeDefinition), - typeof(ObjectType), - typeof(ObjectTypeDefinition), - typeof(ScalarType), - typeof(ScalarTypeDefinition), - typeof(UnionType), - typeof(UnionTypeDefinition) + typeof(EnumType), typeof(EnumTypeDefinition), typeof(InputObjectType), + typeof(InputObjectTypeDefinition), typeof(InterfaceType), typeof(InterfaceTypeDefinition), + typeof(ObjectType), typeof(ObjectTypeDefinition), typeof(ScalarType), typeof(ScalarTypeDefinition), + typeof(UnionType), typeof(UnionTypeDefinition) }; Assert.Equal(expected, types); @@ -134,15 +98,8 @@ public void ClrTypes(Type type) var expected = new[] { - typeof(EnumType), - typeof(EnumValue), - typeof(Field), - typeof(InputObjectType), - typeof(InputValue), - typeof(InterfaceType), - typeof(ObjectType), - typeof(ScalarType), - typeof(UnionType) + typeof(EnumType), typeof(EnumValue), typeof(Field), typeof(InputObjectType), typeof(InputValue), + typeof(InterfaceType), typeof(ObjectType), typeof(ScalarType), typeof(UnionType) }; Assert.Equal(expected, types); @@ -157,15 +114,8 @@ public void TypeDescriptions(Type type) var expected = new[] { - typeof(EnumType), - typeof(EnumValue), - typeof(Field), - typeof(InputObjectType), - typeof(InputValue), - typeof(InterfaceType), - typeof(ObjectType), - typeof(ScalarType), - typeof(UnionType) + typeof(EnumType), typeof(EnumValue), typeof(Field), typeof(InputObjectType), typeof(InputValue), + typeof(InterfaceType), typeof(ObjectType), typeof(ScalarType), typeof(UnionType) }; Assert.Equal(expected, types); @@ -178,10 +128,7 @@ public void AbstractTypeDefinitions() var expected = new[] { - typeof(InterfaceType), - typeof(InterfaceTypeDefinition), - typeof(UnionType), - typeof(UnionTypeDefinition) + typeof(InterfaceType), typeof(InterfaceTypeDefinition), typeof(UnionType), typeof(UnionTypeDefinition) }; Assert.Equal(expected, types); @@ -192,11 +139,7 @@ public void AbstractTypes() { var types = ClrTypeUtils.GetImplementedTypes(typeof(IAbstractType)); - var expected = new[] - { - typeof(InterfaceType), - typeof(UnionType) - }; + var expected = new[] { typeof(InterfaceType), typeof(UnionType) }; Assert.Equal(expected, types); } @@ -209,17 +152,9 @@ public void Annotated() var expected = new[] { - typeof(AnnotatableMemberDefinition), - typeof(EnumType), - typeof(EnumValue), - typeof(Field), - typeof(InputObjectType), - typeof(InputValue), - typeof(InterfaceType), - typeof(ObjectType), - typeof(ScalarType), - typeof(Schema), - typeof(UnionType) + typeof(AnnotatableMemberDefinition), typeof(EnumType), typeof(EnumValue), typeof(Field), + typeof(InputObjectType), typeof(InputValue), typeof(InterfaceType), typeof(ObjectType), + typeof(ScalarType), typeof(Schema), typeof(UnionType) }; Assert.Equal(expected, types); @@ -232,12 +167,8 @@ public void CompositeTypeDefinitions() var expected = new[] { - typeof(InterfaceType), - typeof(InterfaceTypeDefinition), - typeof(ObjectType), - typeof(ObjectTypeDefinition), - typeof(UnionType), - typeof(UnionTypeDefinition) + typeof(InterfaceType), typeof(InterfaceTypeDefinition), typeof(ObjectType), + typeof(ObjectTypeDefinition), typeof(UnionType), typeof(UnionTypeDefinition) }; Assert.Equal(expected, types); @@ -249,12 +180,7 @@ public void CompositeTypes() { var types = ClrTypeUtils.GetImplementedTypes(typeof(ICompositeType)); - var expected = new[] - { - typeof(InterfaceType), - typeof(ObjectType), - typeof(UnionType) - }; + var expected = new[] { typeof(InterfaceType), typeof(ObjectType), typeof(UnionType) }; Assert.Equal(expected, types); } @@ -267,10 +193,7 @@ public void LeafTypeDefinitions() var expected = new[] { - typeof(EnumType), - typeof(EnumTypeDefinition), - typeof(ScalarType), - typeof(ScalarTypeDefinition) + typeof(EnumType), typeof(EnumTypeDefinition), typeof(ScalarType), typeof(ScalarTypeDefinition) }; Assert.Equal(expected, types); @@ -281,11 +204,7 @@ public void LeafTypes() { var types = ClrTypeUtils.GetImplementedTypes(typeof(ILeafType)); - var expected = new[] - { - typeof(EnumType), - typeof(ScalarType) - }; + var expected = new[] { typeof(EnumType), typeof(ScalarType) }; Assert.Equal(expected, types); } @@ -298,13 +217,8 @@ public void NullableTypes() var expected = new[] { - typeof(EnumType), - typeof(InputObjectType), - typeof(InterfaceType), - typeof(ListType), - typeof(ObjectType), - typeof(ScalarType), - typeof(UnionType) + typeof(EnumType), typeof(InputObjectType), typeof(InterfaceType), typeof(ListType), typeof(ObjectType), + typeof(ScalarType), typeof(UnionType) }; Assert.Equal(expected, types); From 8f3eccf6f06e49efd57c6895e2ce21422c1df75d Mon Sep 17 00:00:00 2001 From: Craig Smitham Date: Thu, 23 Apr 2026 22:04:00 -0500 Subject: [PATCH 3/3] Apply dotnet format to fix formatting inconsistencies Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Infrastructure/Check.cs | 2 +- .../LanguageModel/DirectiveLocation.cs | 54 +++++++++----- .../GraphZenServiceCollectionExtensions.cs | 2 +- .../Grammar/DirectiveDefinitionsGrammar.cs | 26 +++---- .../Internal/Grammar/DirectiveGrammar.cs | 8 +-- .../Internal/Grammar/DocumentGrammar.cs | 18 ++--- .../Grammar/EnumTypeDefinitionGrammar.cs | 26 +++---- .../Grammar/EnumTypeExtensionGrammar.cs | 22 +++--- .../Internal/Grammar/FieldGrammar.cs | 36 +++++----- .../Internal/Grammar/FragmentGrammar.cs | 40 +++++------ .../LanguageModel/Internal/Grammar/Grammar.cs | 14 ++-- .../InputObjectTypeExtensionGrammar.cs | 22 +++--- .../Grammar/InputObjectTypeGrammar.cs | 18 ++--- .../Internal/Grammar/InputTypeGrammar.cs | 16 ++--- .../Internal/Grammar/InputValuesGrammar.cs | 24 +++---- .../Grammar/InterfaceTypeDefinitionGrammar.cs | 12 ++-- .../Grammar/InterfaceTypeExtensionGrammar.cs | 12 ++-- .../Grammar/ObjectTypeDefinitionGrammar.cs | 70 +++++++++---------- .../Grammar/ObjectTypeExtensionGrammar.cs | 38 +++++----- .../Grammar/OperationDefinitionGrammar.cs | 26 +++---- .../Grammar/ScalarTypeExtensionGrammar.cs | 10 +-- .../Internal/Grammar/ScalarTypeGrammar.cs | 10 +-- .../Grammar/SchemaExtensionGrammar.cs | 12 ++-- .../Internal/Grammar/SchemaGrammar.cs | 22 +++--- .../Internal/Grammar/SelectionSetGrammar.cs | 8 +-- .../Grammar/UnionTypeDefinitionGrammar.cs | 12 ++-- .../Grammar/UnionTypeExtensionGrammar.cs | 10 +-- .../Internal/Grammar/VariablesGrammar.cs | 22 +++--- .../LanguageModel/Internal/Printer.cs | 2 +- .../TypeSystem/TypeKind.cs | 18 +++-- .../QueryEngine/UnionInterfaceTests.cs | 4 +- .../QueryEngine/Variables/UsingVariables.cs | 8 +-- .../StarWars/StarWarsIntrospectionTest.cs | 3 +- .../StarWars/StarWarsSchemaAndData.cs | 14 ++-- .../FieldArgumentsMustHaveInputTypesTests.cs | 12 ++-- ...nputObjectFieldsMustHaveInputTypesTests.cs | 12 ++-- ...InterfaceFieldsMustHaveOutputTypesTests.cs | 8 +-- .../ObjectFieldsMustHaveOutputTypesTests.cs | 8 +-- .../GraphZen.TypeSystem.Tests/ClrTypeUtils.cs | 18 ++--- ...irectives_ViaObjectClrPropertyAttribute.cs | 3 +- .../EnumValue_ViaClrEnumValue_Description.cs | 3 +- 41 files changed, 370 insertions(+), 335 deletions(-) diff --git a/src/GraphZen.Abstractions/Infrastructure/Check.cs b/src/GraphZen.Abstractions/Infrastructure/Check.cs index 6b57ede77..fccdca7bc 100644 --- a/src/GraphZen.Abstractions/Infrastructure/Check.cs +++ b/src/GraphZen.Abstractions/Infrastructure/Check.cs @@ -10,7 +10,7 @@ internal static class Check { [ContractAnnotation("value:null => halt")] [return: NotNull] - public static T NotNull([NotNull] [NoEnumeration] T value, [InvokerParameterName] string parameterName) + public static T NotNull([NotNull][NoEnumeration] T value, [InvokerParameterName] string parameterName) { if (value is null) { diff --git a/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs b/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs index c366b2e78..d3340ebc0 100644 --- a/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs +++ b/src/GraphZen.Abstractions/LanguageModel/DirectiveLocation.cs @@ -12,57 +12,75 @@ namespace GraphZen.LanguageModel; [GraphQLName("__DirectiveLocation")] public enum DirectiveLocation { - [Description("Location adjacent to a query operation.")] [GraphQLName("QUERY")] + [Description("Location adjacent to a query operation.")] + [GraphQLName("QUERY")] Query, - [Description("Location adjacent to a mutation operation.")] [GraphQLName("MUTATION")] + [Description("Location adjacent to a mutation operation.")] + [GraphQLName("MUTATION")] Mutation, - [Description("Location adjacent to a subscription operation.")] [GraphQLName("SUBSCRIPTION")] + [Description("Location adjacent to a subscription operation.")] + [GraphQLName("SUBSCRIPTION")] Subscription, - [Description("Location adjacent to a field.")] [GraphQLName("FIELD")] + [Description("Location adjacent to a field.")] + [GraphQLName("FIELD")] Field, - [Description("Location adjacent to a fragment definition.")] [GraphQLName("FRAGMENT_DEFINITION")] + [Description("Location adjacent to a fragment definition.")] + [GraphQLName("FRAGMENT_DEFINITION")] FragmentDefinition, - [Description("Location adjacent to a fragment spread.")] [GraphQLName("FRAGMENT_SPREAD")] + [Description("Location adjacent to a fragment spread.")] + [GraphQLName("FRAGMENT_SPREAD")] FragmentSpread, - [Description("Location adjacent to an inline fragment.")] [GraphQLName("INLINE_FRAGMENT")] + [Description("Location adjacent to an inline fragment.")] + [GraphQLName("INLINE_FRAGMENT")] InlineFragment, - [Description("Location adjacent to a schema definition.")] [GraphQLName("SCHEMA")] + [Description("Location adjacent to a schema definition.")] + [GraphQLName("SCHEMA")] Schema, - [Description("Location adjacent to a scalar definition.")] [GraphQLName("SCALAR")] + [Description("Location adjacent to a scalar definition.")] + [GraphQLName("SCALAR")] Scalar, - [Description("Location adjacent to an object type definition.")] [GraphQLName("OBJECT")] + [Description("Location adjacent to an object type definition.")] + [GraphQLName("OBJECT")] Object, - [Description("Location adjacent to a field Definition.")] [GraphQLName("FIELD_DEFINITION")] + [Description("Location adjacent to a field Definition.")] + [GraphQLName("FIELD_DEFINITION")] FieldDefinition, - [Description("Location adjacent to an argument definition.")] [GraphQLName("ARGUMENT_DEFINITION")] + [Description("Location adjacent to an argument definition.")] + [GraphQLName("ARGUMENT_DEFINITION")] ArgumentDefinition, - [Description("Location adjacent to an interface definition.")] [GraphQLName("INTERFACE")] + [Description("Location adjacent to an interface definition.")] + [GraphQLName("INTERFACE")] Interface, - [Description("Location adjacent to a union Definition.")] [GraphQLName("UNION")] + [Description("Location adjacent to a union Definition.")] + [GraphQLName("UNION")] Union, - [Description("Location adjacent to an enum definition.")] [GraphQLName("ENUM")] + [Description("Location adjacent to an enum definition.")] + [GraphQLName("ENUM")] Enum, - [Description("Location adjacent to an enum value definition.")] [GraphQLName("ENUM_VALUE")] + [Description("Location adjacent to an enum value definition.")] + [GraphQLName("ENUM_VALUE")] EnumValue, - [Description("Location adjacent to an input object type Definition.")] [GraphQLName("INPUT_OBJECT")] + [Description("Location adjacent to an input object type Definition.")] + [GraphQLName("INPUT_OBJECT")] InputObject, - [Description("Location adjacent to an input object field definition.")] [GraphQLName("INPUT_FIELD_DEFINITION")] + [Description("Location adjacent to an input object field definition.")] + [GraphQLName("INPUT_FIELD_DEFINITION")] InputFieldDefinition } diff --git a/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs b/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs index 2b76c435d..42b13c8a6 100644 --- a/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs +++ b/src/GraphZen.AspNetCore.Server/GraphZenServiceCollectionExtensions.cs @@ -31,7 +31,7 @@ public static void AddGraphQLContext( optionsAction != null // ReSharper disable once ConstantConditionalAccessQualifier ? (p, b) => { optionsAction?.Invoke(b); } - : (Action?)null; + : (Action?)null; var contextType = typeof(TContext); if (optionsAction != null) diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs index 8cd773a19..9e944f524 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveDefinitionsGrammar.cs @@ -12,17 +12,17 @@ internal static partial class Grammar /// private static TokenListParser DirectiveDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from directive in Keyword("directive")! - from at in AtSymbol! - from name in Name! - from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() - from @on in Keyword("on")! - from locations in DirectiveLocations! - select new DirectiveDefinitionSyntax(name!, locations!, desc, args, - SyntaxLocation.FromMany(desc, directive, at, name!, - args?.GetLocation() - , @on, - locations!.GetLocation()))) + from directive in Keyword("directive")! + from at in AtSymbol! + from name in Name! + from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() + from @on in Keyword("on")! + from locations in DirectiveLocations! + select new DirectiveDefinitionSyntax(name!, locations!, desc, args, + SyntaxLocation.FromMany(desc, directive, at, name!, + args?.GetLocation() + , @on, + locations!.GetLocation()))) .Try() .Named("directive definition"); @@ -31,8 +31,8 @@ from locations in DirectiveLocations! /// private static TokenListParser DirectiveLocations { get; } = (from pipe in Parse.Ref(() => Pipe!).AsNullable().OptionalOrDefault() - from locations in DirectiveLocation!.ManyDelimitedBy(Pipe!) - select locations) + from locations in DirectiveLocation!.ManyDelimitedBy(Pipe!) + select locations) .Try() .Named("directive locations"); diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs index c51e9ae75..242382e4d 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DirectiveGrammar.cs @@ -18,9 +18,9 @@ internal static partial class Grammar /// internal static TokenListParser Directive { get; } = (from at in Parse.Ref(() => AtSymbol!.Named("directive symbol")) - from name in Name!.Named("directive name") - from args in Arguments!.AsNullable().OptionalOrDefault().Named("directive arguments") - select new DirectiveSyntax(name!, args, - SyntaxLocation.FromMany(at, name!, args.GetLocation()))).Try() + from name in Name!.Named("directive name") + from args in Arguments!.AsNullable().OptionalOrDefault().Named("directive arguments") + select new DirectiveSyntax(name!, args, + SyntaxLocation.FromMany(at, name!, args.GetLocation()))).Try() .Named("directive"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs index a85b17ab0..2f0a1ff01 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/DocumentGrammar.cs @@ -13,10 +13,10 @@ internal static partial class Grammar /// internal static TokenListParser Document { get; } = (from leadingComments in Parse.Ref(() => Comment!.Many()) - from definitions in Parse.Ref(() => Definition!).Many() - from trailingComments in Comment!.Many() - select new DocumentSyntax(definitions, - definitions.GetLocation().Location)) + from definitions in Parse.Ref(() => Definition!).Many() + from trailingComments in Comment!.Many() + select new DocumentSyntax(definitions, + definitions.GetLocation().Location)) .Named("document"); /// @@ -24,11 +24,11 @@ from definitions in Parse.Ref(() => Definition!).Many() /// private static TokenListParser Definition { get; } = (from leadingComments in Parse.Ref(() => Comment!.Many()) - from def in ExecutableDefinition!.Select(_ => (DefinitionSyntax)_) - .Or(TypeSystemDefinition!.Select(_ => (DefinitionSyntax)_)) - .Or(TypeSystemExtension!.Select(_ => (DefinitionSyntax)_)) - from trailingComments in Comment!.Many() - select def) + from def in ExecutableDefinition!.Select(_ => (DefinitionSyntax)_) + .Or(TypeSystemDefinition!.Select(_ => (DefinitionSyntax)_)) + .Or(TypeSystemExtension!.Select(_ => (DefinitionSyntax)_)) + from trailingComments in Comment!.Many() + select def) .Named("definition"); /// diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs index 093c4c366..889733ba1 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeDefinitionGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser EnumTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from @enum in Keyword("enum")! - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from values in EnumValuesDefinition!.AsNullable().OptionalOrDefault() - select new EnumTypeDefinitionSyntax(name!, desc, directives, values, - SyntaxLocation.FromMany(desc, @enum, name!, directives.GetLocation(), values.GetLocation()))) + from @enum in Keyword("enum")! + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from values in EnumValuesDefinition!.AsNullable().OptionalOrDefault() + select new EnumTypeDefinitionSyntax(name!, desc, directives, values, + SyntaxLocation.FromMany(desc, @enum, name!, directives.GetLocation(), values.GetLocation()))) .Named("enum type definition"); /// @@ -25,9 +25,9 @@ from directives in Directives.AsNullable().OptionalOrDefault() /// private static TokenListParser EnumValuesDefinition { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from values in EnumValueDefinition!.Many() - from rb in RightBrace! - select values) + from values in EnumValueDefinition!.Many() + from rb in RightBrace! + select values) .Try() .Named("enum values"); @@ -36,10 +36,10 @@ from rb in RightBrace! /// private static TokenListParser EnumValueDefinition { get; } = (from desc in Parse.Ref(() => Description!.AsNullable().OptionalOrDefault()) - from value in EnumValue! - from directives in Directives.AsNullable().OptionalOrDefault() - select new EnumValueDefinitionSyntax(value!, desc, directives, - SyntaxLocation.FromMany(desc, value!, directives.GetLocation()))) + from value in EnumValue! + from directives in Directives.AsNullable().OptionalOrDefault() + select new EnumValueDefinitionSyntax(value!, desc, directives, + SyntaxLocation.FromMany(desc, value!, directives.GetLocation()))) .Try() .Named("enum value"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs index 5ad529cee..fe79e0ef8 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/EnumTypeExtensionGrammar.cs @@ -13,18 +13,18 @@ internal static partial class Grammar /// private static TokenListParser EnumTypeExtension { get; } = (from extend in Keyword("extend") - from @enum in Keyword("enum")! - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from values in EnumValuesDefinition - select new EnumTypeExtensionSyntax(name!, directives, values!, - SyntaxLocation.FromMany(extend, name!, directives.GetLocation(), values!.GetLocation()))).Try() + from @enum in Keyword("enum")! + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from values in EnumValuesDefinition + select new EnumTypeExtensionSyntax(name!, directives, values!, + SyntaxLocation.FromMany(extend, name!, directives.GetLocation(), values!.GetLocation()))).Try() .Or((from extend in Keyword("extend") - from @enum in Keyword("enum")! - from name in Name! - from directives in Directives - select new EnumTypeExtensionSyntax(name!, directives!, null!, - SyntaxLocation.FromMany(extend, name!, directives!.GetLocation()))).Try()) + from @enum in Keyword("enum")! + from name in Name! + from directives in Directives + select new EnumTypeExtensionSyntax(name!, directives!, null!, + SyntaxLocation.FromMany(extend, name!, directives!.GetLocation()))).Try()) .Try() .Named("enum type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs index 6054132c7..cef58952b 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FieldGrammar.cs @@ -10,24 +10,24 @@ internal static partial class Grammar { internal static TokenListParser Field { get; } = (from firstName in Parse.Ref(() => Name!.AsNullable().OptionalOrDefault()) - from aliasedName in (from colon in Colon - from aliasedName in Name! - select aliasedName).AsNullable().OptionalOrDefault() - from arguments in Arguments!.AsNullable().OptionalOrDefault().Named("field arguments") - from directives in Directives.AsNullable().OptionalOrDefault().Named("field directives") - from selectionSet in SelectionSet!.AsNullable().OptionalOrDefault().Named("field selections") - let alias = aliasedName != null ? firstName : null - let name = aliasedName ?? firstName - where firstName != null - select new FieldSyntax(name!, - alias, - arguments, - directives, - selectionSet, - SyntaxLocation.FromMany(alias!, name!, arguments?.GetLocation(), - selectionSet, - directives?.GetLocation() - ))) + from aliasedName in (from colon in Colon + from aliasedName in Name! + select aliasedName).AsNullable().OptionalOrDefault() + from arguments in Arguments!.AsNullable().OptionalOrDefault().Named("field arguments") + from directives in Directives.AsNullable().OptionalOrDefault().Named("field directives") + from selectionSet in SelectionSet!.AsNullable().OptionalOrDefault().Named("field selections") + let alias = aliasedName != null ? firstName : null + let name = aliasedName ?? firstName + where firstName != null + select new FieldSyntax(name!, + alias, + arguments, + directives, + selectionSet, + SyntaxLocation.FromMany(alias!, name!, arguments?.GetLocation(), + selectionSet, + directives?.GetLocation() + ))) .Try() .Named("field"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs index 241d55773..5e744a27e 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/FragmentGrammar.cs @@ -10,43 +10,43 @@ internal static partial class Grammar { private static TokenListParser TypeCondition { get; } = (from @on in Keyword("on") - from type in NamedType! - select type!) + from type in NamedType! + select type!) .Try() .Named("type condition"); private static TokenListParser FragmentName { get; } = (from name in Parse.Ref(() => Name!) - where !name.Value.Equals("on", StringComparison.OrdinalIgnoreCase) - select name) + where !name.Value.Equals("on", StringComparison.OrdinalIgnoreCase) + select name) .Try() .Named("fragment name"); internal static TokenListParser FragmentSpread { get; } = (from spread in Parse.Ref(() => Spread!) - from name in FragmentName.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - where name != null - select new FragmentSpreadSyntax(name, directives, - SyntaxLocation.FromMany(spread, name, directives.GetLocation()))) + from name in FragmentName.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + where name != null + select new FragmentSpreadSyntax(name, directives, + SyntaxLocation.FromMany(spread, name, directives.GetLocation()))) .Try() .Named("fragment spread"); internal static TokenListParser InlineFragment => (from spread in Spread - from typeCondition in TypeCondition.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from selectionSet in SelectionSet - select new InlineFragmentSyntax(selectionSet!, typeCondition, directives, - new SyntaxLocation(spread, selectionSet!))).Named("inline fragment"); + from typeCondition in TypeCondition.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from selectionSet in SelectionSet + select new InlineFragmentSyntax(selectionSet!, typeCondition, directives, + new SyntaxLocation(spread, selectionSet!))).Named("inline fragment"); internal static TokenListParser FragmentDefinition => (from fragment in Keyword("fragment") - from fragmentName in FragmentName - from type in TypeCondition.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from selectionSet in SelectionSet - select new FragmentDefinitionSyntax(fragmentName!, type, selectionSet!, directives, - new SyntaxLocation(fragment, selectionSet!))).Named("fragment definition"); + from fragmentName in FragmentName + from type in TypeCondition.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from selectionSet in SelectionSet + select new FragmentDefinitionSyntax(fragmentName!, type, selectionSet!, directives, + new SyntaxLocation(fragment, selectionSet!))).Named("fragment definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs index 4f328130b..926808acd 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/Grammar.cs @@ -12,10 +12,10 @@ internal static partial class Grammar /// internal static TokenListParser Argument { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from name in Parse.Ref(() => Name!.Named("argument name")) - from colon in Colon! - from value in Value!.Named("argument value") - select new ArgumentSyntax(name!, desc, value, SyntaxLocation.FromMany(name!, value))).Try() + from name in Parse.Ref(() => Name!.Named("argument name")) + from colon in Colon! + from value in Value!.Named("argument value") + select new ArgumentSyntax(name!, desc, value, SyntaxLocation.FromMany(name!, value))).Try() .Named("argument"); /// @@ -23,8 +23,8 @@ from colon in Colon! /// internal static TokenListParser Arguments { get; } = (from lp in Parse.Ref(() => LeftParen!) - from args in Argument!.Many() - from rp in RightParen! - select args).Try() + from args in Argument!.Many() + from rp in RightParen! + select args).Try() .Named("arguments"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs index 709fd59de..30277cca7 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeExtensionGrammar.cs @@ -12,19 +12,19 @@ internal static partial class Grammar /// private static TokenListParser InputObjectTypeExtension { get; } = (from extend in Keyword("extend") - from input in Keyword("input") - from name in Parse.Ref(() => Name!) - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in InputFieldsDefinition! - select new InputObjectTypeExtensionSyntax(name!, directives, fields!, - SyntaxLocation.FromMany(extend, fields!.GetLocation()))) + from input in Keyword("input") + from name in Parse.Ref(() => Name!) + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in InputFieldsDefinition! + select new InputObjectTypeExtensionSyntax(name!, directives, fields!, + SyntaxLocation.FromMany(extend, fields!.GetLocation()))) .Try().Or ((from extend in Keyword("extend") - from input in Keyword("input") - from name in Parse.Ref(() => Name!) - from directives in Directives - select new InputObjectTypeExtensionSyntax(name!, directives!, null, - SyntaxLocation.FromMany(extend, directives!.GetLocation()))) + from input in Keyword("input") + from name in Parse.Ref(() => Name!) + from directives in Directives + select new InputObjectTypeExtensionSyntax(name!, directives!, null, + SyntaxLocation.FromMany(extend, directives!.GetLocation()))) .Try()) .Named("input object type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs index 9c85aef38..dc3f4f02e 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputObjectTypeGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser InputObjectTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from input in Keyword("input")! - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in InputFieldsDefinition!.AsNullable().OptionalOrDefault() - select new InputObjectTypeDefinitionSyntax(name!, desc, directives, fields, - SyntaxLocation.FromMany(desc, input, name!, directives.GetLocation(), fields.GetLocation()))) + from input in Keyword("input")! + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in InputFieldsDefinition!.AsNullable().OptionalOrDefault() + select new InputObjectTypeDefinitionSyntax(name!, desc, directives, fields, + SyntaxLocation.FromMany(desc, input, name!, directives.GetLocation(), fields.GetLocation()))) .Named("input object type definition"); /// @@ -25,9 +25,9 @@ from directives in Directives.AsNullable().OptionalOrDefault() /// private static TokenListParser InputFieldsDefinition { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from values in InputValueDefinition!.Many() - from rb in RightBrace! - select values) + from values in InputValueDefinition!.Many() + from rb in RightBrace! + select values) .Try() .Named("input fields definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs index 4abb5de0a..9296a867a 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputTypeGrammar.cs @@ -9,14 +9,14 @@ internal static partial class Grammar { private static TokenListParser NamedType { get; } = (from name in Parse.Ref(() => Name!) - select new NamedTypeSyntax(name, name.Location)) + select new NamedTypeSyntax(name, name.Location)) .Named("named type"); private static TokenListParser ListType { get; } = (from leftBracket in Parse.Ref(() => LeftBracket!) - from type in Type! - from rightBracket in RightBracket! - select new ListTypeSyntax(type!, new SyntaxLocation(leftBracket, rightBracket))) + from type in Type! + from rightBracket in RightBracket! + select new ListTypeSyntax(type!, new SyntaxLocation(leftBracket, rightBracket))) .Try() .Named("list type"); @@ -24,10 +24,10 @@ from rightBracket in RightBracket! (from type in ListType .Select(n => (NullableTypeSyntax)n) .Or(NamedType.Select(n => (NullableTypeSyntax)n)) - from bang in Bang!.AsNullable().OptionalOrDefault() - select bang == null - ? type! - : new NonNullTypeSyntax(type!, SyntaxLocation.FromMany(type!, bang)) as TypeSyntax) + from bang in Bang!.AsNullable().OptionalOrDefault() + select bang == null + ? type! + : new NonNullTypeSyntax(type!, SyntaxLocation.FromMany(type!, bang)) as TypeSyntax) .Try() .Named("type"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs index 5fbd2e9fb..d4d4ac6c9 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InputValuesGrammar.cs @@ -11,7 +11,7 @@ internal static partial class Grammar { private static TokenListParser NullValue { get; } = (from @null in Keyword("null") - select SyntaxFactory.NullValue()) + select SyntaxFactory.NullValue()) .Try() .Named("null value"); @@ -20,33 +20,33 @@ select SyntaxFactory.NullValue()) /// private static TokenListParser EnumValue { get; } = (from name in Parse.Ref(() => Name!) - where EnumValueSyntax.IsValidValue(name.Value) - select new EnumValueSyntax(name)) + where EnumValueSyntax.IsValidValue(name.Value) + select new EnumValueSyntax(name)) .Try() .Named("enum value"); private static TokenListParser ListValue { get; } = (from leftBracket in Parse.Ref(() => LeftBracket!) - from values in Value!.Many() - from rightBracket in RightBracket! - select new ListValueSyntax(values!, new SyntaxLocation(leftBracket, rightBracket))) + from values in Value!.Many() + from rightBracket in RightBracket! + select new ListValueSyntax(values!, new SyntaxLocation(leftBracket, rightBracket))) .Try() .Named("list value"); private static TokenListParser ObjectField { get; } = (from n in Parse.Ref(() => Name!) - from c in Colon! - from v in Value! - select SyntaxFactory.ObjectField(n, v!)) + from c in Colon! + from v in Value! + select SyntaxFactory.ObjectField(n, v!)) .Try() .Named("object field"); private static TokenListParser ObjectValue { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from fields in ObjectField!.Many() - from rb in RightBrace! - select new ObjectValueSyntax(fields!, new SyntaxLocation(lb, rb))) + from fields in ObjectField!.Many() + from rb in RightBrace! + select new ObjectValueSyntax(fields!, new SyntaxLocation(lb, rb))) .Try().Named("object value"); private static TokenListParser IntValue { get; } = diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs index 6e7bb9606..9c62a5781 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeDefinitionGrammar.cs @@ -12,11 +12,11 @@ internal static partial class Grammar /// private static TokenListParser InterfaceTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!.AsNullable().OptionalOrDefault()) - from @interface in Keyword("interface") - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() - select new InterfaceTypeDefinitionSyntax(name!, desc, directives, fields, - SyntaxLocation.FromMany(desc, @interface, name!, directives.GetLocation(), fields.GetLocation()))) + from @interface in Keyword("interface") + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() + select new InterfaceTypeDefinitionSyntax(name!, desc, directives, fields, + SyntaxLocation.FromMany(desc, @interface, name!, directives.GetLocation(), fields.GetLocation()))) .Named("interface"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs index f4aeff56d..b24dbab2b 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/InterfaceTypeExtensionGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser InterfaceTypeExtension { get; } = (from extend in Keyword("extend") - from iface in Keyword("interface") - from name in Name! - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition! - select new InterfaceTypeExtensionSyntax(name!, directives, fields!, - SyntaxLocation.FromMany(extend, fields!.GetLocation()))).Try().Or( + from iface in Keyword("interface") + from name in Name! + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition! + select new InterfaceTypeExtensionSyntax(name!, directives, fields!, + SyntaxLocation.FromMany(extend, fields!.GetLocation()))).Try().Or( from extend in Keyword("extend") from iface in Keyword("interface") from name in Name! diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs index e868b37de..b2b7d1492 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeDefinitionGrammar.cs @@ -12,26 +12,26 @@ internal static partial class Grammar /// private static TokenListParser ObjectTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from type in Keyword("type") - from typeName in Name - from interfaces in ImplementsIntefaces!.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() - select new ObjectTypeDefinitionSyntax(typeName!, - desc, - interfaces, directives, fields, - SyntaxLocation.FromMany(desc, type, typeName!, interfaces?.GetLocation(), - directives?.GetLocation(), - fields?.GetLocation()))).Named("object type definition"); + from type in Keyword("type") + from typeName in Name + from interfaces in ImplementsIntefaces!.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition!.AsNullable().OptionalOrDefault() + select new ObjectTypeDefinitionSyntax(typeName!, + desc, + interfaces, directives, fields, + SyntaxLocation.FromMany(desc, type, typeName!, interfaces?.GetLocation(), + directives?.GetLocation(), + fields?.GetLocation()))).Named("object type definition"); /// /// http://facebook.github.io/graphql/June2018/#ImplementsInterfaces /// private static TokenListParser ImplementsIntefaces { get; } = (from impl in Keyword("implements") - from amp in Ampersand.Optional() - from ifaces in NamedType.Select(nt => nt).ManyDelimitedBy(Ampersand.OptionalOrDefault()) - select ifaces!) + from amp in Ampersand.Optional() + from ifaces in NamedType.Select(nt => nt).ManyDelimitedBy(Ampersand.OptionalOrDefault()) + select ifaces!) .Named("implements interfaces"); /// @@ -39,9 +39,9 @@ from ifaces in NamedType.Select(nt => nt).ManyDelimitedBy(Ampersand.OptionalOrDe /// private static TokenListParser FieldsDefinition { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from defs in FieldDefinition!.Many() - from rb in RightBrace - select defs) + from defs in FieldDefinition!.Many() + from rb in RightBrace + select defs) .Try() .Named("fields definition"); @@ -51,35 +51,35 @@ from rb in RightBrace /// private static TokenListParser FieldDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from name in Name - from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() - from c in Colon - from type in Type - from directives in Directives.AsNullable().OptionalOrDefault() - select new FieldDefinitionSyntax(name!, type!, desc, args, directives, - SyntaxLocation.FromMany(desc, name!, args?.GetLocation(), c, type!))) + from name in Name + from args in ArgumentsDefinition!.AsNullable().OptionalOrDefault() + from c in Colon + from type in Type + from directives in Directives.AsNullable().OptionalOrDefault() + select new FieldDefinitionSyntax(name!, type!, desc, args, directives, + SyntaxLocation.FromMany(desc, name!, args?.GetLocation(), c, type!))) .Try() .Named("field definition"); private static TokenListParser ArgumentsDefinition { get; } = (from lp in Parse.Ref(() => LeftParen!) - from defs in InputValueDefinition!.Many() - from rp in RightParen - select defs) + from defs in InputValueDefinition!.Many() + from rp in RightParen + select defs) .Try() .Named("arguments definition"); private static TokenListParser InputValueDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from name in Name - from c in Colon - from type in Type - from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - select new InputValueDefinitionSyntax(name!, type!, desc, defaultValue, directives, - SyntaxLocation.FromMany( - desc, name!, type!, defaultValue, directives?.GetLocation()))) + from name in Name + from c in Colon + from type in Type + from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + select new InputValueDefinitionSyntax(name!, type!, desc, defaultValue, directives, + SyntaxLocation.FromMany( + desc, name!, type!, defaultValue, directives?.GetLocation()))) .Try() .Named("input value definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs index 6a449564b..b0a07549f 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ObjectTypeExtensionGrammar.cs @@ -9,30 +9,30 @@ internal static partial class Grammar { private static TokenListParser ObjectTypeExtension { get; } = (from extend in Keyword("extend") - from type in Keyword("type") - from name in Name - from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() - from directives in Directives.AsNullable().OptionalOrDefault() - from fields in FieldsDefinition - select new ObjectTypeExtensionSyntax(name!, ifaces, directives, fields!, - SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation(), - fields?.GetLocation()))).Try() + from type in Keyword("type") + from name in Name + from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() + from directives in Directives.AsNullable().OptionalOrDefault() + from fields in FieldsDefinition + select new ObjectTypeExtensionSyntax(name!, ifaces, directives, fields!, + SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation(), + fields?.GetLocation()))).Try() .Or( (from extend in Keyword("extend") - from type in Keyword("type") - from name in Name - from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() - from directives in Directives - select new ObjectTypeExtensionSyntax(name!, ifaces, directives!, null, - SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation()))) + from type in Keyword("type") + from name in Name + from ifaces in ImplementsIntefaces.AsNullable().OptionalOrDefault() + from directives in Directives + select new ObjectTypeExtensionSyntax(name!, ifaces, directives!, null, + SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation(), directives?.GetLocation()))) .Try() ).Or( (from extend in Keyword("extend") - from type in Keyword("type") - from name in Name - from ifaces in ImplementsIntefaces - select new ObjectTypeExtensionSyntax(name!, ifaces!, null, null, - SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation()))).Try() + from type in Keyword("type") + from name in Name + from ifaces in ImplementsIntefaces + select new ObjectTypeExtensionSyntax(name!, ifaces!, null, null, + SyntaxLocation.FromMany(extend, name!, ifaces?.GetLocation()))).Try() ) .Named("object type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs index b58d71e71..a97a0f1b3 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/OperationDefinitionGrammar.cs @@ -24,22 +24,22 @@ from selectionSet in SelectionSet! private static TokenListParser OperationType { get; } = (from name in Token.EqualTo(TokenKind.Name).Named("operation type") - let nameValue = name.ToStringValue() - let isQuery = nameValue?.Equals("query", StringComparison.OrdinalIgnoreCase) ?? false - let isMutation = nameValue?.Equals("mutation", StringComparison.OrdinalIgnoreCase) ?? false - let isSubscription = nameValue?.Equals("subscription", StringComparison.OrdinalIgnoreCase) ?? false - where isQuery || isMutation || isSubscription - let type = isQuery - ? LanguageModel.OperationType.Query - : isMutation - ? LanguageModel.OperationType.Mutation - : LanguageModel.OperationType.Subscription - select (type, name.Span.ToLocation())) + let nameValue = name.ToStringValue() + let isQuery = nameValue?.Equals("query", StringComparison.OrdinalIgnoreCase) ?? false + let isMutation = nameValue?.Equals("mutation", StringComparison.OrdinalIgnoreCase) ?? false + let isSubscription = nameValue?.Equals("subscription", StringComparison.OrdinalIgnoreCase) ?? false + where isQuery || isMutation || isSubscription + let type = isQuery + ? LanguageModel.OperationType.Query + : isMutation + ? LanguageModel.OperationType.Mutation + : LanguageModel.OperationType.Subscription + select (type, name.Span.ToLocation())) .Named("operation type"); private static TokenListParser QueryShorthandOpeartion { get; } = (from selectionSet in Parse.Ref(() => SelectionSet!) - select new OperationDefinitionSyntax(LanguageModel.OperationType.Query, selectionSet, - location: selectionSet.Location)) + select new OperationDefinitionSyntax(LanguageModel.OperationType.Query, selectionSet, + location: selectionSet.Location)) .Named("query shortand operation"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs index 3a2d38b5d..b97e5cba1 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeExtensionGrammar.cs @@ -12,11 +12,11 @@ internal static partial class Grammar /// private static TokenListParser ScalarTypeExtension { get; } = (from extend in Keyword("extend") - from scalar in Keyword("scalar") - from name in Parse.Ref(() => Name!) - from directives in Directives - select new ScalarTypeExtensionSyntax(name!, directives!, - SyntaxLocation.FromMany(extend, directives!.GetLocation()))) + from scalar in Keyword("scalar") + from name in Parse.Ref(() => Name!) + from directives in Directives + select new ScalarTypeExtensionSyntax(name!, directives!, + SyntaxLocation.FromMany(extend, directives!.GetLocation()))) .Try() .Named("scalar type extension"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs index b8650ece4..4e6bb4e5c 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/ScalarTypeGrammar.cs @@ -9,11 +9,11 @@ internal static partial class Grammar { private static TokenListParser ScalarTypeDefinitionSyntax { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from scalar in Keyword("scalar") - from name in Name - from directives in Directives.AsNullable().OptionalOrDefault() - select new ScalarTypeDefinitionSyntax(name!, desc, directives, - SyntaxLocation.FromMany(desc, scalar, name!, directives.GetLocation()))) + from scalar in Keyword("scalar") + from name in Name + from directives in Directives.AsNullable().OptionalOrDefault() + select new ScalarTypeDefinitionSyntax(name!, desc, directives, + SyntaxLocation.FromMany(desc, scalar, name!, directives.GetLocation()))) .Try() .Named("scalar type"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs index 9c416a8f5..6425a79d5 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaExtensionGrammar.cs @@ -12,12 +12,12 @@ internal static partial class Grammar /// private static TokenListParser SchemaExtension { get; } = (from extend in Keyword("extend") - from schema in Keyword("schema") - from directives in Directives.AsNullable().OptionalOrDefault() - from lb in Parse.Ref(() => LeftBrace!) - from defs in OperationTypeDefinition!.Many() - from rb in RightBrace - select new SchemaExtensionSyntax(directives, defs!, SyntaxLocation.FromMany(extend, rb))).Try().Or( + from schema in Keyword("schema") + from directives in Directives.AsNullable().OptionalOrDefault() + from lb in Parse.Ref(() => LeftBrace!) + from defs in OperationTypeDefinition!.Many() + from rb in RightBrace + select new SchemaExtensionSyntax(directives, defs!, SyntaxLocation.FromMany(extend, rb))).Try().Or( from extend in Keyword("extend") from schema in Keyword("schema") from directives in Directives diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs index d24366732..4b691b840 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SchemaGrammar.cs @@ -9,20 +9,20 @@ internal static partial class Grammar { private static TokenListParser SchemaDefinition { get; } = (from schema in Keyword("schema") - from directives in Directives.AsNullable().OptionalOrDefault() - from leftBrace in Parse.Ref(() => LeftBrace!) - from operationTypeDefinitionNodes in OperationTypeDefinition!.Many() - from rightBrace in RightBrace - select new SchemaDefinitionSyntax(operationTypeDefinitionNodes!, directives, - SyntaxLocation.FromMany(schema, rightBrace))).Try().Named("schema definition"); + from directives in Directives.AsNullable().OptionalOrDefault() + from leftBrace in Parse.Ref(() => LeftBrace!) + from operationTypeDefinitionNodes in OperationTypeDefinition!.Many() + from rightBrace in RightBrace + select new SchemaDefinitionSyntax(operationTypeDefinitionNodes!, directives, + SyntaxLocation.FromMany(schema, rightBrace))).Try().Named("schema definition"); private static TokenListParser OperationTypeDefinition { get; } = (from opType in Parse.Ref(() => OperationType!) - from colon in Colon - from type in NamedType - select new OperationTypeDefinitionSyntax(opType.type, - type!, - SyntaxLocation.FromMany(opType.location, type!.Location))) + from colon in Colon + from type in NamedType + select new OperationTypeDefinitionSyntax(opType.type, + type!, + SyntaxLocation.FromMany(opType.location, type!.Location))) .Try() .Named("operation type definition"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs index 253894b21..c4b2f5714 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/SelectionSetGrammar.cs @@ -12,10 +12,10 @@ internal static partial class Grammar /// internal static TokenListParser SelectionSet { get; } = (from lb in Parse.Ref(() => LeftBrace!) - from selections in Selection! - .AtLeastOnce() - from rb in RightBrace - select new SelectionSetSyntax(selections, new SyntaxLocation(lb, rb))) + from selections in Selection! + .AtLeastOnce() + from rb in RightBrace + select new SelectionSetSyntax(selections, new SyntaxLocation(lb, rb))) .Named("selection set"); diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs index 3135da22e..b924a401f 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeDefinitionGrammar.cs @@ -9,12 +9,12 @@ internal static partial class Grammar { private static TokenListParser UnionTypeDefinition { get; } = (from desc in Parse.Ref(() => Description!).AsNullable().OptionalOrDefault() - from union in Keyword("union") - from name in Name - from directives in Directives.AsNullable().OptionalOrDefault() - from types in UnionMemberTypes!.AsNullable().OptionalOrDefault() - select new UnionTypeDefinitionSyntax(name!, desc, directives, types, - SyntaxLocation.FromMany(desc, union, name!, directives?.GetLocation(), types?.GetLocation()))) + from union in Keyword("union") + from name in Name + from directives in Directives.AsNullable().OptionalOrDefault() + from types in UnionMemberTypes!.AsNullable().OptionalOrDefault() + select new UnionTypeDefinitionSyntax(name!, desc, directives, types, + SyntaxLocation.FromMany(desc, union, name!, directives?.GetLocation(), types?.GetLocation()))) .Named("union type definition"); /// diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs index 7053c91b2..9de0e0b6b 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/UnionTypeExtensionGrammar.cs @@ -12,11 +12,11 @@ internal static partial class Grammar /// private static TokenListParser UnionTypeExtension { get; } = (from extend in Keyword("extend") - from union in Keyword("union") - from name in Parse.Ref(() => Name!) - from directives in Directives - select new UnionTypeExtensionSyntax(name!, directives!, null, - SyntaxLocation.FromMany(extend, directives!.GetLocation()))) + from union in Keyword("union") + from name in Parse.Ref(() => Name!) + from directives in Directives + select new UnionTypeExtensionSyntax(name!, directives!, null, + SyntaxLocation.FromMany(extend, directives!.GetLocation()))) .Select(_ => { return _; }) .Try() .Or(from extend in Keyword("extend") diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs index 485a05962..a3bf9cd14 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Grammar/VariablesGrammar.cs @@ -12,9 +12,9 @@ internal static partial class Grammar /// private static TokenListParser VariableDefinitions { get; } = (from lp in Parse.Ref(() => LeftParen!) - from variableDefinitionNodes in VariableDefinition!.Many() - from rp in RightParen - select variableDefinitionNodes) + from variableDefinitionNodes in VariableDefinition!.Many() + from rp in RightParen + select variableDefinitionNodes) .Named("variable definitions"); /// @@ -22,10 +22,10 @@ from rp in RightParen /// internal static TokenListParser VariableDefinition { get; } = (from v in Parse.Ref(() => Variable!) - from c in Colon - from t in Type - from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() - select new VariableDefinitionSyntax(v, t!, defaultValue, SyntaxLocation.FromMany(v, c, t!, defaultValue))) + from c in Colon + from t in Type + from defaultValue in DefaultValue!.AsNullable().OptionalOrDefault() + select new VariableDefinitionSyntax(v, t!, defaultValue, SyntaxLocation.FromMany(v, c, t!, defaultValue))) .Named("variable definition"); /// @@ -33,8 +33,8 @@ from t in Type /// internal static TokenListParser Variable { get; } = (from d in Parse.Ref(() => DollarSign!) - from n in Name!.Named("variable name") - select new VariableSyntax(n, new SyntaxLocation(d, n))) + from n in Name!.Named("variable name") + select new VariableSyntax(n, new SyntaxLocation(d, n))) .Named("variable"); /// @@ -42,7 +42,7 @@ from t in Type /// private static TokenListParser DefaultValue { get; } = (from assignment in Parse.Ref(() => Assignment!).Named("assignment") - from value in Value!.Named("default value") - select value!) + from value in Value!.Named("default value") + select value!) .Named("default value"); } diff --git a/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs b/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs index 2b0ebd4fa..6a79e614f 100644 --- a/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs +++ b/src/GraphZen.LanguageModel/LanguageModel/Internal/Printer.cs @@ -521,7 +521,7 @@ private void Join(IReadOnlyList nodes, string? seperator = null) { Join(nodes, seperator != null ? () => { Append(seperator); } - : null); + : null); } #endregion diff --git a/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs b/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs index cc2bbf809..ad6150176 100644 --- a/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs +++ b/src/GraphZen.TypeSystem/TypeSystem/TypeKind.cs @@ -9,29 +9,35 @@ namespace GraphZen.TypeSystem; [Description("An enum describing what kind of type a given `__Type` is.")] public enum TypeKind { - [Description("Indicates this type is a scalar.")] [GraphQLName("SCALAR")] + [Description("Indicates this type is a scalar.")] + [GraphQLName("SCALAR")] Scalar, - [Description("Indicates this type is an object fields` and `interfaces` are valid fields.")] [GraphQLName("OBJECT")] + [Description("Indicates this type is an object fields` and `interfaces` are valid fields.")] + [GraphQLName("OBJECT")] Object, [Description("Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.")] [GraphQLName("INTERFACE")] Interface, - [Description("Indicates this type is a union. `possibleTypes` is a valid field.")] [GraphQLName("UNION")] + [Description("Indicates this type is a union. `possibleTypes` is a valid field.")] + [GraphQLName("UNION")] Union, - [Description("Indicates this type is an enum. `enumValues` is a valid field.")] [GraphQLName("ENUM")] + [Description("Indicates this type is an enum. `enumValues` is a valid field.")] + [GraphQLName("ENUM")] Enum, [Description("Indicates this type is an input object. `inputFields` is a valid field.")] [GraphQLName("INPUT_OBJECT")] InputObject, - [Description("Indicates this type is a list. `ofType` is a valid field.")] [GraphQLName("LIST")] + [Description("Indicates this type is a list. `ofType` is a valid field.")] + [GraphQLName("LIST")] List, - [Description("Indicates this type is a non-null. `ofType` is a valid field.")] [GraphQLName("NON_NULL")] + [Description("Indicates this type is a non-null. `ofType` is a valid field.")] + [GraphQLName("NON_NULL")] NonNull } diff --git a/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs b/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs index 1b4b5e2db..0917d0ac1 100644 --- a/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs +++ b/test/GraphZen.Tests/QueryEngine/UnionInterfaceTests.cs @@ -76,7 +76,9 @@ public class Dog public static Person John { get; } = new() { - Name = "John", Pets = new object[] { Garfield, Odie }, Friends = new object[] { Liz, Odie } + Name = "John", + Pets = new object[] { Garfield, Odie }, + Friends = new object[] { Liz, Odie } }; [Fact] diff --git a/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs b/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs index b4fbf45f6..f36cd9c8e 100644 --- a/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs +++ b/test/GraphZen.Tests/QueryEngine/Variables/UsingVariables.cs @@ -35,11 +35,11 @@ public Task ErrorsOnDeepNestedErrorsAndWithmanyErrors() => .ShouldEqual(new { errors = Array(new - { - message = + { + message = "Variable \"$input\" got invalid value `{na: {a: \"foo\"}}`; Field value.nb of required type String! was not provided.", - locations = Array(new { line = 2, column = 20 }) - }, + locations = Array(new { line = 2, column = 20 }) + }, new { message = diff --git a/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs b/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs index 447dc5efc..fb401f0c8 100644 --- a/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs +++ b/test/GraphZen.Tests/StarWars/StarWarsIntrospectionTest.cs @@ -339,7 +339,8 @@ query IntrospectionDroidDescriptionQuery { { __type = new { - name = "Droid", description = "A mechanical creature in the Star Wars universe." + name = "Droid", + description = "A mechanical creature in the Star Wars universe." } } }); diff --git a/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs b/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs index 77c566ffb..366d0d76b 100644 --- a/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs +++ b/test/GraphZen.Tests/StarWars/StarWarsSchemaAndData.cs @@ -144,7 +144,10 @@ public class Droid : ICharacter private static Human Tarkin { get; } = new() { - Id = "1004", Name = "Wilhuff Tarkin", FriendIds = new[] { "1001" }, AppearsIn = new[] { Episode.Empire } + Id = "1004", + Name = "Wilhuff Tarkin", + FriendIds = new[] { "1001" }, + AppearsIn = new[] { Episode.Empire } }; private static readonly IReadOnlyDictionary HumanData = new Dictionary @@ -271,13 +274,16 @@ public class Droid : ICharacter [Description("One of the films in the Star Wars Trilogy")] public enum Episode { - [Description("Released in 1977")] [GraphQLName("NEW_HOPE")] + [Description("Released in 1977")] + [GraphQLName("NEW_HOPE")] NewHope = 4, - [Description("Released in 1980")] [GraphQLName("EMPIRE")] + [Description("Released in 1980")] + [GraphQLName("EMPIRE")] Empire = 5, - [Description("Released in 1983")] [GraphQLName("JEDI")] + [Description("Released in 1983")] + [GraphQLName("JEDI")] Jedi = 6 } diff --git a/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs index 21cd69e19..6503663e5 100644 --- a/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/FieldArgumentsMustHaveInputTypesTests.cs @@ -16,9 +16,9 @@ public class FieldArgumentsMustHaveInputTypesTests : ValidationRuleHarness public static IEnumerable GetInputTypeData(string typeName) { return from fieldsType in OutputFieldsTypes - from inputType in InputTypes - from fieldType in typeName.WithModifiers() - select new object[] { fieldsType, inputType, fieldType }; + from inputType in InputTypes + from fieldType in typeName.WithModifiers() + select new object[] { fieldsType, inputType, fieldType }; } [Theory] @@ -37,9 +37,9 @@ public void AcceptsInputTypeAsFieldArgType(string fieldsType, string inputType, public static IEnumerable GetNonInputTypeData(string typeName) { return from fieldsType in OutputFieldsTypes - from inputType in NonInputTypes - from fieldType in typeName.WithModifiers() - select new object[] { fieldsType, inputType, fieldType }; + from inputType in NonInputTypes + from fieldType in typeName.WithModifiers() + select new object[] { fieldsType, inputType, fieldType }; } [Theory] diff --git a/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs index 37c545e8d..d9f8105e3 100644 --- a/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/InputObjectFieldsMustHaveInputTypesTests.cs @@ -15,9 +15,9 @@ public class InputObjectFieldsMustHaveInputTypesTests : ValidationRuleHarness public static IEnumerable GetValidInputFieldScenarios() { return from inputType in InputTypes - from fieldsType in InputFieldsTypes - from fieldType in "SomeInputType".WithModifiers() - select new object[] { inputType, fieldsType, fieldType }; + from fieldsType in InputFieldsTypes + from fieldType in "SomeInputType".WithModifiers() + select new object[] { inputType, fieldsType, fieldType }; } [Theory] @@ -36,9 +36,9 @@ public void AcceptsAnInputTypeAsAnInputFieldType(string inputType, string inputF public static IEnumerable GetInvalidInputFieldScenarios() { return from nonInputType in NonInputTypes - from inputFieldsType in InputFieldsTypes - from fieldType in "SomeOutputType".WithModifiers() - select new object[] { nonInputType, inputFieldsType, fieldType }; + from inputFieldsType in InputFieldsTypes + from fieldType in "SomeOutputType".WithModifiers() + select new object[] { nonInputType, inputFieldsType, fieldType }; } [Theory] diff --git a/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs index 77660ed45..9391ca637 100644 --- a/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/InterfaceFieldsMustHaveOutputTypesTests.cs @@ -15,8 +15,8 @@ public class InterfaceFieldsMustHaveOutputTypesTests : ValidationRuleHarness public static IEnumerable GetValidInterfaceFieldTypeScenarios() { return from outputType in OutputTypes - from fieldType in "SomeOutputType".WithModifiers() - select new object[] { outputType, fieldType }; + from fieldType in "SomeOutputType".WithModifiers() + select new object[] { outputType, fieldType }; } [Theory] @@ -35,8 +35,8 @@ interface SomeInterface {{ public static IEnumerable GetInvalidInterfaceFieldTypeScenarios() { return from nonOutputType in NonOutputTypes - from fieldType in "SomeInputType".WithModifiers() - select new object[] { nonOutputType, fieldType }; + from fieldType in "SomeInputType".WithModifiers() + select new object[] { nonOutputType, fieldType }; } [Theory] diff --git a/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs b/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs index 39a1d5cb9..1b0ad231e 100644 --- a/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs +++ b/test/GraphZen.Tests/Validation/Rules/ObjectFieldsMustHaveOutputTypesTests.cs @@ -14,8 +14,8 @@ public class ObjectFieldsMustHaveOutputTypesTests : ValidationRuleHarness public static IEnumerable GetValidFieldScenarios() { return from outputType in OutputTypes - from fieldType in "SomeOutputType".WithModifiers() - select new[] { outputType, fieldType }; + from fieldType in "SomeOutputType".WithModifiers() + select new[] { outputType, fieldType }; } [Theory] @@ -34,8 +34,8 @@ type SomeObject {{ public static IEnumerable GetInvalidFieldScenarios() { return from nonOutputType in NonOutputTypes - from fieldType in "SomeInputType".WithModifiers() - select new[] { nonOutputType, fieldType }; + from fieldType in "SomeInputType".WithModifiers() + select new[] { nonOutputType, fieldType }; } diff --git a/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs b/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs index e7de78a6c..be72d243b 100644 --- a/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs +++ b/test/GraphZen.TypeSystem.Tests/ClrTypeUtils.cs @@ -32,14 +32,14 @@ public static IEnumerable GetTypesImplementingOpenGenericType(Type openGen { var assembly = openGenericType.Assembly; return from x in assembly.GetTypes() - from z in x.GetInterfaces() - let y = x.BaseType - where - (y != null && y.IsGenericType && - openGenericType.IsAssignableFrom(y.GetGenericTypeDefinition())) || - (z.IsGenericType && - openGenericType.IsAssignableFrom(z.GetGenericTypeDefinition())) - where !isAbstract.HasValue || x.IsAbstract == isAbstract.Value - select x; + from z in x.GetInterfaces() + let y = x.BaseType + where + (y != null && y.IsGenericType && + openGenericType.IsAssignableFrom(y.GetGenericTypeDefinition())) || + (z.IsGenericType && + openGenericType.IsAssignableFrom(z.GetGenericTypeDefinition())) + where !isAbstract.HasValue || x.IsAbstract == isAbstract.Value + select x; } } diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs index 0e7eb0413..b297b82c8 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Directives/Schema_Directives_ViaObjectClrPropertyAttribute.cs @@ -12,7 +12,8 @@ public class Schema_Directives_ViaObjectClrPropertyAttribute : Schema_Directives { public CollectionConventionContext GetContext() => new() { - ItemNamedByConvention = nameof(FieldDefinition), ItemNamedByDataAnnotation = "hello" + ItemNamedByConvention = nameof(FieldDefinition), + ItemNamedByDataAnnotation = "hello" }; public void ConfigureContextConventionally(SchemaBuilder sb) diff --git a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs index 8da859433..3986c32b5 100644 --- a/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs +++ b/test/GraphZen.TypeSystem.Tests/Configuration/Schema/Enums/EnumValues/Description/EnumValue_ViaClrEnumValue_Description.cs @@ -21,7 +21,8 @@ public enum ExampleEnum public LeafConventionContext GetContext() => new() { - ParentName = nameof(ExampleEnum.ExampleEnumValue), DataAnnotationValue = DataAnnotationDescriptionValue + ParentName = nameof(ExampleEnum.ExampleEnumValue), + DataAnnotationValue = DataAnnotationDescriptionValue }; public void ConfigureContextConventionally(SchemaBuilder sb)