Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create working tests for complex list items #551

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ public class ComprehensiveDeferQueryWithDifferentServiceCallsSnapshot : TestSnap
| "path": [
| "user"
| ],
| "label": "team-details",
| "data": {
| "profilePicture": "https://examplesite.com/user/profile_picture.jpg"
| "teamName": "The Unicorns",
| "teamMembers": [
| "Felipe",
| "Franklin"
| ]
| }
| }
| ]
Expand All @@ -111,13 +116,8 @@ public class ComprehensiveDeferQueryWithDifferentServiceCallsSnapshot : TestSnap
| "path": [
| "user"
| ],
| "label": "team-details",
| "data": {
| "teamName": "The Unicorns",
| "teamMembers": [
| "Felipe",
| "Franklin"
| ]
| "profilePicture": "https://examplesite.com/user/profile_picture.jpg"
| }
| }
| ]
Expand All @@ -133,12 +133,12 @@ public class ComprehensiveDeferQueryWithDifferentServiceCallsSnapshot : TestSnap
* "data": {
* "user": {
* "name": "Steven",
* "profilePicture": "https://examplesite.com/user/profile_picture.jpg",
* "teamName": "The Unicorns",
* "teamMembers": [
* "Felipe",
* "Franklin"
* ],
* "profilePicture": "https://examplesite.com/user/profile_picture.jpg"
* ]
* },
* "product": {
* "productName": "Awesome Product",
Expand Down Expand Up @@ -188,8 +188,13 @@ public class ComprehensiveDeferQueryWithDifferentServiceCallsSnapshot : TestSnap
| "path": [
| "user"
| ],
| "label": "team-details",
| "data": {
| "profilePicture": "https://examplesite.com/user/profile_picture.jpg"
| "teamName": "The Unicorns",
| "teamMembers": [
| "Felipe",
| "Franklin"
| ]
| }
| }
| ]
Expand All @@ -203,13 +208,8 @@ public class ComprehensiveDeferQueryWithDifferentServiceCallsSnapshot : TestSnap
| "path": [
| "user"
| ],
| "label": "team-details",
| "data": {
| "teamName": "The Unicorns",
| "teamMembers": [
| "Felipe",
| "Franklin"
| ]
| "profilePicture": "https://examplesite.com/user/profile_picture.jpg"
| }
| }
| ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package graphql.nadel.tests.next.fixtures.defer
import graphql.nadel.NadelExecutionHints
import graphql.nadel.tests.next.NadelIntegrationTest

open class DeferOnListItems : NadelIntegrationTest(
open class DeferOnListItemsTest : NadelIntegrationTest(
query = """
query {
defer {
Expand Down Expand Up @@ -45,17 +45,23 @@ open class DeferOnListItems : NadelIntegrationTest(
}
.type("DeferApi") { type ->
type
.dataFetcher("list") {
type
.dataFetcher("hello") { env ->
"helloString"
}
.dataFetcher("slow") { env ->
"slowString"
}
.dataFetcher("list") { env ->
listOf(
mapOf<String, Any>(),
mapOf<String, Any>(),
)
}
}
},
.type("Test") { type ->
type
.dataFetcher("fast") { env ->
"fastString"
}
.dataFetcher("slow") { env ->
"slowString"
}
}
}
),
),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,75 @@ public class DeferOnListItemsSnapshot : TestSnapshot() {
variables = "{}",
result = """
| {
| "errors": [
| {
| "message": "Can't resolve value (/defer/list) : type mismatch error, expected type LIST",
| "path": [
| "defer",
| "list"
| ],
| "extensions": {
| "classification": "DataFetchingException"
| }
| }
| ],
| "data": {
| "defer": {
| "list": null
| "list": [
| {
| "fast": "fastString"
| },
| {
| "fast": "fastString"
| }
| ]
| }
| }
| },
| "hasNext": true
| }
""".trimMargin(),
delayedResults = listOfJsonStrings(
"""
| {
| "hasNext": false,
| "incremental": [
| {
| "path": [
| "defer",
| "list",
| 1
| ],
| "data": {
| "slow": "slowString"
| }
| }
| ]
| }
""".trimMargin(),
"""
| {
| "hasNext": true,
| "incremental": [
| {
| "path": [
| "defer",
| "list",
| 0
| ],
| "data": {
| "slow": "slowString"
| }
| }
| ]
| }
""".trimMargin(),
),
),
)

/**
* ```json
* {
* "errors": [
* {
* "message": "Can't resolve value (/defer/list) : type mismatch error, expected type
* LIST",
* "locations": [],
* "path": [
* "defer",
* "list"
* ],
* "extensions": {
* "classification": "DataFetchingException"
* }
* }
* ],
* "data": {
* "defer": {
* "list": null
* "list": [
* {
* "fast": "fastString",
* "slow": "slowString"
* },
* {
* "fast": "fastString",
* "slow": "slowString"
* }
* ]
* }
* }
* }
Expand All @@ -86,27 +111,56 @@ public class DeferOnListItemsSnapshot : TestSnapshot() {
override val result: ExpectedNadelResult = ExpectedNadelResult(
result = """
| {
| "errors": [
| {
| "message": "Can't resolve value (/defer/list) : type mismatch error, expected type LIST",
| "locations": [],
| "path": [
| "defer",
| "list"
| ],
| "extensions": {
| "classification": "DataFetchingException"
| }
| }
| ],
| "data": {
| "defer": {
| "list": null
| "list": [
| {
| "fast": "fastString"
| },
| {
| "fast": "fastString"
| }
| ]
| }
| }
| },
| "hasNext": true
| }
""".trimMargin(),
delayedResults = listOfJsonStrings(
"""
| {
| "hasNext": false,
| "incremental": [
| {
| "path": [
| "defer",
| "list",
| 1
| ],
| "data": {
| "slow": "slowString"
| }
| }
| ]
| }
""".trimMargin(),
"""
| {
| "hasNext": true,
| "incremental": [
| {
| "path": [
| "defer",
| "list",
| 0
| ],
| "data": {
| "slow": "slowString"
| }
| }
| ]
| }
""".trimMargin(),
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public class NestedDefersTestSnapshot : TestSnapshot() {
| "path": [
| "defer"
| ],
| "label": "outer defer",
| "label": "inner defer",
| "data": {
| "slowField1": null
| "slowField2": null
| }
| }
| ]
Expand All @@ -68,9 +68,9 @@ public class NestedDefersTestSnapshot : TestSnapshot() {
| "path": [
| "defer"
| ],
| "label": "inner defer",
| "label": "outer defer",
| "data": {
| "slowField2": null
| "slowField1": null
| }
| }
| ]
Expand All @@ -86,8 +86,8 @@ public class NestedDefersTestSnapshot : TestSnapshot() {
* "data": {
* "defer": {
* "fastField": null,
* "slowField2": null,
* "slowField1": null
* "slowField1": null,
* "slowField2": null
* }
* }
* }
Expand All @@ -113,9 +113,9 @@ public class NestedDefersTestSnapshot : TestSnapshot() {
| "path": [
| "defer"
| ],
| "label": "outer defer",
| "label": "inner defer",
| "data": {
| "slowField1": null
| "slowField2": null
| }
| }
| ]
Expand All @@ -129,9 +129,9 @@ public class NestedDefersTestSnapshot : TestSnapshot() {
| "path": [
| "defer"
| ],
| "label": "inner defer",
| "label": "outer defer",
| "data": {
| "slowField2": null
| "slowField1": null
| }
| }
| ]
Expand Down
Loading