-
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.
Fix renamed shared input type bug (#584)
* Add test for renamed shared input type bug * Add failing test for bug * Pick up shared type renames when only used as input type * Update comment
- Loading branch information
Showing
7 changed files
with
449 additions
and
27 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
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
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
83 changes: 83 additions & 0 deletions
83
test/src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedInputTypeTest.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,83 @@ | ||
package graphql.nadel.tests.next.fixtures.rename | ||
|
||
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`. | ||
*/ | ||
class RenamedInputTypeTest : NadelIntegrationTest( | ||
query = """ | ||
query { | ||
me { | ||
profilePicture { | ||
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
.../src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedInputTypeTestSnapshot.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.rename | ||
|
||
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<RenamedInputTypeTest>() | ||
} | ||
|
||
/** | ||
* This class is generated. Do NOT modify. | ||
* | ||
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots | ||
*/ | ||
@Suppress("unused") | ||
public class RenamedInputTypeTestSnapshot : 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" | ||
| } | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
), | ||
) | ||
} |
Oops, something went wrong.