Skip to content

Commit

Permalink
Merge branch 'apply-rename-transformer' into add-deferred-executions-…
Browse files Browse the repository at this point in the history
…to-rename-transform
  • Loading branch information
sbarker2 committed Jun 26, 2024
2 parents 213005a + 4055215 commit 285bdaa
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graphql.nadel.tests.next.fixtures.defer
package graphql.nadel.tests.next.fixtures.defer.transforms

import graphql.nadel.NadelExecutionHints
import graphql.nadel.tests.next.NadelIntegrationTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @formatter:off
package graphql.nadel.tests.next.fixtures.defer
package graphql.nadel.tests.next.fixtures.defer.transforms

import graphql.nadel.tests.next.ExpectedNadelResult
import graphql.nadel.tests.next.ExpectedServiceCall
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package graphql.nadel.tests.next.fixtures.defer.transforms

import graphql.nadel.NadelExecutionHints
import graphql.nadel.tests.next.NadelIntegrationTest

open class MultipleRenamedFieldsAreDeferredSeparately : NadelIntegrationTest(
query = """
query {
defer {
hello
...@defer(label: "defer1") {
overallString
}
...@defer(label: "defer2") {
overallString
}
}
}
""".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
overallString: String @renamed(from: "underlyingString")
overallString2: String @renamed(from: "underlyingString2")
}

""".trimIndent(),
underlyingSchema = """
directive @defer(if: Boolean, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT

type Query {
defer: DeferApi
}
type DeferApi {
hello: String
underlyingString: String
underlyingString2: String
}

""".trimIndent(),
runtimeWiring = { wiring ->
wiring
.type("Query") { type ->
type
.dataFetcher("defer") { env ->
Any()
}
}
.type("DeferApi") { type ->
type
.dataFetcher("hello") { env ->
"hello there"
}
.dataFetcher("underlyingString") { env ->
"deferred string 1"
}
.dataFetcher("underlyingString2") { env ->
"deferred string 2"
}
}
},
),
),
) {
override fun makeExecutionHints(): NadelExecutionHints.Builder {
return super.makeExecutionHints()
.deferSupport { true }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// @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

/**
* This class is generated. Do NOT modify.
*
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots
*/
@Suppress("unused")
public class MultipleRenamedFieldsAreDeferredSeparatelySnapshot : TestSnapshot() {
override val calls: List<ExpectedServiceCall> = listOf(
ExpectedServiceCall(
service = "defer",
query = """
| {
| defer {
| hello
| rename__overallString__underlyingString: underlyingString
| __typename__rename__overallString: __typename
| }
| }
""".trimMargin(),
variables = "{}",
result = """
| {
| "data": {
| "defer": {
| "hello": "hello there",
| "rename__overallString__underlyingString": "deferred string 1",
| "__typename__rename__overallString": "DeferApi"
| }
| }
| }
""".trimMargin(),
delayedResults = listOfJsonStrings(
),
),
)

/**
* ```json
* {
* "data": {
* "defer": {
* "hello": "hello there",
* "overallString": "deferred string 1"
* }
* }
* }
* ```
*/
override val result: ExpectedNadelResult = ExpectedNadelResult(
result = """
| {
| "data": {
| "defer": {
| "hello": "hello there",
| "overallString": "deferred string 1"
| }
| }
| }
""".trimMargin(),
delayedResults = listOfJsonStrings(
),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package graphql.nadel.tests.next.fixtures.defer.transforms

import graphql.nadel.NadelExecutionHints
import graphql.nadel.tests.next.NadelIntegrationTest

open class MultipleRenamedFieldsAreDeferredTogether : NadelIntegrationTest(
query = """
query {
defer {
hello
...@defer {
overallString
overallString2
}
}
}
""".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
overallString: String @renamed(from: "underlyingString")
overallString2: String @renamed(from: "underlyingString2")
}

""".trimIndent(),
underlyingSchema = """
directive @defer(if: Boolean, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT

type Query {
defer: DeferApi
}
type DeferApi {
hello: String
underlyingString: String
underlyingString2: String
}

""".trimIndent(),
runtimeWiring = { wiring ->
wiring
.type("Query") { type ->
type
.dataFetcher("defer") { env ->
Any()
}
}
.type("DeferApi") { type ->
type
.dataFetcher("hello") { env ->
"hello there"
}
.dataFetcher("underlyingString") { env ->
"deferred string 1"
}
.dataFetcher("underlyingString2") { env ->
"deferred string 2"
}
}
},
),
),
) {
override fun makeExecutionHints(): NadelExecutionHints.Builder {
return super.makeExecutionHints()
.deferSupport { true }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// @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

/**
* This class is generated. Do NOT modify.
*
* Refer to [graphql.nadel.tests.next.UpdateTestSnapshots
*/
@Suppress("unused")
public class MultipleRenamedFieldsAreDeferredTogetherSnapshot : TestSnapshot() {
override val calls: List<ExpectedServiceCall> = listOf(
ExpectedServiceCall(
service = "defer",
query = """
| {
| defer {
| hello
| rename__overallString__underlyingString: underlyingString
| __typename__rename__overallString: __typename
| rename__overallString2__underlyingString2: underlyingString2
| __typename__rename__overallString2: __typename
| }
| }
""".trimMargin(),
variables = "{}",
result = """
| {
| "data": {
| "defer": {
| "hello": "hello there",
| "rename__overallString__underlyingString": "deferred string 1",
| "__typename__rename__overallString": "DeferApi",
| "rename__overallString2__underlyingString2": "deferred string 2",
| "__typename__rename__overallString2": "DeferApi"
| }
| }
| }
""".trimMargin(),
delayedResults = listOfJsonStrings(
),
),
)

/**
* ```json
* {
* "data": {
* "defer": {
* "hello": "hello there",
* "overallString": "deferred string 1",
* "overallString2": "deferred string 2"
* }
* }
* }
* ```
*/
override val result: ExpectedNadelResult = ExpectedNadelResult(
result = """
| {
| "data": {
| "defer": {
| "hello": "hello there",
| "overallString": "deferred string 1",
| "overallString2": "deferred string 2"
| }
| }
| }
""".trimMargin(),
delayedResults = listOfJsonStrings(
),
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graphql.nadel.tests.next.fixtures.defer
package graphql.nadel.tests.next.fixtures.defer.transforms

import graphql.nadel.NadelExecutionHints
import graphql.nadel.tests.next.NadelIntegrationTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @formatter:off
package graphql.nadel.tests.next.fixtures.defer
package graphql.nadel.tests.next.fixtures.defer.transforms

import graphql.nadel.tests.next.ExpectedNadelResult
import graphql.nadel.tests.next.ExpectedServiceCall
Expand Down

0 comments on commit 285bdaa

Please sign in to comment.