Skip to content

Commit

Permalink
Create working tests for complex list items
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarker2 committed Jun 18, 2024
1 parent 4b307cc commit 50c4bdc
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 80 deletions.
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

0 comments on commit 50c4bdc

Please sign in to comment.