Skip to content

Commit

Permalink
More map for byId fields
Browse files Browse the repository at this point in the history
  • Loading branch information
gnawf committed Jan 2, 2025
1 parent bb0595d commit a8cacd0
Show file tree
Hide file tree
Showing 30 changed files with 210 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private suspend fun main() {
/**
* This class is generated. Do NOT modify.
*
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots]
*/
@Suppress("unused")
public class `deep rename inside batch hydration null object snapshot` : TestSnapshot() {
Expand Down Expand Up @@ -46,14 +46,14 @@ public class `deep rename inside batch hydration null object snapshot` : TestSna
| "__typename__deep_rename__name": "Issue",
| "batch_hydration__issue__id": "issue-1"
| },
| null,
| {
| "deep_rename__name__detail": {
| "detailName": "Names are arbitrary"
| },
| "__typename__deep_rename__name": "Issue",
| "batch_hydration__issue__id": "issue-3"
| },
| null
| }
| ]
| }
| }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,23 @@ class `deep rename inside batch hydration null object` : NadelLegacyIntegrationT
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val issuesByIds = listOf(
IssueService_Issue(
detail = IssueService_IssueDetails(
detailName = "Memes are the DNA of the soul",
),
id = "issue-1",
),
IssueService_Issue(
detail = IssueService_IssueDetails(
detailName = "Names are arbitrary",
),
id = "issue-3",
),
).associateBy { it.id }

type.dataFetcher("issuesByIds") { env ->
if (env.getArgument<Any?>("id") == listOf("issue-1", "issue-2", "issue-3")) {
listOf(
IssueService_Issue(
detail = IssueService_IssueDetails(
detailName = "Memes are the DNA of the soul",
),
id = "issue-1",
),
IssueService_Issue(
detail = IssueService_IssueDetails(detailName = "Names are arbitrary"),
id = "issue-3",
),
null,
)
} else {
null
}
env.getArgument<List<String>>("id")?.map(issuesByIds::get)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ class `basic hydration with default array argument values` : NadelLegacyIntegrat
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val barById = listOf(
Service2_Bar(id = "barId", name = "Bar1"),
).associateBy { it.id }

type.dataFetcher("barById") { env ->
if (env.getArgument<Any?>("id") == "barId" &&
env.getArgument<Any?>("test") ==
listOf("Hello", "World")
) {
Service2_Bar(name = "Bar1")
if (env.getArgument<Any?>("test") == listOf("Hello", "World")) {
barById[env.getArgument<String>("id")]
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ class `basic hydration with static arg array` : NadelLegacyIntegrationTest(
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val barById = listOf(
Service2_Bar(id = "barId", name = "Bar1")
).associateBy { it.id }

type.dataFetcher("barById") { env ->
if (env.getArgument<Any?>("id") == "barId" &&
env.getArgument<Any?>("friendIds") ==
listOf("barId2", "barId3", "barId4")
) {
Service2_Bar(name = "Bar1")
if (env.getArgument<Any?>("friendIds") == listOf("barId2", "barId3", "barId4")) {
barById[env.getArgument<String>("id")]
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,19 @@ class `basic hydration with static arg object array` : NadelLegacyIntegrationTes
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val barById = listOf(
Service2_Bar(id = "barId", name = "Bar1")
).associateBy { it.id }

val secret = listOf(
mapOf("firstName" to "first", "lastName" to "last"),
mapOf("firstName" to "first2", "lastName" to "last2"),
mapOf("firstName" to "first3", "lastName" to "last3"),
)

type.dataFetcher("barById") { env ->
if (env.getArgument<Any?>("id") == "barId" &&
env.getArgument<Any?>("friends") ==
listOf(
mapOf("firstName" to "first", "lastName" to "last"),
mapOf(
"firstName" to "first2",
"lastName" to "last2",
),
mapOf(
"firstName" to "first3",
"lastName" to "last3",
),
)
) {
Service2_Bar(name = "Bar1")
if (env.getArgument<Any?>("friends") == secret) {
barById[env.getArgument<String>("id")]
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ class `batching absent source input` : NadelLegacyIntegrationTest(
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val commentsById = listOf(
Comments_Comment(content = "It's over 9000", id = "comment/9001"),
).associateBy { it.id }

type.dataFetcher("commentsByIds") { env ->
if (env.getArgument<Any?>("ids") == listOf("comment/9001")) {
listOf(Comments_Comment(content = "It's over 9000", id = "comment/9001"))
} else {
null
}
env.getArgument<List<String>>("ids")?.map(commentsById::get)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private suspend fun main() {
/**
* This class is generated. Do NOT modify.
*
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots]
*/
@Suppress("unused")
public class `batching conditional hydration in abstract type snapshot` : TestSnapshot() {
Expand Down Expand Up @@ -103,15 +103,15 @@ public class `batching conditional hydration in abstract type snapshot` : TestSn
| },
| {
| "__typename": "Comment",
| "id": "comment/9001",
| "content": "It's over 9000",
| "batch_hydration__content__id": "comment/9001"
| },
| {
| "__typename": "Comment",
| "id": "comment/1234",
| "content": "One Two Three Four",
| "batch_hydration__content__id": "comment/1234"
| },
| {
| "__typename": "Comment",
| "id": "comment/9001",
| "content": "It's over 9000",
| "batch_hydration__content__id": "comment/9001"
| }
| ]
| }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ class `batching conditional hydration in abstract type` : NadelLegacyIntegration
Monolith_Issue(id = "issue/4000", title = "Four Thousand"),
Monolith_Issue(id = "issue/7496", title = "Seven Four Nine Six"),
).associateBy { it.id }
val commentsById = listOf(
Monolith_Comment(content = "Five Thousand", id = "comment/5000"),
Monolith_Comment(content = "Six Thousand", id = "comment/6000"),
Monolith_Comment(content = "It's over 9000", id = "comment/9001"),
Monolith_Comment(content = "One Two Three Four", id = "comment/1234"),
).associateBy { it.id }

type
.dataFetcher("activity") { env ->
Expand All @@ -127,23 +133,7 @@ class `batching conditional hydration in abstract type` : NadelLegacyIntegration
env.getArgument<List<String>>("ids")?.mapNotNull(issuesById::get)
}
.dataFetcher("commentsByIds") { env ->
if (env.getArgument<Any?>("ids") ==
listOf(
"comment/5000",
"comment/6000",
"comment/1234",
"comment/9001",
)
) {
listOf(
Monolith_Comment(content = "Five Thousand", id = "comment/5000"),
Monolith_Comment(content = "Six Thousand", id = "comment/6000"),
Monolith_Comment(content = "It's over 9000", id = "comment/9001"),
Monolith_Comment(content = "One Two Three Four", id = "comment/1234"),
)
} else {
null
}
env.getArgument<List<String>>("ids")?.map(commentsById::get)
}
}
wiring.type("ActivityContent") { type ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,27 @@ class `batching multiple source ids going to different services` : NadelLegacyIn
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val issuesById = listOf(
Issues_Issue(
id = "issue/4000",
title = "Four Thousand",
),
Issues_Issue(
id = "issue/8080",
title = "Eighty Eighty",
),
Issues_Issue(
id = "issue/7496",
title = "Seven Four Nine Six",
),
Issues_Issue(
id = "issue/1234",
title = "One Two Three Four",
),
).associateBy { it.id }

type.dataFetcher("issuesByIds") { env ->
if (env.getArgument<Any?>("ids") ==
listOf(
"issue/4000",
"issue/8080",
"issue/7496",
"issue/1234",
)
) {
listOf(
Issues_Issue(id = "issue/4000", title = "Four Thousand"),
Issues_Issue(
id = "issue/8080",
title = "Eighty Eighty",
),
Issues_Issue(
id = "issue/7496",
title = "Seven Four Nine Six",
),
Issues_Issue(
id = "issue/1234",
title = "One Two Three Four",
),
)
} else {
null
}
env.getArgument<List<String>>("ids")?.mapNotNull(issuesById::get)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private suspend fun main() {
/**
* This class is generated. Do NOT modify.
*
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots]
*/
@Suppress("unused")
public class `batching no source inputs snapshot` : TestSnapshot() {
Expand Down Expand Up @@ -85,15 +85,15 @@ public class `batching no source inputs snapshot` : TestSnapshot() {
| "commentsByIds": [
| {
| "__typename": "Comment",
| "id": "comment/1234",
| "content": "One Two Three Four",
| "batch_hydration__content__id": "comment/1234"
| },
| {
| "__typename": "Comment",
| "id": "comment/9001",
| "content": "It's over 9000",
| "batch_hydration__content__id": "comment/9001"
| },
| {
| "__typename": "Comment",
| "id": "comment/1234",
| "content": "One Two Three Four",
| "batch_hydration__content__id": "comment/1234"
| }
| ]
| }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,13 @@ class `batching no source inputs` : NadelLegacyIntegrationTest(
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val commentsById = listOf(
Comments_Comment(content = "One Two Three Four", id = "comment/1234"),
Comments_Comment(content = "It's over 9000", id = "comment/9001"),
).associateBy { it.id }

type.dataFetcher("commentsByIds") { env ->
if (env.getArgument<Any?>("ids") == listOf("comment/9001", "comment/1234")) {
listOf(
Comments_Comment(content = "One Two Three Four", id = "comment/1234"),
Comments_Comment(content = "It's over 9000", id = "comment/9001"),
)
} else {
null
}
env.getArgument<List<String>>("ids")?.map(commentsById::get)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ class `batching single source id` : NadelLegacyIntegrationTest(
""".trimIndent(),
runtimeWiring = { wiring ->
wiring.type("Query") { type ->
val commentsById = listOf(
Comments_Comment(content = "One Two Three Four", id = "comment/1234")
).associateBy { it.id }

type.dataFetcher("commentsByIds") { env ->
if (env.getArgument<Any?>("ids") == listOf("comment/1234")) {
listOf(Comments_Comment(content = "One Two Three Four", id = "comment/1234"))
} else {
null
}
env.getArgument<List<String>>("ids")?.map(commentsById::get)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,9 @@ class `complex identified by doesnt use all input fields in the inputIdentifiedB
type.dataFetcher("issues") { env ->
if (env.getArgument<Any?>("issuesInput") ==
listOf(
mapOf(
"id" to "ISSUE-0",
"site" to "CLOUD-0",
),
mapOf("id" to "ISSUE-0", "site" to "CLOUD-0"),
mapOf("id" to "ISSUE-1", "site" to "CLOUD-0"),
mapOf(
"id" to "ISSUE-2",
"site" to "CLOUD-0",
),
mapOf("id" to "ISSUE-2", "site" to "CLOUD-0"),
mapOf("id" to "ISSUE-3", "site" to "CLOUD-0"),
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,9 @@ class `complex identified by with indexed hydration` : NadelLegacyIntegrationTes
type.dataFetcher("issues") { env ->
if (env.getArgument<Any?>("issuesInput") ==
listOf(
mapOf(
"id" to "ISSUE-0",
"site" to "CLOUD-0",
),
mapOf("id" to "ISSUE-0", "site" to "CLOUD-0"),
mapOf("id" to "ISSUE-1", "site" to "CLOUD-0"),
mapOf(
"id" to "ISSUE-2",
"site" to "CLOUD-0",
),
mapOf("id" to "ISSUE-2", "site" to "CLOUD-0"),
mapOf("id" to "ISSUE-3", "site" to "CLOUD-0"),
)
) {
Expand Down
Loading

0 comments on commit a8cacd0

Please sign in to comment.