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

JSONSelection in URIs and Header values #6513

Draft
wants to merge 21 commits into
base: benjamn/JSONSelection-compute_output_shape
Choose a base branch
from

Conversation

dylan-apollo
Copy link
Member

@dylan-apollo dylan-apollo commented Jan 6, 2025

This PR implements full expressions in URIs and header values (e.g., arrow methods, not just variables) via a few pieces:

  1. The new apollo-federation/src/sources/connect/string_template.rs contains shared logic for both URIs and headers, so they can be more consistent behavior (both parsing and interpolation). This comes with support for full JSONSelection rather than just the variable references
  2. As a result of 1, headers now work much like URIs in that arrays and objects won't be automatically serialized to JSON, instead it is an error for an expression to result in one of those. This is a breaking change. Users should work around this with ->jsonStringify from ->jsonStringify method #6519
  3. Much of the former variable reference code has been removed in favor of this new parsing approach, which leans on the JSONSelection parser instead
  4. To validate these more complex expressions, the new shape library is being used. As a result this PR relies on Implement ApplyToInternal::compute_output_shape and JSONSelection::shape returning shape::Shape #6458

Pay extra attention to the test cases in apollo-federation/src/sources/connect/validation/expression.rs to look for any gaps. In particular, any named types ($args, $this, $config, etc.) can have unexpected effects on the shape processing as things need to be checked/simplified before the types are known.

There are some expected gaps in the validations where we need to build more infrastructure for the type checker. For example, ->map is completely ignored for now.

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Jan 6, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 4f9769aff1fc03c607ee1919

@router-perf
Copy link

router-perf bot commented Jan 6, 2025

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

@benjamn benjamn force-pushed the benjamn/JSONSelection-compute_output_shape branch from 70486c1 to 2658a33 Compare January 7, 2025 18:29
@dylan-apollo dylan-apollo changed the title String template type checking JSONSelection in URIs and Header values Jan 7, 2025
@dylan-apollo dylan-apollo force-pushed the dylan/string-template-type-checking branch from 35ab7e6 to b132e04 Compare January 7, 2025 21:56
@benjamn benjamn force-pushed the benjamn/JSONSelection-compute_output_shape branch from 2658a33 to 9081976 Compare January 9, 2025 20:24
@benjamn benjamn changed the base branch from benjamn/JSONSelection-compute_output_shape to next January 10, 2025 18:36
#[case::slice("$args.string->slice(0, 2)")]
#[case::size("$args.array->size")]
#[case::first("$args.array->first.bool")]
#[case::last("$args.array->last.bool")]

Choose a reason for hiding this comment

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

Nitpick: maybe an additional test for properties nested at a greater depth, like:

#[case::multi_level_input("$args.multiLevel.inner.nested")]

(I did try this and it worked)

@benjamn benjamn force-pushed the dylan/string-template-type-checking branch from ea917ee to e448dcd Compare January 10, 2025 19:40
@benjamn benjamn changed the base branch from next to benjamn/JSONSelection-compute_output_shape January 10, 2025 19:40
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.

4 participants