From 6cc1ca5e9a643370d0e3767d58934a0983d82571 Mon Sep 17 00:00:00 2001 From: Nigel Sampson Date: Mon, 8 Jul 2019 10:10:59 +1200 Subject: [PATCH] Respect UseXmlDocumentation with Schema.Create (#897) --- src/Core/Types.Tests/Types/ObjectTypeTests.cs | 15 +++++++++++++++ ...lDocumentation_IgnoreXmlDocs_SchemaCreate.snap | 10 ++++++++++ src/Core/Types/Configuration/SchemaOptions.cs | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/Core/Types.Tests/Types/__snapshots__/ObjectTypeTests.CreateObjectTypeWithXmlDocumentation_IgnoreXmlDocs_SchemaCreate.snap diff --git a/src/Core/Types.Tests/Types/ObjectTypeTests.cs b/src/Core/Types.Tests/Types/ObjectTypeTests.cs index 2c710af7ef8..03c2a28ac66 100644 --- a/src/Core/Types.Tests/Types/ObjectTypeTests.cs +++ b/src/Core/Types.Tests/Types/ObjectTypeTests.cs @@ -1322,6 +1322,21 @@ public void CreateObjectTypeWithXmlDocumentation_IgnoreXmlDocs() schema.ToString().MatchSnapshot(); } + [Fact] + public void CreateObjectTypeWithXmlDocumentation_IgnoreXmlDocs_SchemaCreate() + { + // arrange + // act + ISchema schema = Schema.Create(c => + { + c.RegisterQueryType(); + c.Options.UseXmlDocumentation = false; + }); + + // assert + schema.ToString().MatchSnapshot(); + } + [Fact] public void Field_Is_Missing_Type_Throws_SchemaException() { diff --git a/src/Core/Types.Tests/Types/__snapshots__/ObjectTypeTests.CreateObjectTypeWithXmlDocumentation_IgnoreXmlDocs_SchemaCreate.snap b/src/Core/Types.Tests/Types/__snapshots__/ObjectTypeTests.CreateObjectTypeWithXmlDocumentation_IgnoreXmlDocs_SchemaCreate.snap new file mode 100644 index 00000000000..29223f7280a --- /dev/null +++ b/src/Core/Types.Tests/Types/__snapshots__/ObjectTypeTests.CreateObjectTypeWithXmlDocumentation_IgnoreXmlDocs_SchemaCreate.snap @@ -0,0 +1,10 @@ +schema { + query: QueryWithDocumentation +} + +type QueryWithDocumentation { + foo(bar: String): String +} + +"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text." +scalar String diff --git a/src/Core/Types/Configuration/SchemaOptions.cs b/src/Core/Types/Configuration/SchemaOptions.cs index b919743fcaf..0733ba31b19 100644 --- a/src/Core/Types/Configuration/SchemaOptions.cs +++ b/src/Core/Types/Configuration/SchemaOptions.cs @@ -20,7 +20,8 @@ public static SchemaOptions FromOptions(IReadOnlySchemaOptions options) QueryTypeName = options.QueryTypeName, MutationTypeName = options.MutationTypeName, SubscriptionTypeName = options.SubscriptionTypeName, - StrictValidation = options.StrictValidation + StrictValidation = options.StrictValidation, + UseXmlDocumentation = options.UseXmlDocumentation }; } }