diff --git a/test/src/test/kotlin/graphql/nadel/tests/hooks/batching-of-hydration-list-with-partition.kt b/test/src/test/kotlin/graphql/nadel/tests/hooks/batching-of-hydration-list-with-partition.kt index 91d816e61..d6b32199a 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/hooks/batching-of-hydration-list-with-partition.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/hooks/batching-of-hydration-list-with-partition.kt @@ -41,6 +41,13 @@ class `batching-of-hydration-list-with-partition` : EngineTestHook { } } +@UseHook +class `new-batching-of-hydration-list-with-partition-2` : EngineTestHook { + override fun makeNadel(builder: Nadel.Builder): Nadel.Builder { + return builder.executionHooks(BatchHydrationHooks()) + } +} + @UseHook class `index-hydration-with-partitioned-inputs` : EngineTestHook { override fun makeExecutionHints( diff --git a/test/src/test/resources/fixtures/new hydration/new-batching-of-hydration-list-with-partition-2.yml b/test/src/test/resources/fixtures/new hydration/new-batching-of-hydration-list-with-partition-2.yml new file mode 100644 index 000000000..d5f8eec9e --- /dev/null +++ b/test/src/test/resources/fixtures/new hydration/new-batching-of-hydration-list-with-partition-2.yml @@ -0,0 +1,186 @@ +name: "new batching of hydration list with partition 2" +enabled: true +overallSchema: + # language=GraphQL + UserService: | + type Query { + usersByIds(id: [ID]): [User] + } + type User { + id: ID + } + # language=GraphQL + Issues: | + type Query { + issues: [Issue] + } + type Issue { + id: ID + authors: [User] + @hydrated( + service: "UserService" + field: "usersByIds" + arguments: [{name: "id" value: "$source.authorIds"}] + identifiedBy: "id" + batchSize: 90 + ) + } +underlyingSchema: + # language=GraphQL + UserService: | + type Query { + usersByIds(id: [ID]): [User] + } + + type User { + id: ID + } + # language=GraphQL + Issues: | + type Issue { + authorIds: [ID] + id: ID + } + + type Query { + issues: [Issue] + } +# language=GraphQL +query: | + query { + issues { + id + authors { + id + } + } + } +variables: { } +serviceCalls: + - serviceName: "Issues" + request: + # language=GraphQL + query: | + query { + issues { + __typename__batch_hydration__authors: __typename + batch_hydration__authors__authorIds: authorIds + id + } + } + variables: { } + # language=JSON + response: |- + { + "data": { + "issues": [ + { + "__typename__batch_hydration__authors": "Issue", + "batch_hydration__authors__authorIds": [ + "site-1/user-1", + "site-2/user-2" + ], + "id": "issue-1" + }, + { + "__typename__batch_hydration__authors": "Issue", + "batch_hydration__authors__authorIds": [ + ], + "id": "issue-2" + }, + { + "__typename__batch_hydration__authors": "Issue", + "batch_hydration__authors__authorIds": [ + "site-2/user-4" + ], + "id": "issue-3" + } + ] + }, + "extensions": {} + } + - serviceName: "UserService" + request: + # language=GraphQL + query: | + query { + usersByIds(id: ["site-1/user-1"]) { + id + batch_hydration__authors__id: id + } + } + variables: { } + # language=JSON + response: |- + { + "data": { + "usersByIds": [ + { + "id": "site-1/user-1", + "batch_hydration__authors__id": "site-1/user-1" + } + ] + }, + "extensions": {} + } + - serviceName: "UserService" + request: + # language=GraphQL + query: | + query { + usersByIds(id: ["site-2/user-2", "site-2/user-4"]) { + id + batch_hydration__authors__id: id + } + } + variables: { } + # language=JSON + response: |- + { + "data": { + "usersByIds": [ + { + "id": "site-2/user-2", + "batch_hydration__authors__id": "site-2/user-2" + }, + { + "id": "site-2/user-4", + "batch_hydration__authors__id": "site-2/user-4" + } + ] + }, + "extensions": {} + } +# language=JSON +response: |- + { + "data": { + "issues": [ + { + "id": "issue-1", + "authors": [ + { + "id": "site-1/user-1" + }, + { + "id": "site-2/user-2" + } + ] + }, + { + "id": "issue-2", + "authors": [ + ] + }, + { + "id": "issue-3", + "authors": [ + { + "id": "site-2/user-4" + } + ] + } + ] + }, + "extensions": {} + }