-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add tests for remaining transforms with defer #590
Open
sbarker2
wants to merge
27
commits into
master
Choose a base branch
from
add-other-transforms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
6f25a60
add error test for defer (#574)
sbarker2 aa1248a
add initial defer transform tests (#576)
sbarker2 96654b7
initial defer logic (#577)
sbarker2 5a8e505
get transforms actually working for deferred payloads (#578)
sbarker2 7ea4f4c
improve JsonNodes class
sbarker2 d64d395
passing in NadelQueryPath instead of List<String> to allow better typ…
sbarker2 8d98b98
remove unused if block
sbarker2 876b302
add ability to log errors for defer transforms
sbarker2 76cfa21
add extra defer tests for fields in lists and fields in hydrations
sbarker2 59de250
move processing of graphql errors
sbarker2 8d1d18b
remove incorrect test
sbarker2 83ceb7f
remove unused test
sbarker2 fe5827d
add logic to move transform functions next to each other
sbarker2 ceb3c56
add level of abstraction for reused code in transform functions
sbarker2 35d74db
add assertShouldNeverHappen when prefix does not match query path in …
sbarker2 75285f7
add deep deferred rename transform test
sbarker2 b3196a1
remove empty file
sbarker2 96cd51d
clean up defer transform code
sbarker2 fc34be3
Merge branch 'apply-transforms-to-defer-payloads' into add-other-tran…
sbarker2 92863a1
add tests for other transforms
sbarker2 691665f
add defer to deep rename transform test
sbarker2 d0b7eb3
Merge branch 'master' into add-other-transforms
sbarker2 1037769
add tests for other transforms
sbarker2 b1165ac
Merge branch 'master' into add-other-transforms
sbarker2 1f57de1
remove unused test snapshot
sbarker2 7a52d51
fix NadelServiceTypeFilterTransform test
sbarker2 2d0625e
update test package
sbarker2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...n/graphql/nadel/tests/next/fixtures/defer/transforms/DeferWithTransformThrowsErrorTest.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.defer.transforms | ||
|
||
import graphql.nadel.NadelExecutionHints | ||
import graphql.nadel.tests.next.NadelIntegrationTest | ||
|
||
open class DeferWithTransformThrowsErrorTest : 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 @renamed(from: "underlyingSlow") | ||
} | ||
|
||
""".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 -> | ||
throw RuntimeException("An error occurred while fetching 'slow'") | ||
} | ||
} | ||
}, | ||
), | ||
), | ||
) { | ||
override fun makeExecutionHints(): NadelExecutionHints.Builder { | ||
return super.makeExecutionHints() | ||
.deferSupport { true } | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
...l/nadel/tests/next/fixtures/defer/transforms/DeferWithTransformThrowsErrorTestSnapshot.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,112 @@ | ||
// @formatter:off | ||
package graphql.nadel.tests.next.fixtures.defer.transforms | ||
|
||
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 | ||
|
||
private suspend fun main() { | ||
graphql.nadel.tests.next.update<DeferWithTransformThrowsErrorTest>() | ||
} | ||
|
||
/** | ||
* This class is generated. Do NOT modify. | ||
* | ||
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots | ||
*/ | ||
@Suppress("unused") | ||
public class DeferWithTransformThrowsErrorTestSnapshot : TestSnapshot() { | ||
override val calls: List<ExpectedServiceCall> = listOf( | ||
ExpectedServiceCall( | ||
service = "defer", | ||
query = """ | ||
| { | ||
| defer { | ||
| hello | ||
| ... @defer(label: "slow-defer") { | ||
| rename__slow__underlyingSlow: underlyingSlow | ||
| __typename__rename__slow: __typename | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
variables = " {}", | ||
result = """ | ||
| { | ||
| "data": { | ||
| "defer": { | ||
| "hello": "helloString" | ||
| } | ||
| }, | ||
| "hasNext": true | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
""" | ||
| { | ||
| "hasNext": false, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "defer" | ||
| ], | ||
| "label": "slow-defer", | ||
| "data": { | ||
| "rename__slow__underlyingSlow": null, | ||
| "__typename__rename__slow": "DeferApi" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
), | ||
), | ||
) | ||
|
||
/** | ||
* ```json | ||
* { | ||
* "data": { | ||
* "defer": { | ||
* "hello": "helloString", | ||
* "slow": null | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
override val result: ExpectedNadelResult = ExpectedNadelResult( | ||
result = """ | ||
| { | ||
| "data": { | ||
| "defer": { | ||
| "hello": "helloString" | ||
| } | ||
| }, | ||
| "hasNext": true | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
""" | ||
| { | ||
| "hasNext": false, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "defer" | ||
| ], | ||
| "label": "slow-defer", | ||
| "data": { | ||
| "slow": null | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
), | ||
) | ||
} |
87 changes: 87 additions & 0 deletions
87
...kotlin/graphql/nadel/tests/next/fixtures/defer/transforms/DeferredRenamedInputTypeTest.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,87 @@ | ||
package graphql.nadel.tests.next.fixtures.defer.transforms | ||
|
||
import graphql.nadel.NadelExecutionHints | ||
import graphql.nadel.tests.next.NadelIntegrationTest | ||
|
||
/** | ||
* The `ConfluenceLegacyPathType` input type was renamed. | ||
* | ||
* In the test snapshot we ensure the variable is defined as `PathType`. | ||
* | ||
* This tests the NadelRenameArgumentInputTypesTransform with defer | ||
*/ | ||
class DeferredRenamedInputTypeTest : NadelIntegrationTest( | ||
query = """ | ||
query { | ||
me { | ||
profilePicture { | ||
...@defer { | ||
path(type: ABSOLUTE) | ||
} | ||
} | ||
} | ||
} | ||
""".trimIndent(), | ||
services = listOf( | ||
Service( | ||
name = "confluence_legacy", | ||
overallSchema = """ | ||
type Query { | ||
me: ConfluenceLegacyUser | ||
} | ||
type ConfluenceLegacyUser @renamed(from: "User") { | ||
profilePicture: ConfluenceLegacyProfilePicture | ||
} | ||
type ConfluenceLegacyProfilePicture @renamed(from: "ProfilePicture") { | ||
path(type: ConfluenceLegacyPathType!): String | ||
} | ||
enum ConfluenceLegacyPathType @renamed(from: "PathType") { | ||
ABSOLUTE | ||
RELATIVE | ||
} | ||
""".trimIndent(), | ||
runtimeWiring = { wiring -> | ||
data class ProfilePicture( | ||
val absolutePath: String, | ||
val relativePath: String, | ||
) | ||
|
||
data class User( | ||
val profilePicture: ProfilePicture, | ||
) | ||
|
||
wiring | ||
.type("Query") { type -> | ||
type | ||
.dataFetcher("me") { env -> | ||
User( | ||
profilePicture = ProfilePicture( | ||
relativePath = "/wiki/aa-avatar/5ee0a4ef55749e0ab6e0fb70", | ||
absolutePath = "https://atlassian.net/wiki/aa-avatar/5ee0a4ef55749e0ab6e0fb70", | ||
), | ||
) | ||
} | ||
} | ||
.type("ProfilePicture") { type -> | ||
type | ||
.dataFetcher("path") { env -> | ||
val pfp = env.getSource<ProfilePicture>()!! | ||
when (val urlType = env.getArgument<String>("type")) { | ||
"ABSOLUTE" -> pfp.absolutePath | ||
"RELATIVE" -> pfp.relativePath | ||
else -> throw IllegalArgumentException(urlType) | ||
} | ||
} | ||
} | ||
}, | ||
), | ||
), | ||
) { | ||
override fun makeExecutionHints(): NadelExecutionHints.Builder { | ||
return super.makeExecutionHints() | ||
// todo: this should be on by default | ||
.allDocumentVariablesHint { | ||
true | ||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...raphql/nadel/tests/next/fixtures/defer/transforms/DeferredRenamedInputTypeTestSnapshot.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,84 @@ | ||
// @formatter:off | ||
package graphql.nadel.tests.next.fixtures.defer.transforms | ||
|
||
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 | ||
|
||
private suspend fun main() { | ||
graphql.nadel.tests.next.update<DeferredRenamedInputTypeTest>() | ||
} | ||
|
||
/** | ||
* This class is generated. Do NOT modify. | ||
* | ||
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots | ||
*/ | ||
@Suppress("unused") | ||
public class DeferredRenamedInputTypeTestSnapshot : TestSnapshot() { | ||
override val calls: List<ExpectedServiceCall> = listOf( | ||
ExpectedServiceCall( | ||
service = "confluence_legacy", | ||
query = """ | ||
| query (${'$'}v0: PathType!) { | ||
| me { | ||
| profilePicture { | ||
| path(type: ${'$'}v0) | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
variables = """ | ||
| { | ||
| "v0": "ABSOLUTE" | ||
| } | ||
""".trimMargin(), | ||
result = """ | ||
| { | ||
| "data": { | ||
| "me": { | ||
| "profilePicture": { | ||
| "path": "https://atlassian.net/wiki/aa-avatar/5ee0a4ef55749e0ab6e0fb70" | ||
| } | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
), | ||
), | ||
) | ||
|
||
/** | ||
* ```json | ||
* { | ||
* "data": { | ||
* "me": { | ||
* "profilePicture": { | ||
* "path": "https://atlassian.net/wiki/aa-avatar/5ee0a4ef55749e0ab6e0fb70" | ||
* } | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
override val result: ExpectedNadelResult = ExpectedNadelResult( | ||
result = """ | ||
| { | ||
| "data": { | ||
| "me": { | ||
| "profilePicture": { | ||
| "path": "https://atlassian.net/wiki/aa-avatar/5ee0a4ef55749e0ab6e0fb70" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no incremental data in the result |
||
| } | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
), | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's the error in the result?