diff --git a/src/test/groovy/com/intuit/graphql/orchestrator/integration/MutationNestedFieldsArgumentsSpec.groovy b/src/test/groovy/com/intuit/graphql/orchestrator/integration/MutationNestedFieldsArgumentsSpec.groovy index 59917c55..d6418855 100644 --- a/src/test/groovy/com/intuit/graphql/orchestrator/integration/MutationNestedFieldsArgumentsSpec.groovy +++ b/src/test/groovy/com/intuit/graphql/orchestrator/integration/MutationNestedFieldsArgumentsSpec.groovy @@ -1,17 +1,37 @@ package com.intuit.graphql.orchestrator.integration import com.intuit.graphql.orchestrator.GraphQLOrchestrator -import com.intuit.graphql.orchestrator.ServiceD -import com.intuit.graphql.orchestrator.ServiceE import com.intuit.graphql.orchestrator.ServiceProvider import com.intuit.graphql.orchestrator.schema.transform.FieldMergeException import helpers.BaseIntegrationTestSpecification class MutationNestedFieldsArgumentsSpec extends BaseIntegrationTestSpecification { + def mockDServiceResponse = [ + data: [ + serviceD: [] + ] + ] + + def mockEServiceResponse = [ + data: [ + serviceD: [] + ] + ] def "cannot Build Due To Mutation Nested Fields Has Mismatched Arguments"() { + def serviceD = createSimpleMockService( "SVCD", "type Query { } " + + "type Mutation { container(in : String) : Container } " + + "type Container { serviceD : ServiceD } " + + "type ServiceD { svcDField1 : String }", mockDServiceResponse) + + def serviceE = createSimpleMockService( "SVCE", "type Query { } " + + "type Mutation { container(out : String) : Container } " + + "type Container { serviceE : ServiceE } " + + "type ServiceE { svcEField1 : String }", mockEServiceResponse) + + given: - ServiceProvider[] services = [ new ServiceD(), new ServiceE() ] + ServiceProvider[] services = [ serviceD, serviceE ] when: GraphQLOrchestrator orchestrator = createGraphQLOrchestrator(services) diff --git a/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsArgumentsSpec.groovy b/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsArgumentsSpec.groovy index 19085fc5..000f6aca 100644 --- a/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsArgumentsSpec.groovy +++ b/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsArgumentsSpec.groovy @@ -1,17 +1,35 @@ package com.intuit.graphql.orchestrator.integration import com.intuit.graphql.orchestrator.GraphQLOrchestrator -import com.intuit.graphql.orchestrator.ServiceA -import com.intuit.graphql.orchestrator.ServiceB import com.intuit.graphql.orchestrator.ServiceProvider import com.intuit.graphql.orchestrator.schema.transform.FieldMergeException import helpers.BaseIntegrationTestSpecification class NestedFieldsArgumentsSpec extends BaseIntegrationTestSpecification { + def mockAServiceResponse = [ + data: [ + serviceA: [] + ] + ] + + def mockBServiceResponse = [ + data: [ + serviceB: [] + ] + ] def "cannot Build Due To Query Nested Fields Has Mismatched Arguments"() { + def serviceA = createSimpleMockService( "SVCA", "type Query { container : Container } " + + "type Container { serviceA : ServiceA } " + + "type ServiceA { svcAField1 : String }", mockAServiceResponse) + + def serviceB = createSimpleMockService( "SVCB", "type Query { container(in : String) : Container } " + + "type Container { serviceB : ServiceB } " + + "type ServiceB { svcBField1 : String }", mockBServiceResponse) + + when: - ServiceProvider[] services = [ new ServiceA(), new ServiceB() ] + ServiceProvider[] services = [ serviceA, serviceB ] GraphQLOrchestrator orchestrator = createGraphQLOrchestrator(services) then: diff --git a/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsDirectivesSpec.groovy b/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsDirectivesSpec.groovy index 916986cb..19d9a336 100644 --- a/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsDirectivesSpec.groovy +++ b/src/test/groovy/com/intuit/graphql/orchestrator/integration/NestedFieldsDirectivesSpec.groovy @@ -1,17 +1,37 @@ package com.intuit.graphql.orchestrator.integration import com.intuit.graphql.orchestrator.GraphQLOrchestrator -import com.intuit.graphql.orchestrator.ServiceA -import com.intuit.graphql.orchestrator.ServiceC import com.intuit.graphql.orchestrator.ServiceProvider import com.intuit.graphql.orchestrator.schema.transform.FieldMergeException import helpers.BaseIntegrationTestSpecification class NestedFieldsDirectivesSpec extends BaseIntegrationTestSpecification { + def mockAServiceResponse = [ + data: [ + serviceA: [] + ] + ] + + def mockCServiceResponse = [ + data: [ + serviceC: [] + ] + ] + + def "cannot Build Due To Query Nested Fields Has Mismatched Directives"() { + def serviceA = createSimpleMockService( "SVCA", "type Query { container : Container } " + + "type Container { serviceA : ServiceA } " + + "type ServiceA { svcAField1 : String }", mockAServiceResponse) + + def serviceC = createSimpleMockService( "SVCC", "type Query { container : Container @deprecated } " + + "type Container { serviceC : ServiceC } " + + "type ServiceC { svcCField1 : String }", mockCServiceResponse) + + when: - ServiceProvider[] services = [new ServiceA(), new ServiceC() ] + ServiceProvider[] services = [serviceA, serviceC] GraphQLOrchestrator orchestrator = createGraphQLOrchestrator(services) then: diff --git a/src/test/java/com/intuit/graphql/orchestrator/ServiceA.java b/src/test/java/com/intuit/graphql/orchestrator/ServiceA.java deleted file mode 100644 index 4e44e146..00000000 --- a/src/test/java/com/intuit/graphql/orchestrator/ServiceA.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.intuit.graphql.orchestrator; - -import com.google.common.collect.ImmutableMap; -import graphql.ExecutionInput; -import graphql.GraphQLContext; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -public class ServiceA implements ServiceProvider { - - ServiceA() { - } - - @Override - public String getNameSpace() { - return "SVCA"; - } - - @Override - public Map sdlFiles() { - String schema = "type Query { container : Container } " - + "type Container { serviceA : ServiceA } " - + "type ServiceA { svcAField1 : String }"; - return ImmutableMap.of("svca-schema.graphqls", schema); - } - - @Override - public CompletableFuture> query(ExecutionInput executionInput, - GraphQLContext context) { - // this is intended to fail during stitching - // this will not be called - return null; - } -} diff --git a/src/test/java/com/intuit/graphql/orchestrator/ServiceB.java b/src/test/java/com/intuit/graphql/orchestrator/ServiceB.java deleted file mode 100644 index 9f29165b..00000000 --- a/src/test/java/com/intuit/graphql/orchestrator/ServiceB.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.intuit.graphql.orchestrator; - -import com.google.common.collect.ImmutableMap; -import graphql.ExecutionInput; -import graphql.GraphQLContext; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -public class ServiceB implements ServiceProvider { - - ServiceB() { - } - - @Override - public String getNameSpace() { - return "SVCB"; - } - - @Override - public Map sdlFiles() { - String schema = "type Query { container(in : String) : Container } " - + "type Container { serviceB : ServiceB } " - + "type ServiceB { svcBField1 : String }"; - return ImmutableMap.of("svcb-schema.graphqls", schema); - } - - @Override - public CompletableFuture> query(ExecutionInput executionInput, - GraphQLContext context) { - // this is intended to fail during stitching - // this will not be called - return null; - } -} diff --git a/src/test/java/com/intuit/graphql/orchestrator/ServiceC.java b/src/test/java/com/intuit/graphql/orchestrator/ServiceC.java deleted file mode 100644 index 7b74b240..00000000 --- a/src/test/java/com/intuit/graphql/orchestrator/ServiceC.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.intuit.graphql.orchestrator; - -import com.google.common.collect.ImmutableMap; -import graphql.ExecutionInput; -import graphql.GraphQLContext; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -public class ServiceC implements ServiceProvider { - - ServiceC() { - } - - @Override - public String getNameSpace() { - return "SVCC"; - } - - @Override - public Map sdlFiles() { - String schema = "type Query { container : Container @deprecated } " - + "type Container { serviceC : ServiceC } " - + "type ServiceC { svcCField1 : String }"; - - return ImmutableMap.of("svcc-schema.graphqls", schema); - } - - @Override - public CompletableFuture> query(ExecutionInput executionInput, - GraphQLContext context) { - // this is intended to fail during stitching - // this will not be called - return null; - } -} diff --git a/src/test/java/com/intuit/graphql/orchestrator/ServiceD.java b/src/test/java/com/intuit/graphql/orchestrator/ServiceD.java deleted file mode 100644 index e91c707c..00000000 --- a/src/test/java/com/intuit/graphql/orchestrator/ServiceD.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.intuit.graphql.orchestrator; - -import com.google.common.collect.ImmutableMap; -import graphql.ExecutionInput; -import graphql.GraphQLContext; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -public class ServiceD implements ServiceProvider { - - ServiceD() { - } - - @Override - public String getNameSpace() { - return "SVCD"; - } - - @Override - public Map sdlFiles() { - String schema = "type Query { } " - + "type Mutation { container(in : String) : Container } " - + "type Container { serviceD : ServiceD } " - + "type ServiceD { svcDField1 : String }"; - return ImmutableMap.of("svcd-schema.graphqls", schema); - } - - @Override - public CompletableFuture> query(ExecutionInput executionInput, - GraphQLContext context) { - // this is intended to fail during stitching - // this will not be called - return null; - } -} diff --git a/src/test/java/com/intuit/graphql/orchestrator/ServiceE.java b/src/test/java/com/intuit/graphql/orchestrator/ServiceE.java deleted file mode 100644 index c8dda658..00000000 --- a/src/test/java/com/intuit/graphql/orchestrator/ServiceE.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.intuit.graphql.orchestrator; - -import com.google.common.collect.ImmutableMap; -import graphql.ExecutionInput; -import graphql.GraphQLContext; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -public class ServiceE implements ServiceProvider { - - ServiceE() { - } - - @Override - public String getNameSpace() { - return "SVCE"; - } - - @Override - public Map sdlFiles() { - String schema = "type Query { } " - + "type Mutation { container(out : String) : Container } " - + "type Container { serviceE : ServiceE } " - + "type ServiceE { svcEField1 : String }"; - - return ImmutableMap.of("svce-schema.graphqls", schema); - } - - @Override - public CompletableFuture> query(ExecutionInput executionInput, - GraphQLContext context) { - // this is intended to fail during stitching - // this will not be called - return null; - } -}