-
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
[READY] Initial defer implementation #553
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
974412e
nextgen engine changes for defer
sbarker2 1034d5e
adding defer tests
sbarker2 f673efd
adding more stuff to defer tests
sbarker2 7dbfe88
Ignore failing tests (defer queries with multiple service call)
sbarker2 4b43280
ignore location field in defer test errors (#554)
sbarker2 66f9346
fix error locations bug (#555)
sbarker2 b82ea6c
changing defer tests
sbarker2 2ef6589
Merge branch 'master' into initial-defer-implementation
sbarker2 66e1b87
remove @ignore on previously failing tests
sbarker2 d01433c
update test snapshots
sbarker2 86dc443
cleaning up defer tests
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
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
118 changes: 118 additions & 0 deletions
118
...aphql/nadel/tests/next/fixtures/defer/ComprehensiveDeferQueryWithDifferentServiceCalls.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,118 @@ | ||
package graphql.nadel.tests.next.fixtures.defer | ||
|
||
import graphql.nadel.NadelExecutionHints | ||
import graphql.nadel.tests.next.NadelIntegrationTest | ||
import kotlin.test.Ignore | ||
|
||
open class ComprehensiveDeferQueryWithDifferentServiceCalls : NadelIntegrationTest( | ||
query = """ | ||
query { | ||
user { | ||
name | ||
... @defer { | ||
profilePicture | ||
} | ||
... @defer(label: "team-details") { | ||
teamName | ||
teamMembers | ||
} | ||
} | ||
product { | ||
productName | ||
... @defer { | ||
productImage | ||
} | ||
... @defer(if: false) { | ||
productDescription | ||
} | ||
} | ||
} | ||
""".trimIndent(), | ||
services = listOf( | ||
Service( | ||
name = "shared", | ||
overallSchema = """ | ||
directive @defer(if: Boolean, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
""".trimIndent(), | ||
runtimeWiring = { wiring -> | ||
}, | ||
), | ||
Service( | ||
name = "users", | ||
overallSchema = """ | ||
type Query { | ||
user: UserApi | ||
} | ||
type UserApi { | ||
name: String | ||
profilePicture: String | ||
teamName: String | ||
teamMembers: [String] | ||
} | ||
""".trimIndent(), | ||
runtimeWiring = { wiring -> | ||
wiring | ||
.type("Query") { type -> | ||
type | ||
.dataFetcher("user") { env -> | ||
Any() | ||
} | ||
} | ||
.type("UserApi") { type -> | ||
type | ||
.dataFetcher("name") { env -> | ||
"Steven" | ||
} | ||
.dataFetcher("profilePicture") { env -> | ||
"https://examplesite.com/user/profile_picture.jpg" | ||
} | ||
.dataFetcher("teamName") { env -> | ||
"The Unicorns" | ||
} | ||
.dataFetcher("teamMembers") { env -> | ||
listOf("Felipe", "Franklin", "Juliano") | ||
} | ||
} | ||
}, | ||
), | ||
Service( | ||
name = "product", | ||
overallSchema = """ | ||
type Query { | ||
product: ProductApi | ||
} | ||
type ProductApi { | ||
productName: String | ||
productImage: String | ||
productDescription: String | ||
} | ||
""".trimIndent(), | ||
runtimeWiring = { wiring -> | ||
wiring | ||
.type("Query") { type -> | ||
type | ||
.dataFetcher("product") { env -> | ||
Any() | ||
} | ||
} | ||
.type("ProductApi") { type -> | ||
type | ||
.dataFetcher("productName") { env -> | ||
"Awesome Product" | ||
} | ||
.dataFetcher("profilePicture") { env -> | ||
"https://examplesite.com/product/product_image.jpg" | ||
} | ||
.dataFetcher("profilePicture") { env -> | ||
"This is a really awesome product with really awesome features." | ||
} | ||
} | ||
}, | ||
), | ||
), | ||
) { | ||
override fun makeExecutionHints(): NadelExecutionHints.Builder { | ||
return super.makeExecutionHints() | ||
.deferSupport { true } | ||
} | ||
} |
223 changes: 223 additions & 0 deletions
223
...del/tests/next/fixtures/defer/ComprehensiveDeferQueryWithDifferentServiceCallsSnapshot.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,223 @@ | ||
// @formatter:off | ||
package graphql.nadel.tests.next.fixtures.defer | ||
|
||
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 ComprehensiveDeferQueryWithDifferentServiceCallsSnapshot : TestSnapshot() { | ||
override val calls: List<ExpectedServiceCall> = listOf( | ||
ExpectedServiceCall( | ||
service = "product", | ||
query = """ | ||
| { | ||
| product { | ||
| productName | ||
| productDescription | ||
| ... @defer { | ||
| productImage | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
variables = "{}", | ||
result = """ | ||
| { | ||
| "data": { | ||
| "product": { | ||
| "productName": "Awesome Product", | ||
| "productDescription": null | ||
| } | ||
| }, | ||
| "hasNext": true | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
""" | ||
| { | ||
| "hasNext": false, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "product" | ||
| ], | ||
| "data": { | ||
| "productImage": null | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
), | ||
), | ||
ExpectedServiceCall( | ||
service = "users", | ||
query = """ | ||
| { | ||
| user { | ||
| name | ||
| ... @defer { | ||
| profilePicture | ||
| } | ||
| ... @defer(label: "team-details") { | ||
| teamName | ||
| teamMembers | ||
| } | ||
| } | ||
| } | ||
""".trimMargin(), | ||
variables = "{}", | ||
result = """ | ||
| { | ||
| "data": { | ||
| "user": { | ||
| "name": "Steven" | ||
| } | ||
| }, | ||
| "hasNext": true | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
""" | ||
| { | ||
| "hasNext": false, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "user" | ||
| ], | ||
| "label": "team-details", | ||
| "data": { | ||
| "teamName": "The Unicorns", | ||
| "teamMembers": [ | ||
| "Felipe", | ||
| "Franklin", | ||
| "Juliano" | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
""" | ||
| { | ||
| "hasNext": true, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "user" | ||
| ], | ||
| "data": { | ||
| "profilePicture": "https://examplesite.com/user/profile_picture.jpg" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
), | ||
), | ||
) | ||
|
||
/** | ||
* ```json | ||
* { | ||
* "data": { | ||
* "user": { | ||
* "name": "Steven", | ||
* "profilePicture": "https://examplesite.com/user/profile_picture.jpg", | ||
* "teamName": "The Unicorns", | ||
* "teamMembers": [ | ||
* "Felipe", | ||
* "Franklin", | ||
* "Juliano" | ||
* ] | ||
* }, | ||
* "product": { | ||
* "productName": "Awesome Product", | ||
* "productDescription": null, | ||
* "productImage": null | ||
* } | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
override val result: ExpectedNadelResult = ExpectedNadelResult( | ||
result = """ | ||
| { | ||
| "data": { | ||
| "user": { | ||
| "name": "Steven" | ||
| }, | ||
| "product": { | ||
| "productName": "Awesome Product", | ||
| "productDescription": null | ||
| } | ||
| }, | ||
| "hasNext": true | ||
| } | ||
""".trimMargin(), | ||
delayedResults = listOfJsonStrings( | ||
""" | ||
| { | ||
| "hasNext": false, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "user" | ||
| ], | ||
| "label": "team-details", | ||
| "data": { | ||
| "teamName": "The Unicorns", | ||
| "teamMembers": [ | ||
| "Felipe", | ||
| "Franklin", | ||
| "Juliano" | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
""" | ||
| { | ||
| "hasNext": true, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "product" | ||
| ], | ||
| "data": { | ||
| "productImage": null | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
""" | ||
| { | ||
| "hasNext": true, | ||
| "incremental": [ | ||
| { | ||
| "path": [ | ||
| "user" | ||
| ], | ||
| "data": { | ||
| "profilePicture": "https://examplesite.com/user/profile_picture.jpg" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
""".trimMargin(), | ||
), | ||
) | ||
} |
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.
This change is because we want to ignore the
locations
field in errors when comparing defer vs non-defer queries because the line/column of the error would be different as the two queries look slightly different (one has@defer
directive stripped)