Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private suspend fun main() {
public class `let jsw do jsw things snapshot` : TestSnapshot() {
override val calls: List<ExpectedServiceCall> = listOf(
ExpectedServiceCall(
service = "service",
service = "jsw",
query = """
| {
| foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<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()
.allDocumentVariablesHint { true }
}

override fun makeNadelSchemas(): NadelSchemas.Builder {
return super.makeNadelSchemas()
.overallWiringFactory(GatewaySchemaWiringFactory())
}
}
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<RenamedScalarInputTypeTest>()
}

/**
* This class is generated. Do NOT modify.
*
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots]
*/
@Suppress("unused")
public class RenamedScalarInputTypeTestSnapshot : 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(
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: "let jsw do jsw things"
enabled: true
# language=GraphQL
overallSchema:
service: |
jsw: |
type Query {
foo: A
}
Expand All @@ -15,7 +15,7 @@ overallSchema:
scalar D @renamed(from: "Y")
# language=GraphQL
underlyingSchema:
service: |
jsw: |
type Query {
foo: X
}
Expand All @@ -30,7 +30,7 @@ query: |
}
variables: { }
serviceCalls:
- serviceName: "service"
- serviceName: "jsw"
request:
# language=GraphQL
query: |
Expand Down
Loading