-
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.
- Loading branch information
Showing
6 changed files
with
375 additions
and
33 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
166 changes: 166 additions & 0 deletions
166
test/src/test/kotlin/graphql/nadel/tests/next/fixtures/defer/DeferOnListItemsTestSnapshot.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,166 @@ | ||
// @formatter:off | ||
package graphql.nadel.tests.next.fixtures.defer | ||
|
||
import graphql.nadel.tests.next.ExpectedNadelResult | ||
import graphql.nadel.tests.next.ExpectedServiceCall | ||
import graphql.nadel.tests.next.TestSnapshot | ||
import graphql.nadel.tests.next.listOfJsonStrings | ||
import kotlin.Suppress | ||
import kotlin.collections.List | ||
import kotlin.collections.listOf | ||
|
||
/** | ||
* This class is generated. Do NOT modify. | ||
* | ||
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots | ||
*/ | ||
@Suppress("unused") | ||
public class DeferOnListItemsTestSnapshot : TestSnapshot() { | ||
override val calls: List<ExpectedServiceCall> = listOf( | ||
ExpectedServiceCall( | ||
service = "defer", | ||
query = """ | ||
| { | ||
| defer { | ||
| list { | ||
| fast | ||
| ... @defer { | ||
| slow | ||
| } | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
variables = "{}", | ||
result = """ | ||
| { | ||
| "data": { | ||
| "defer": { | ||
| "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 | ||
* { | ||
* "data": { | ||
* "defer": { | ||
* "list": [ | ||
* { | ||
* "fast": "fastString", | ||
* "slow": "slowString" | ||
* }, | ||
* { | ||
* "fast": "fastString", | ||
* "slow": "slowString" | ||
* } | ||
* ] | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
override val result: ExpectedNadelResult = ExpectedNadelResult( | ||
result = """ | ||
| { | ||
| "data": { | ||
| "defer": { | ||
| "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(), | ||
), | ||
) | ||
} |
70 changes: 70 additions & 0 deletions
70
test/src/test/kotlin/graphql/nadel/tests/next/fixtures/defer/DeferWithErrorTest.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,70 @@ | ||
package graphql.nadel.tests.next.fixtures.defer | ||
|
||
import graphql.GraphqlErrorBuilder | ||
import graphql.execution.DataFetcherResult | ||
import graphql.nadel.NadelExecutionHints | ||
import graphql.nadel.tests.next.NadelIntegrationTest | ||
|
||
open class DeferWithErrorTest : NadelIntegrationTest( | ||
query = """ | ||
query { | ||
defer { | ||
hello | ||
... @defer(label: "slow-defer") { | ||
slow | ||
} | ||
} | ||
} | ||
""".trimIndent(), | ||
services = listOf( | ||
Service( | ||
name = "defer", | ||
overallSchema = """ | ||
directive @defer(if: Boolean, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
|
||
type Query { | ||
defer: DeferApi | ||
} | ||
type DeferApi { | ||
hello: String | ||
slow: String | ||
} | ||
|
||
""".trimIndent(), | ||
runtimeWiring = { wiring -> | ||
data class DeferApi( | ||
val hello: String, | ||
val slow: String, | ||
) | ||
|
||
wiring | ||
.type("Query") { type -> | ||
type | ||
.dataFetcher("defer") { env -> | ||
Any() | ||
} | ||
} | ||
.type("DeferApi") { type -> | ||
type | ||
.dataFetcher("hello") { env -> | ||
"helloString" | ||
} | ||
.dataFetcher("slow") { env -> | ||
DataFetcherResult.newResult<String>() | ||
.error( | ||
GraphqlErrorBuilder.newError() | ||
.message("An error occurred while fetching 'slow'") | ||
.build() | ||
) | ||
.build() | ||
} | ||
} | ||
}, | ||
), | ||
), | ||
) { | ||
override fun makeExecutionHints(): NadelExecutionHints.Builder { | ||
return super.makeExecutionHints() | ||
.deferSupport { true } | ||
} | ||
} |
Oops, something went wrong.