Skip to content
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

Added logic to parse @context in FederatedQueryGraphBuilder::build #6223

Open
wants to merge 9 commits into
base: router-528-impl-set-context
Choose a base branch
from

Conversation

TylerBloom
Copy link
Contributor

There are still a few TODOs. The regular expression that is used will fail to build because looking around is not supported. The logic inside the simpleTraversal for the context has also not been ported. Lastly, the definition position types might be off and need to be tested.

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Nov 4, 2024

✅ Docs Preview Ready

No new or changed pages found.

@router-perf
Copy link

router-perf bot commented Nov 4, 2024

CI performance tests

  • connectors-const - Connectors stress test that runs with a constant number of users
  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

@TylerBloom TylerBloom force-pushed the tylerb/port-context-in-federate-subgraphs branch from 2ce6517 to a757dfd Compare November 4, 2024 04:21
@TylerBloom TylerBloom force-pushed the tylerb/port-context-in-federate-subgraphs branch from a6f22b7 to 76f8cad Compare November 6, 2024 16:37
// fromContext in that subgraph, ya?
.find(|(dir, _)| **dir == FROM_CONTEXT_DIRECTIVE_NAME)
else {
continue;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One not about this: This is silencing potential errors. There could be @context in the subgraph but not @fromContext (or worse, visa versa). This simply ignore that. I'm comfortable with this because composition should catch that, but it would also be reasonable track this better and raise an error.

Comment on lines 404 to 406
subgraph_to_args: IndexMap<Arc<str>, Vec<ObjectFieldArgumentDefinitionPosition>>,
subgraph_to_arg_indices:
IndexMap<Arc<str>, IndexMap<ObjectFieldArgumentDefinitionPosition, String>>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to revisit this was we near the end of porting this feature. These fields contain the same data, in the same order. The only difference is one also contains identifier strings. We should be able to remove subgraph_to_args. For now, keeping it will make porting things easier.

.root_kinds_to_nodes_by_source
.iter()
.filter(|(source, _)| **source != self.base.query_graph.current_source)
.flat_map(|(_, root_kind_to_notes)| root_kind_to_notes.keys().copied())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
.flat_map(|(_, root_kind_to_notes)| root_kind_to_notes.keys().copied())
.flat_map(|(_, root_kind_to_nodes)| root_kind_to_nodes.keys().copied())

.referencers()
.directives
.iter()
// TODO: I think I need to get the subgraph data which contains the name of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so? Because the directive could be renamed in the subgraph, I think we want to use the ContextSpecDefinition to get the name, but I'm not totally sure of the mechanics.

// For @context
// subgraph -> referencers -> iter through object_types and interface_types
let subgraph_data = self.subgraphs.get(source)?;
let mut context_name_to_types: HashMap<&str, HashSet<&ObjectTypeDefinitionPosition>> =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to build a similar HashMap for interfaces and unions? Or can we do it in the same map?

Comment on lines +1519 to +1522
context_name_to_types
.entry(application.name)
.or_default()
.insert(object_def_pos);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how elegant this is in Rust.


// Collect data for @fromContext
let coordinate_map = coordinate_map.entry(subgraph_name.clone()).or_default();
for object_field_arg in &from_context_refs.object_field_arguments {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice that the way we've architected this, we don't have to do some of the checking that's done in the JS code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants