From 1626be2a61bf0698a74741fa0406529f90f426a5 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Tue, 21 Apr 2020 23:32:57 +0200 Subject: [PATCH 1/6] fix(Stiching): enable nested variable stiching --- src/Core/Language/Visitors/QuerySyntaxRewriter.cs | 10 +++++++++- ...aMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap | 8 +++++++- ...sts.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap | 8 +++++++- ...aMergerTests.MergeDemoSchemaWithDefaultHandler.snap | 8 +++++++- .../DelegateToRemoteSchemaMiddlewareTests.cs | 2 ++ ...ng.graphql_StitchingQueryWithVariables.graphql.snap | 3 ++- ...geQueryRewriterTests.QueryWithPrivateVariables.snap | 3 ++- .../Stitching.Tests/__resources__/Customer.graphql | 8 +++++++- .../Stitching.Tests/__resources__/Stitching.graphql | 6 ++++++ .../__resources__/StitchingQueryWithVariables.graphql | 3 ++- .../StitchingBuilderTests.AddExtensionsFromFile.snap | 4 ++-- .../StitchingBuilderTests.AddExtensionsFromString.snap | 4 ++-- .../StitchingBuilderTests.AddSchemaFromFile.snap | 8 +++++++- .../StitchingBuilderTests.AddSchemaFromString.snap | 8 +++++++- .../Utilities/ExtractFieldQuerySyntaxRewriter.cs | 4 ++-- 15 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/Core/Language/Visitors/QuerySyntaxRewriter.cs b/src/Core/Language/Visitors/QuerySyntaxRewriter.cs index 4e3a85df2a5..549b8639519 100644 --- a/src/Core/Language/Visitors/QuerySyntaxRewriter.cs +++ b/src/Core/Language/Visitors/QuerySyntaxRewriter.cs @@ -38,6 +38,15 @@ public virtual ISyntaxNode Rewrite( case InlineFragmentNode inline: return RewriteInlineFragment(inline, context); + case ObjectValueNode objectValue: + return RewriteObjectValue(objectValue, context); + + case VariableNode variable: + return RewriteVariable(variable, context); + + case IValueNode _: + return node; + default: throw new NotSupportedException( LangResources.QuerySyntaxRewriter_NotSupported); @@ -209,7 +218,6 @@ protected virtual FieldNode RewriteField( (p, c) => RewriteMany(p, c, RewriteDirective), current.WithDirectives); - if (current.SelectionSet != null) { current = Rewrite(current, current.SelectionSet, context, diff --git a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap index 8a8b3179b18..46913c76311 100644 --- a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap +++ b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap @@ -1,4 +1,4 @@ -interface Contract @source(name: "Contract", schema: "A") { +interface Contract @source(name: "Contract", schema: "A") { id: ID! } @@ -16,6 +16,7 @@ type Customer @source(name: "Customer", schema: "B") { id: ID! name: String! consultant: Consultant + complexArg(arg: ComplexInputType): String } type Consultant @source(name: "Consultant", schema: "B") { @@ -24,3 +25,8 @@ type Consultant @source(name: "Consultant", schema: "B") { } union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "B") = Customer | Consultant + +input ComplexInputType @source(name: "ComplexInputType", schema: "B") { + value: String + deeper: ComplexInputType +} diff --git a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap index f07c55cfab5..59a5b4e5823 100644 --- a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap +++ b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap @@ -1,4 +1,4 @@ -type Query { +type Query { customer(id: ID!): Customer @delegate(schema: "B") consultant(id: ID!): Consultant @delegate(schema: "B") customerOrConsultant(id: ID!): CustomerOrConsultant @delegate(schema: "B") @@ -22,6 +22,7 @@ type Customer @source(name: "Customer", schema: "B") { id: ID! name: String! consultant: Consultant + complexArg(arg: ComplexInputType): String } type Consultant @source(name: "Consultant", schema: "B") { @@ -30,3 +31,8 @@ type Consultant @source(name: "Consultant", schema: "B") { } union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "B") = Customer | Consultant + +input ComplexInputType @source(name: "ComplexInputType", schema: "B") { + value: String + deeper: ComplexInputType +} diff --git a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap index a9ad2a22697..6fe45f19100 100644 --- a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap +++ b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap @@ -1,4 +1,4 @@ -type Query { +type Query { contract(contractId: ID!): Contract @delegate(schema: "A") contracts(customerId: ID!): [Contract!] @delegate(schema: "A") customer(id: ID!): Customer @delegate(schema: "B") @@ -24,6 +24,7 @@ type Customer @source(name: "Customer", schema: "B") { id: ID! name: String! consultant: Consultant + complexArg(arg: ComplexInputType): String } type Consultant @source(name: "Consultant", schema: "B") { @@ -32,3 +33,8 @@ type Consultant @source(name: "Consultant", schema: "B") { } union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "B") = Customer | Consultant + +input ComplexInputType @source(name: "ComplexInputType", schema: "B") { + value: String + deeper: ComplexInputType +} diff --git a/src/Stitching/Stitching.Tests/Middleware/DelegateToRemoteSchemaMiddlewareTests.cs b/src/Stitching/Stitching.Tests/Middleware/DelegateToRemoteSchemaMiddlewareTests.cs index 51e99592370..1272bb7d1ca 100644 --- a/src/Stitching/Stitching.Tests/Middleware/DelegateToRemoteSchemaMiddlewareTests.cs +++ b/src/Stitching/Stitching.Tests/Middleware/DelegateToRemoteSchemaMiddlewareTests.cs @@ -63,6 +63,8 @@ public async Task ExecuteStitchingQueryWithVariables() .SetQuery(FileResource.Open( "StitchingQueryWithVariables.graphql")) .SetVariableValue("customerId", "Q3VzdG9tZXIKZDE=") + .SetVariableValue("deep", "deep") + .SetVariableValue("deeper", "deeper") .Create(); // act diff --git a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap index 43a3f13caad..ec88621c7e0 100644 --- a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap +++ b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap @@ -1,10 +1,11 @@ -query fetch($customerId: ID!) { +query fetch($customerId: ID!, $deep: String!) { customer(id: $customerId) { name consultant { name __typename } + complexArg(arg: { value: $deep, deeper: { deeper: { value: $deeper } } }) id __typename } diff --git a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap index 3194ba8a6be..a828ab39add 100644 --- a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap +++ b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap @@ -1,4 +1,4 @@ -query exec_batch($_b_customerId: ID!) { +query exec_batch($_b_customerId: ID!, $_b_deep: String!, $_b_deeper: String!) { _a_customer: customerOrConsultant(id: "Q3VzdG9tZXIKZDE=") { ... _a_customer ... _a_consultant @@ -12,6 +12,7 @@ query exec_batch($_b_customerId: ID!) { consultant { name } + complexArg(arg: { value: $deep, deeper: { deeper: { value: $deeper } } }) contracts { id ... on LifeInsuranceContract { diff --git a/src/Stitching/Stitching.Tests/__resources__/Customer.graphql b/src/Stitching/Stitching.Tests/__resources__/Customer.graphql index d601bd2446b..7faa488a5ac 100644 --- a/src/Stitching/Stitching.Tests/__resources__/Customer.graphql +++ b/src/Stitching/Stitching.Tests/__resources__/Customer.graphql @@ -8,6 +8,7 @@ type Customer { id: ID! name: String! consultant: Consultant + complexArg(arg:ComplexInputType): String } type Consultant { @@ -15,4 +16,9 @@ type Consultant { name: String! } -union CustomerOrConsultant = Customer | Consultant +union CustomerOrConsultant = Customer | Consultant + +input ComplexInputType { + value: String + deeper: ComplexInputType +} \ No newline at end of file diff --git a/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql b/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql index ea9742f1af9..8baa3ea5369 100644 --- a/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql +++ b/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql @@ -19,6 +19,7 @@ type Query { type Customer { id: ID! name: String! + complexArg(arg:ComplexInputType): String consultant: Consultant contracts: [Contract!] @delegate(schema: "contract", path: "contracts(customerId:$fields:id)") @@ -46,3 +47,8 @@ type SomeOtherContract implements Contract { } union CustomerOrConsultant = Customer | Consultant + +input ComplexInputType { + value: String + deeper: ComplexInputType +} diff --git a/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql b/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql index ede799bc110..4a07f07b512 100644 --- a/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql +++ b/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql @@ -1,9 +1,10 @@ -query customer_query($customerId: ID!) { +query customer_query($customerId: ID!, $deep: String!, $deeper: String!) { customer(id: $customerId) { name consultant { name } + complexArg(arg: { value: $deep, deeper: { deeper: { value: $deeper } } }) contracts { id ... on LifeInsuranceContract { diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap index 9ac7e1d1f45..8a5b26d42c5 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap @@ -1,4 +1,4 @@ -[ +[ "type Query {\n contract(contractId: ID!): Contract\n contracts(customerId: ID!): [Contract!]\n}\n\ninterface Contract {\n id: ID!\n}\n\ntype LifeInsuranceContract implements Contract {\n id: ID!\n premium: Float\n}\n\ntype SomeOtherContract implements Contract {\n id: ID!\n expiryDate: DateTime\n}", - "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant" + "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n complexArg(arg: ComplexInputType): String\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant\n\ninput ComplexInputType {\n value: String\n deeper: ComplexInputType\n}" ] diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap index 9ac7e1d1f45..8a5b26d42c5 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap @@ -1,4 +1,4 @@ -[ +[ "type Query {\n contract(contractId: ID!): Contract\n contracts(customerId: ID!): [Contract!]\n}\n\ninterface Contract {\n id: ID!\n}\n\ntype LifeInsuranceContract implements Contract {\n id: ID!\n premium: Float\n}\n\ntype SomeOtherContract implements Contract {\n id: ID!\n expiryDate: DateTime\n}", - "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant" + "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n complexArg(arg: ComplexInputType): String\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant\n\ninput ComplexInputType {\n value: String\n deeper: ComplexInputType\n}" ] diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap index f2341ba29da..e73411b5db3 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap @@ -1,4 +1,4 @@ -type Query { +type Query { contract(contractId: ID!): Contract @delegate(schema: "contract") contracts(customerId: ID!): [Contract!] @delegate(schema: "contract") customer(id: ID!): Customer @delegate(schema: "customer") @@ -24,6 +24,7 @@ type Customer @source(name: "Customer", schema: "customer") { id: ID! name: String! consultant: Consultant + complexArg(arg: ComplexInputType): String } type Consultant @source(name: "Consultant", schema: "customer") { @@ -32,3 +33,8 @@ type Consultant @source(name: "Consultant", schema: "customer") { } union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "customer") = Customer | Consultant + +input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { + value: String + deeper: ComplexInputType +} diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap index f2341ba29da..e73411b5db3 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap @@ -1,4 +1,4 @@ -type Query { +type Query { contract(contractId: ID!): Contract @delegate(schema: "contract") contracts(customerId: ID!): [Contract!] @delegate(schema: "contract") customer(id: ID!): Customer @delegate(schema: "customer") @@ -24,6 +24,7 @@ type Customer @source(name: "Customer", schema: "customer") { id: ID! name: String! consultant: Consultant + complexArg(arg: ComplexInputType): String } type Consultant @source(name: "Consultant", schema: "customer") { @@ -32,3 +33,8 @@ type Consultant @source(name: "Consultant", schema: "customer") { } union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "customer") = Customer | Consultant + +input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { + value: String + deeper: ComplexInputType +} diff --git a/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs b/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs index 918b1bfcfe0..f5c02f8320a 100644 --- a/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs +++ b/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs @@ -263,7 +263,6 @@ protected override ObjectFieldNode RewriteObjectField( && inputType.Fields.TryGetField(current.Name.Value, out InputField inputField)) { - Context cloned = context.Clone(); cloned.InputField = inputField; cloned.InputType = inputField.Type; @@ -276,9 +275,10 @@ protected override ObjectFieldNode RewriteObjectField( new NameNode(sourceDirective.Name)); } + Rewrite(node.Value, context); + return base.RewriteObjectField(current, cloned); } - return base.RewriteObjectField(current, context); } From 95c8440014b7b418c01175d3b9930a5cdd51cd31 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 22 Apr 2020 00:01:31 +0200 Subject: [PATCH 2/6] fix test --- ...sts.ExecuteStitchingQueryWithVariables.snap | 1 + ...s.ListVariableIsCorrectlyPassed_schema.snap | 6 ++++++ ...edListVariableIsCorrectlyPassed_schema.snap | 6 ++++++ .../Schemas/Customers/ComplexInput.cs | 8 ++++++++ .../Schemas/Customers/ComplexInputType.cs | 18 ++++++++++++++++++ .../Schemas/Customers/CustomerType.cs | 6 ++++++ ...ql_StitchingQueryWithVariables.graphql.snap | 2 +- ...titchingBuilderTests.AddSchemaFromHttp.snap | 6 ++++++ .../StitchingBuilderTests.AddSchema_2.snap | 6 ++++++ 9 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs create mode 100644 src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInputType.cs diff --git a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/DelegateToRemoteSchemaMiddlewareTests.ExecuteStitchingQueryWithVariables.snap b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/DelegateToRemoteSchemaMiddlewareTests.ExecuteStitchingQueryWithVariables.snap index fa8aa2c8ba9..b1291f77587 100644 --- a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/DelegateToRemoteSchemaMiddlewareTests.ExecuteStitchingQueryWithVariables.snap +++ b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/DelegateToRemoteSchemaMiddlewareTests.ExecuteStitchingQueryWithVariables.snap @@ -5,6 +5,7 @@ "consultant": { "name": "Jordan Belfort" }, + "complexArg": "", "contracts": [ { "id": "TGlmZUluc3VyYW5jZUNvbnRyYWN0CmQx", diff --git a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap index 88de4ed106c..7c58f817d51 100644 --- a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap +++ b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap @@ -19,6 +19,7 @@ type CreateCustomerPayload @source(name: "CreateCustomerPayload", schema: "custo } type Customer @source(name: "Customer", schema: "customer") { + complexArg(arg: ComplexInputType): String consultant(customer: CustomerInput): Consultant id: ID! kind: CustomerKind! @@ -103,6 +104,11 @@ type SomeOtherContract implements Contract @source(name: "SomeOtherContract", sc union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "customer") = Customer | Consultant +input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { + deeper: ComplexInputType + value: String +} + input CreateCustomerInput @source(name: "CreateCustomerInput", schema: "customer") { consultantId: String name: String diff --git a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap index 95f365f96f9..b1144ed4494 100644 --- a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap +++ b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap @@ -19,6 +19,7 @@ type CreateCustomerPayload @source(name: "CreateCustomerPayload", schema: "custo } type Customer @source(name: "Customer", schema: "customer") { + complexArg(arg: ComplexInputType): String consultant(customer: CustomerInput): Consultant id: ID! kind: CustomerKind! @@ -104,6 +105,11 @@ type SomeOtherContract implements Contract @source(name: "SomeOtherContract", sc union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "customer") = Customer | Consultant +input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { + deeper: ComplexInputType + value: String +} + input CreateCustomerInput @source(name: "CreateCustomerInput", schema: "customer") { consultantId: String name: String diff --git a/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs new file mode 100644 index 00000000000..c647fc161c3 --- /dev/null +++ b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs @@ -0,0 +1,8 @@ +namespace HotChocolate.Stitching.Schemas.Customers +{ + public class ComplexInput + { + public string Value { get; set; } + public ComplexInput Deeper { get; set; } + } +} diff --git a/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInputType.cs b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInputType.cs new file mode 100644 index 00000000000..a13036a1854 --- /dev/null +++ b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInputType.cs @@ -0,0 +1,18 @@ +using System.Linq; +using HotChocolate.Types; +using HotChocolate.Types.Relay; + +namespace HotChocolate.Stitching.Schemas.Customers +{ + public class ComplexInputType + : InputObjectType + { + protected override void Configure( + IInputObjectTypeDescriptor descriptor) + { + descriptor.Name("ComplexInputType"); + descriptor.Field(t => t.Value).Type(); + descriptor.Field(t => t.Deeper).Type(); + } + } +} diff --git a/src/Stitching/Stitching.Tests/Schemas/Customers/CustomerType.cs b/src/Stitching/Stitching.Tests/Schemas/Customers/CustomerType.cs index 6d41f54df78..3a369a611a3 100644 --- a/src/Stitching/Stitching.Tests/Schemas/Customers/CustomerType.cs +++ b/src/Stitching/Stitching.Tests/Schemas/Customers/CustomerType.cs @@ -23,6 +23,12 @@ protected override void Configure( .Type() .Resolver(ctx => string.Join(", ", ctx.Argument("input").Words)); + + descriptor.Field("complexArg") + .Argument("arg", a => + a.Type()) + .Type() + .Resolver(""); } } } diff --git a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap index ec88621c7e0..939ae636ef4 100644 --- a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap +++ b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap @@ -1,4 +1,4 @@ -query fetch($customerId: ID!, $deep: String!) { +query fetch($customerId: ID!, $deep: String!, $deeper: String!) { customer(id: $customerId) { name consultant { diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap index c2698263750..96e77ca8caf 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap @@ -17,6 +17,7 @@ type Mutation { } type Customer @source(name: "Customer", schema: "customer") { + complexArg(arg: ComplexInputType): String consultant(customer: CustomerInput): Consultant id: ID! kind: CustomerKind! @@ -39,6 +40,11 @@ input SayInput @source(name: "SayInput", schema: "customer") { words: [String] } +input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { + deeper: ComplexInputType + value: String +} + "A connection to a list of items." type CustomerConnection @source(name: "CustomerConnection", schema: "customer") { "A list of edges." diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap index 75e903e0a15..cde329f41cc 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap @@ -27,6 +27,7 @@ type CreateCustomerPayload @source(name: "CreateCustomerPayload", schema: "custo } type Customer @source(name: "Customer", schema: "customer") { + complexArg(arg: ComplexInputType): String consultant(customer: CustomerInput): Consultant id: ID! kind: CustomerKind! @@ -70,6 +71,11 @@ type PageInfo @source(name: "PageInfo", schema: "customer") { union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "customer") = Customer | Consultant +input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { + deeper: ComplexInputType + value: String +} + input CreateCustomerInput @source(name: "CreateCustomerInput", schema: "customer") { consultantId: String name: String From 3c70d139fd16040bd6432386723181ea9b6de719 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 22 Apr 2020 00:05:17 +0200 Subject: [PATCH 3/6] test constant value --- ...Stitching.graphql_StitchingQueryWithVariables.graphql.snap | 2 +- .../MergeQueryRewriterTests.QueryWithPrivateVariables.snap | 2 +- .../__resources__/StitchingQueryWithVariables.graphql | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap index 939ae636ef4..4cfd992259a 100644 --- a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap +++ b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap @@ -5,7 +5,7 @@ name __typename } - complexArg(arg: { value: $deep, deeper: { deeper: { value: $deeper } } }) + complexArg(arg: { value: $deep, deeper: { value: "CONSTANT", deeper: { value: $deeper } } }) id __typename } diff --git a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap index a828ab39add..8a647162bf3 100644 --- a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap +++ b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap @@ -12,7 +12,7 @@ consultant { name } - complexArg(arg: { value: $deep, deeper: { deeper: { value: $deeper } } }) + complexArg(arg: { value: $deep, deeper: { value: "CONSTANT", deeper: { value: $deeper } } }) contracts { id ... on LifeInsuranceContract { diff --git a/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql b/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql index 4a07f07b512..161b993f005 100644 --- a/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql +++ b/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql @@ -4,7 +4,9 @@ query customer_query($customerId: ID!, $deep: String!, $deeper: String!) { consultant { name } - complexArg(arg: { value: $deep, deeper: { deeper: { value: $deeper } } }) + complexArg( + arg: { value: $deep, deeper: { value: "CONSTANT", deeper: { value: $deeper } } } + ) contracts { id ... on LifeInsuranceContract { From 03d51e7d7d760cf4a7ade0b4e90636e07ba65678 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 22 Apr 2020 00:07:50 +0200 Subject: [PATCH 4/6] feat(Stiching): update test types --- ...elegationTests.ListVariableIsCorrectlyPassed_schema.snap | 2 ++ ...ionTests.ScopedListVariableIsCorrectlyPassed_schema.snap | 2 ++ .../Stitching.Tests/Schemas/Customers/ComplexInput.cs | 6 ++++++ .../StitchingBuilderTests.AddSchemaFromHttp.snap | 2 ++ .../__snapshots__/StitchingBuilderTests.AddSchema_2.snap | 2 ++ 5 files changed, 14 insertions(+) diff --git a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap index 7c58f817d51..4f7934329b6 100644 --- a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap +++ b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ListVariableIsCorrectlyPassed_schema.snap @@ -106,7 +106,9 @@ union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "custom input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { deeper: ComplexInputType + deeperArray: [ComplexInputType] value: String + valueArray: [String] } input CreateCustomerInput @source(name: "CreateCustomerInput", schema: "customer") { diff --git a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap index b1144ed4494..0c3413bed47 100644 --- a/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap +++ b/src/Stitching/Stitching.Tests/Middleware/__snapshots__/VariableDelegationTests.ScopedListVariableIsCorrectlyPassed_schema.snap @@ -107,7 +107,9 @@ union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "custom input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { deeper: ComplexInputType + deeperArray: [ComplexInputType] value: String + valueArray: [String] } input CreateCustomerInput @source(name: "CreateCustomerInput", schema: "customer") { diff --git a/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs index c647fc161c3..9703c3148ab 100644 --- a/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs +++ b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs @@ -3,6 +3,12 @@ namespace HotChocolate.Stitching.Schemas.Customers public class ComplexInput { public string Value { get; set; } + public ComplexInput Deeper { get; set; } + + public string[] ValueArray { get; set; } + + public ComplexInput[] DeeperArray { get; set; } + } } diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap index 96e77ca8caf..f2bb305413d 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromHttp.snap @@ -42,7 +42,9 @@ input SayInput @source(name: "SayInput", schema: "customer") { input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { deeper: ComplexInputType + deeperArray: [ComplexInputType] value: String + valueArray: [String] } "A connection to a list of items." diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap index cde329f41cc..b85cc403cf9 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchema_2.snap @@ -73,7 +73,9 @@ union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "custom input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { deeper: ComplexInputType + deeperArray: [ComplexInputType] value: String + valueArray: [String] } input CreateCustomerInput @source(name: "CreateCustomerInput", schema: "customer") { From 689fab2b9ec2223e93254877d173184550598ead Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 22 Apr 2020 00:14:19 +0200 Subject: [PATCH 5/6] feat(Stiching): update schema --- ...aMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap | 4 +++- ...sts.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap | 4 +++- ...aMergerTests.MergeDemoSchemaWithDefaultHandler.snap | 4 +++- .../Stitching.Tests/__resources__/Customer.graphql | 10 ++++++---- .../Stitching.Tests/__resources__/Stitching.graphql | 4 +++- .../StitchingBuilderTests.AddExtensionsFromFile.snap | 2 +- .../StitchingBuilderTests.AddExtensionsFromString.snap | 2 +- .../StitchingBuilderTests.AddSchemaFromFile.snap | 4 +++- .../StitchingBuilderTests.AddSchemaFromString.snap | 4 +++- 9 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap index 46913c76311..16ed220154b 100644 --- a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap +++ b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypes.snap @@ -27,6 +27,8 @@ type Consultant @source(name: "Consultant", schema: "B") { union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "B") = Customer | Consultant input ComplexInputType @source(name: "ComplexInputType", schema: "B") { - value: String deeper: ComplexInputType + deeperArray: [ComplexInputType] + value: String + valueArray: [String] } diff --git a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap index 59a5b4e5823..a7cad701900 100644 --- a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap +++ b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaAndRemoveRootTypesOnSchemaA.snap @@ -33,6 +33,8 @@ type Consultant @source(name: "Consultant", schema: "B") { union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "B") = Customer | Consultant input ComplexInputType @source(name: "ComplexInputType", schema: "B") { - value: String deeper: ComplexInputType + deeperArray: [ComplexInputType] + value: String + valueArray: [String] } diff --git a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap index 6fe45f19100..aad366330a0 100644 --- a/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap +++ b/src/Stitching/Stitching.Tests/Merge/__snapshots__/SchemaMergerTests.MergeDemoSchemaWithDefaultHandler.snap @@ -35,6 +35,8 @@ type Consultant @source(name: "Consultant", schema: "B") { union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "B") = Customer | Consultant input ComplexInputType @source(name: "ComplexInputType", schema: "B") { - value: String deeper: ComplexInputType + deeperArray: [ComplexInputType] + value: String + valueArray: [String] } diff --git a/src/Stitching/Stitching.Tests/__resources__/Customer.graphql b/src/Stitching/Stitching.Tests/__resources__/Customer.graphql index 7faa488a5ac..b336c3ecbc4 100644 --- a/src/Stitching/Stitching.Tests/__resources__/Customer.graphql +++ b/src/Stitching/Stitching.Tests/__resources__/Customer.graphql @@ -8,7 +8,7 @@ type Customer { id: ID! name: String! consultant: Consultant - complexArg(arg:ComplexInputType): String + complexArg(arg: ComplexInputType): String } type Consultant { @@ -16,9 +16,11 @@ type Consultant { name: String! } -union CustomerOrConsultant = Customer | Consultant +union CustomerOrConsultant = Customer | Consultant input ComplexInputType { - value: String deeper: ComplexInputType -} \ No newline at end of file + deeperArray: [ComplexInputType] + value: String + valueArray: [String] +} diff --git a/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql b/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql index 8baa3ea5369..de1d949afe4 100644 --- a/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql +++ b/src/Stitching/Stitching.Tests/__resources__/Stitching.graphql @@ -49,6 +49,8 @@ type SomeOtherContract implements Contract { union CustomerOrConsultant = Customer | Consultant input ComplexInputType { - value: String deeper: ComplexInputType + deeperArray: [ComplexInputType] + value: String + valueArray: [String] } diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap index 8a5b26d42c5..abb96473fd1 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromFile.snap @@ -1,4 +1,4 @@ [ "type Query {\n contract(contractId: ID!): Contract\n contracts(customerId: ID!): [Contract!]\n}\n\ninterface Contract {\n id: ID!\n}\n\ntype LifeInsuranceContract implements Contract {\n id: ID!\n premium: Float\n}\n\ntype SomeOtherContract implements Contract {\n id: ID!\n expiryDate: DateTime\n}", - "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n complexArg(arg: ComplexInputType): String\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant\n\ninput ComplexInputType {\n value: String\n deeper: ComplexInputType\n}" + "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n complexArg(arg: ComplexInputType): String\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant\n\ninput ComplexInputType {\n deeper: ComplexInputType\n deeperArray: [ComplexInputType]\n value: String\n valueArray: [String]\n}" ] diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap index 8a5b26d42c5..abb96473fd1 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddExtensionsFromString.snap @@ -1,4 +1,4 @@ [ "type Query {\n contract(contractId: ID!): Contract\n contracts(customerId: ID!): [Contract!]\n}\n\ninterface Contract {\n id: ID!\n}\n\ntype LifeInsuranceContract implements Contract {\n id: ID!\n premium: Float\n}\n\ntype SomeOtherContract implements Contract {\n id: ID!\n expiryDate: DateTime\n}", - "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n complexArg(arg: ComplexInputType): String\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant\n\ninput ComplexInputType {\n value: String\n deeper: ComplexInputType\n}" + "type Query {\n customer(id: ID!): Customer\n consultant(id: ID!): Consultant\n customerOrConsultant(id: ID!): CustomerOrConsultant\n}\n\ntype Customer {\n id: ID!\n name: String!\n consultant: Consultant\n complexArg(arg: ComplexInputType): String\n}\n\ntype Consultant {\n id: ID!\n name: String!\n}\n\nunion CustomerOrConsultant = Customer | Consultant\n\ninput ComplexInputType {\n deeper: ComplexInputType\n deeperArray: [ComplexInputType]\n value: String\n valueArray: [String]\n}" ] diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap index e73411b5db3..51df2ad57a1 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromFile.snap @@ -35,6 +35,8 @@ type Consultant @source(name: "Consultant", schema: "customer") { union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "customer") = Customer | Consultant input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { - value: String deeper: ComplexInputType + deeperArray: [ComplexInputType] + value: String + valueArray: [String] } diff --git a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap index e73411b5db3..51df2ad57a1 100644 --- a/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap +++ b/src/Stitching/Stitching.Tests/__snapshots__/StitchingBuilderTests.AddSchemaFromString.snap @@ -35,6 +35,8 @@ type Consultant @source(name: "Consultant", schema: "customer") { union CustomerOrConsultant @source(name: "CustomerOrConsultant", schema: "customer") = Customer | Consultant input ComplexInputType @source(name: "ComplexInputType", schema: "customer") { - value: String deeper: ComplexInputType + deeperArray: [ComplexInputType] + value: String + valueArray: [String] } From e9469f5a16a8f6bb8706a4096db1749d850a96ea Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 22 Apr 2020 00:25:10 +0200 Subject: [PATCH 6/6] feat(Stiching): add more complex tests --- .../Language/Visitors/QuerySyntaxRewriter.cs | 3 +++ .../Schemas/Customers/ComplexInput.cs | 1 - ...l_StitchingQueryWithVariables.graphql.snap | 4 ++-- ...writerTests.QueryWithPrivateVariables.snap | 4 ++-- .../StitchingQueryWithVariables.graphql | 19 +++++++++++++++++-- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/Core/Language/Visitors/QuerySyntaxRewriter.cs b/src/Core/Language/Visitors/QuerySyntaxRewriter.cs index 549b8639519..4deb91a604b 100644 --- a/src/Core/Language/Visitors/QuerySyntaxRewriter.cs +++ b/src/Core/Language/Visitors/QuerySyntaxRewriter.cs @@ -41,6 +41,9 @@ public virtual ISyntaxNode Rewrite( case ObjectValueNode objectValue: return RewriteObjectValue(objectValue, context); + case ListValueNode listValue: + return RewriteListValue(listValue, context); + case VariableNode variable: return RewriteVariable(variable, context); diff --git a/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs index 9703c3148ab..c4bb9ef2bf6 100644 --- a/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs +++ b/src/Stitching/Stitching.Tests/Schemas/Customers/ComplexInput.cs @@ -9,6 +9,5 @@ public class ComplexInput public string[] ValueArray { get; set; } public ComplexInput[] DeeperArray { get; set; } - } } diff --git a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap index 4cfd992259a..89a1461010f 100644 --- a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap +++ b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/ExtractFieldQuerySyntaxRewriterTests.ExtractField_Stitching.graphql_StitchingQueryWithVariables.graphql.snap @@ -1,11 +1,11 @@ -query fetch($customerId: ID!, $deep: String!, $deeper: String!) { +query fetch($customerId: ID!, $deep: String!, $deeperInArray: String, $deeper: String!, $deeperArray: String, $complex: ComplexInputType) { customer(id: $customerId) { name consultant { name __typename } - complexArg(arg: { value: $deep, deeper: { value: "CONSTANT", deeper: { value: $deeper } } }) + complexArg(arg: { value: $deep, deeperArray: [ "CONSTANT_IN_ARRAY", $deeperInArray ], deeper: { value: "CONSTANT", deeper: { value: $deeper } }, deeperArray: [ { value: "CONSTANT_ARRAY", deeper: { value: $deeperArray } }, $complex ] }) id __typename } diff --git a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap index 8a647162bf3..56a1d5bc2e3 100644 --- a/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap +++ b/src/Stitching/Stitching.Tests/Utilities/__snapshots__/MergeQueryRewriterTests.QueryWithPrivateVariables.snap @@ -1,4 +1,4 @@ -query exec_batch($_b_customerId: ID!, $_b_deep: String!, $_b_deeper: String!) { +query exec_batch($_b_customerId: ID!, $_b_deep: String!, $_b_deeper: String!, $_b_deeperArray: String, $_b_complex: ComplexInputType, $_b_deeperInArray: String) { _a_customer: customerOrConsultant(id: "Q3VzdG9tZXIKZDE=") { ... _a_customer ... _a_consultant @@ -12,7 +12,7 @@ consultant { name } - complexArg(arg: { value: $deep, deeper: { value: "CONSTANT", deeper: { value: $deeper } } }) + complexArg(arg: { value: $deep, deeperArray: [ "CONSTANT_IN_ARRAY", $deeperInArray ], deeper: { value: "CONSTANT", deeper: { value: $deeper } }, deeperArray: [ { value: "CONSTANT_ARRAY", deeper: { value: $deeperArray } }, $complex ] }) contracts { id ... on LifeInsuranceContract { diff --git a/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql b/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql index 161b993f005..698ed9bd763 100644 --- a/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql +++ b/src/Stitching/Stitching.Tests/__resources__/StitchingQueryWithVariables.graphql @@ -1,11 +1,26 @@ -query customer_query($customerId: ID!, $deep: String!, $deeper: String!) { +query customer_query( + $customerId: ID! + $deep: String! + $deeper: String! + $deeperArray: String + $complex: ComplexInputType + $deeperInArray: String +) { customer(id: $customerId) { name consultant { name } complexArg( - arg: { value: $deep, deeper: { value: "CONSTANT", deeper: { value: $deeper } } } + arg: { + value: $deep + deeperArray: ["CONSTANT_IN_ARRAY", $deeperInArray] + deeper: { value: "CONSTANT", deeper: { value: $deeper } } + deeperArray: [ + { value: "CONSTANT_ARRAY", deeper: { value: $deeperArray } } + $complex + ] + } ) contracts { id