-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix top level hydration * Add plain hydration * Functional solution
- Loading branch information
Showing
6 changed files
with
395 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
.../kotlin/graphql/nadel/tests/next/fixtures/batchHydration/BatchHydrationAtQueryTypeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package graphql.nadel.tests.next.fixtures.batchHydration | ||
|
||
import graphql.nadel.engine.util.strictAssociateBy | ||
import graphql.nadel.tests.next.NadelIntegrationTest | ||
|
||
class BatchHydrationAtQueryTypeTest : NadelIntegrationTest( | ||
query = """ | ||
query { | ||
myIssues { | ||
title | ||
} | ||
} | ||
""".trimIndent(), | ||
services = listOf( | ||
Service( | ||
name = "issues", | ||
overallSchema = """ | ||
type Query { | ||
issuesByIds(ids: [ID!]!): [Issue] | ||
myIssueKeys(limit: Int! = 25): [ID!] @hidden | ||
myIssues: [Issue] | ||
@hydrated( | ||
service: "issues" | ||
field: "issuesByIds" | ||
arguments: [{name: "ids", value: "$source.myIssueKeys"}] | ||
identifiedBy: "id" | ||
) | ||
} | ||
type Issue { | ||
id: ID! | ||
title: String | ||
} | ||
""".trimIndent(), | ||
runtimeWiring = { wiring -> | ||
data class Issue( | ||
val id: String, | ||
val title: String, | ||
) | ||
|
||
val issuesByIds = listOf( | ||
Issue(id = "hello", title = "Hello there"), | ||
Issue(id = "afternoon", title = "Good afternoon"), | ||
Issue(id = "bye", title = "Farewell"), | ||
).strictAssociateBy { it.id } | ||
|
||
wiring | ||
.type("Query") { type -> | ||
type | ||
.dataFetcher("issuesByIds") { env -> | ||
env.getArgument<List<String>>("ids") | ||
?.map { | ||
issuesByIds[it] | ||
} | ||
} | ||
.dataFetcher("myIssueKeys") { env -> | ||
listOf("hello", "bye") | ||
} | ||
} | ||
}, | ||
), | ||
), | ||
) |
Oops, something went wrong.