-
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.
don't call underlying services on empty queries (#519)
* don't call underlying services on empty queries * rename a file * pr feedback
- Loading branch information
1 parent
a81f603
commit f95b257
Showing
14 changed files
with
597 additions
and
119 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
14 changes: 14 additions & 0 deletions
14
lib/src/main/java/graphql/nadel/hints/NadelShortCircuitEmptyQueryHint.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,14 @@ | ||
package graphql.nadel.hints | ||
|
||
import graphql.nadel.Service | ||
|
||
fun interface NadelShortCircuitEmptyQueryHint { | ||
/** | ||
* Determines whether empty queries containing only top level __typename fields should be short-circuited without | ||
* calling the underlying service and executed on the internal introspection service | ||
* | ||
* @param service the service we are sending the query to | ||
* @return true to execute the query on the internal introspection service | ||
*/ | ||
operator fun invoke(service: Service): Boolean | ||
} |
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
109 changes: 109 additions & 0 deletions
109
...sources/fixtures/field removed/hidden-namespaced-hydration-top-level-field-is-removed.yml
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,109 @@ | ||
name: "hidden namespaced hydration top level field is removed" | ||
enabled: true | ||
# language=GraphQL | ||
overallSchema: | ||
IssueService: | | ||
directive @namespaced on FIELD_DEFINITION | ||
type Query { | ||
issueById(id: ID): Issue @namespaced | ||
} | ||
type Issue { | ||
id: ID | ||
comment: Comment @hydrated( | ||
service: "CommentService" | ||
field: "commentApi.commentById" | ||
arguments: [ | ||
{name: "id", value: "$source.commentId"} | ||
] | ||
) | ||
} | ||
CommentService: | | ||
directive @toBeDeleted on FIELD_DEFINITION | ||
type Query { | ||
commentApi: CommentApi @namespaced @hidden | ||
echo: String | ||
} | ||
type CommentApi { | ||
commentById(id: ID): Comment @toBeDeleted @hidden | ||
echo: String | ||
} | ||
type Comment { | ||
id: ID | ||
} | ||
# language=GraphQL | ||
underlyingSchema: | ||
IssueService: | | ||
type Query { | ||
issueById(id: ID): Issue | ||
} | ||
type Issue { | ||
id: ID | ||
commentId: ID | ||
} | ||
CommentService: | | ||
type Query { | ||
commentApi: CommentApi | ||
echo: String | ||
} | ||
type CommentApi { | ||
commentById(id: ID): Comment | ||
echo: String | ||
} | ||
type Comment { | ||
id: ID | ||
} | ||
# language=GraphQL | ||
query: | | ||
query { | ||
issueById(id: "C1") { | ||
id | ||
comment { | ||
id | ||
} | ||
} | ||
} | ||
variables: { } | ||
serviceCalls: | ||
- serviceName: "IssueService" | ||
request: | ||
# language=GraphQL | ||
query: | | ||
{ | ||
issueById(id: "C1") { | ||
__typename__hydration__comment: __typename | ||
hydration__comment__commentId: commentId | ||
id | ||
} | ||
} | ||
variables: { } | ||
# language=JSON | ||
response: |- | ||
{ | ||
"data": { | ||
"issueById": { | ||
"__typename__hydration__comment": "Issue", | ||
"hydration__comment__commentId": "C1", | ||
"id": "C1" | ||
} | ||
}, | ||
"extensions": {} | ||
} | ||
# language=JSON | ||
response: |- | ||
{ | ||
"errors": [ | ||
{ | ||
"locations": [], | ||
"message": "An error has occurred", | ||
"extensions": { | ||
"classification": "ValidationError" | ||
} | ||
} | ||
], | ||
"data": { | ||
"issueById": { | ||
"id": "C1", | ||
"comment": null | ||
} | ||
} | ||
} |
Oops, something went wrong.