diff --git a/lib/src/main/java/graphql/nadel/validation/NadelTypeValidation.kt b/lib/src/main/java/graphql/nadel/validation/NadelTypeValidation.kt index de460f431..99cb0a528 100644 --- a/lib/src/main/java/graphql/nadel/validation/NadelTypeValidation.kt +++ b/lib/src/main/java/graphql/nadel/validation/NadelTypeValidation.kt @@ -203,7 +203,7 @@ internal class NadelTypeValidation( } // Ignore scalar renames, refer to test "let jsw do jsw things" - if (type is NadelServiceSchemaElement.Scalar) { + if (type is NadelServiceSchemaElement.Scalar && type.service.name == "jsw") { return ok() } diff --git a/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things snapshot.kt b/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things snapshot.kt index 4d6f7301d..5bd9fddf8 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things snapshot.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things snapshot.kt @@ -22,7 +22,7 @@ private suspend fun main() { public class `let jsw do jsw things snapshot` : TestSnapshot() { override val calls: List = listOf( ExpectedServiceCall( - service = "service", + service = "jsw", query = """ | { | foo diff --git a/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things.kt b/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things.kt index e63e3cb13..d4433c293 100644 --- a/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things.kt +++ b/test/src/test/kotlin/graphql/nadel/tests/legacy/renames/let jsw do jsw things.kt @@ -13,7 +13,7 @@ class `let jsw do jsw things` : NadelLegacyIntegrationTest( variables = emptyMap(), services = listOf( Service( - name = "service", + name = "jsw", overallSchema = """ type Query { foo: A diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedScalarInputTypeTest.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedScalarInputTypeTest.kt new file mode 100644 index 000000000..28233bceb --- /dev/null +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedScalarInputTypeTest.kt @@ -0,0 +1,91 @@ +package graphql.nadel.tests.next.fixtures.rename + +import graphql.nadel.NadelExecutionHints +import graphql.nadel.NadelSchemas +import graphql.nadel.tests.GatewaySchemaWiringFactory +import graphql.nadel.tests.next.NadelIntegrationTest +import graphql.scalars.ExtendedScalars +import graphql.scalars.ExtendedScalars.newAliasedScalar + +/** + * The `ConfluenceLegacyPathType` scalar type is renamed and used as an input type. + * + * In the test snapshot we ensure the variable is defined as `PathType`. + */ +class RenamedScalarInputTypeTest : 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 + } + scalar ConfluenceLegacyPathType @renamed(from: "PathType") + """.trimIndent(), + runtimeWiring = { wiring -> + data class ProfilePicture( + val absolutePath: String, + val relativePath: String, + ) + + data class User( + val profilePicture: ProfilePicture, + ) + + wiring + .scalar( + newAliasedScalar("PathType") + .aliasedScalar(ExtendedScalars.Json) + .build() + ) + .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()!! + when (val urlType = env.getArgument("type")) { + "ABSOLUTE" -> pfp.absolutePath + "RELATIVE" -> pfp.relativePath + else -> throw IllegalArgumentException(urlType) + } + } + } + }, + ), + ), +) { + override fun makeExecutionHints(): NadelExecutionHints.Builder { + return super.makeExecutionHints() + .allDocumentVariablesHint { true } + } + + override fun makeNadelSchemas(): NadelSchemas.Builder { + return super.makeNadelSchemas() + .overallWiringFactory(GatewaySchemaWiringFactory()) + } +} diff --git a/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedScalarInputTypeTestSnapshot.kt b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedScalarInputTypeTestSnapshot.kt new file mode 100644 index 000000000..493d28df5 --- /dev/null +++ b/test/src/test/kotlin/graphql/nadel/tests/next/fixtures/rename/RenamedScalarInputTypeTestSnapshot.kt @@ -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() +} + +/** + * This class is generated. Do NOT modify. + * + * Refer to [graphql.nadel.tests.next.UpdateTestSnapshots] + */ +@Suppress("unused") +public class RenamedScalarInputTypeTestSnapshot : TestSnapshot() { + override val calls: List = 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( + ), + ) +} diff --git a/test/src/test/resources/fixtures/renames/let-jsw-do-jsw-things.yml b/test/src/test/resources/fixtures/renames/let-jsw-do-jsw-things.yml index 45924f7ac..a6327d454 100644 --- a/test/src/test/resources/fixtures/renames/let-jsw-do-jsw-things.yml +++ b/test/src/test/resources/fixtures/renames/let-jsw-do-jsw-things.yml @@ -3,7 +3,7 @@ name: "let jsw do jsw things" enabled: true # language=GraphQL overallSchema: - service: | + jsw: | type Query { foo: A } @@ -15,7 +15,7 @@ overallSchema: scalar D @renamed(from: "Y") # language=GraphQL underlyingSchema: - service: | + jsw: | type Query { foo: X } @@ -30,7 +30,7 @@ query: | } variables: { } serviceCalls: - - serviceName: "service" + - serviceName: "jsw" request: # language=GraphQL query: |