-
Notifications
You must be signed in to change notification settings - Fork 272
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
fix: cleanup defer handling within the QP #6470
Conversation
✅ Docs Preview ReadyNo new or changed pages found. |
@dariuszkuc, please consider creating a changeset entry in |
CI performance tests
|
@@ -1,5 +1,3 @@ | |||
#[macro_use] | |||
mod build_query_plan_support; | |||
mod build_query_plan_tests; | |||
// TODO: port query-planner-js/src/__tests__/buildPlan.*.test.ts as new modules here | |||
mod operation_validations_tests; |
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.
NOTE: this change is unrelated to the defer cleanup. Those tests were not implemented and their JS counterpart were covering general GraphQL validations that are already handled by apollo-rs
and reuse fragment logic.
@@ -17,8 +17,6 @@ use crate::schema::position::InterfaceTypeDefinitionPosition; | |||
use crate::schema::position::ObjectTypeDefinitionPosition; | |||
use crate::schema::ValidFederationSchema; | |||
|
|||
mod defer; |
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.
those tests were verifying without_defer
functionality
Was going to remove We generate API schema twice -> once by the router and once by the QP. Maybe we should update our |
@@ -332,6 +335,18 @@ impl DirectiveList { | |||
inner.rehash(); | |||
Some(item) | |||
} | |||
|
|||
/// Removes @defer directive from self if it has a matching label. | |||
pub(crate) fn remove_defer(&mut self, defer_labels: &IndexSet<String>) { |
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 was lifted out of the old DeferFilter
. We don't need to pass schema anymore as at this stage all @defer
applications will already have labels normalized.
If user explicitly opt-out of the `@defer` support, deferred queries will be rejected by the router with GraphQL validation error (unknown directive). It is not possible to plan a query with a `@defer` in it when defer support is disabled so we can simplify this logic.
3474d01
to
6342406
Compare
We'll tackle the duplicate API schema generation issue and cleanup the overall API in other PR. |
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.
Looks good!
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.
Other than the one comment about a test being removed, looks good to me.
@@ -6,71 +6,6 @@ fn config_with_defer() -> QueryPlannerConfig { | |||
config | |||
} | |||
|
|||
#[test] | |||
fn defer_test_handles_simple_defer_without_defer_enabled() { |
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.
Is there a reason this was removed? It was ported directly from JS, and, IMO, is testing behavior that we care about.
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.
The changed behavior does not allow @defer
directive if defer is enabled, while previously @defer
was removed silently. So, the tested scenario can no longer happen.
However, I just noticed the test would still be able to run. I think this function need to be updated:
include_defer: true, |
pub(crate) fn api_schema_and_planner(
function_path: &'static str,
config: QueryPlannerConfig,
subgraph_names_and_schemas: &[(&str, &str)],
) -> (ValidFederationSchema, QueryPlanner) {
let supergraph = compose(function_path, subgraph_names_and_schemas);
let supergraph = apollo_federation::Supergraph::new(&supergraph).unwrap();
let planner = QueryPlanner::new(&supergraph, config).unwrap();
let api_schema_config = apollo_federation::ApiSchemaOptions {
include_defer: true,
include_stream: false,
};
let api_schema = supergraph.to_api_schema(api_schema_config).unwrap();
(api_schema, planner)
}
The config should control ApiSchemaOptions
's include_defer
.
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.
thats the thing -> outside of tests it is not possible for this scenario to ever reach QP. Old test was verifying the behavior that we would strip out @defer
from incoming requests if it was disabled.... but if user explicitly opts out of @defer
but still send a query with @defer
it will be rejected during GraphQL validation by apollo-rs
(as that directive won't exist in the API schema).
So real use cases are
- defer enabled
- query with defer (need to normalize it)
- query without defer
- defer disabled
- query without defer
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.
Fixed the test api schema config in 6d7a1ca
If user explicitly opt-out of the
@defer
support, deferred queries will be rejected by the router with GraphQL validation error (unknown directive). It is not possible to plan a query with a@defer
in it when defer support is disabled so we can simplify this logic.Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩