Skip to content

Allow non-trivial root __typename-only queries when introspection is disabled#6282

Merged
SimonSapin merged 2 commits intodevfrom
simon/typename-tests
Nov 25, 2024
Merged

Allow non-trivial root __typename-only queries when introspection is disabled#6282
SimonSapin merged 2 commits intodevfrom
simon/typename-tests

Conversation

@SimonSapin
Copy link
Contributor

@SimonSapin SimonSapin commented Nov 19, 2024

Even though we use the same executor as for schema introspection, queries that only use __typename should not be rejected when schema introspection is disabled.

Also fixes #6154: these tests were using #[should_panic] without an expected message. At some point the underlying bug was fixed but these tests still panicked for a different reason, so we didn’t notice at the time.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. 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.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

Fixes #6154

These tests were using `#[should_panic]` without an `expected` message.
At some point the underlying bug was fixed but these tests still panicked
for a different reason, so we didn’t notice at the time.
@SimonSapin SimonSapin requested review from a team and IvanGoncharov November 19, 2024 12:59
@SimonSapin SimonSapin requested a review from a team as a code owner November 19, 2024 13:00
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Nov 19, 2024

✅ Docs Preview Ready

No new or changed pages found.

@github-actions
Copy link
Contributor

@SimonSapin, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

@router-perf
Copy link

router-perf bot commented Nov 19, 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

.configuration_json(json!({
"supergraph": {
"introspection": true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

To make sure.
These tests don't work without this flag, right?
If the query only has __typename, is it treated as an introspection query?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes without this these tests return INTROSPECTION_DISABLED

… but I didn’t realize opening this PR: that’s also a bug! Even if we internally use the introspection execution engine to handle __typename in fragment, it probably shouldn’t be rejected when (schema-)introspection is disabled

I’ll tweak the rejection logic in this PR

…disabled

… even though the same execution machinery as introspection is used.
@SimonSapin SimonSapin changed the title Enable typename tests that now pass Allow non-trivial root __typename-only queries when introspection is disabled Nov 19, 2024
@SimonSapin
Copy link
Contributor Author

SimonSapin commented Nov 19, 2024

I’ve tweaked the execution logic and rephrased the PR title and description, please take another look

ControlFlow::Break(self.cached_introspection(schema, key, doc).await)?
// root __typename only, probably a small query
// Execute it without caching:
ControlFlow::Break(Self::execute_introspection(schema, doc))?
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be handled by the maybe_lone_root_typename call earlier in the function? Or maybe we can remove that function (which doesn't handle fragments), and only rely on this branch now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe_lone_root_typename handles exactly {__typename} (which is very common) and ~nothing else. This handles cases where __typename is the only field, but fragments or directives may be used.

It’s true that the maybe_lone_root_typename fast path becomes less impactful with this PR since the cache is bypassed either way. I wouldn’t oppose remove it, though I don’t know if this fast path is still faster than going through the executor machinery.

Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

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

LGTM but i'd like to have the question clarified before merging

@SimonSapin SimonSapin merged commit e73e94f into dev Nov 25, 2024
@SimonSapin SimonSapin deleted the simon/typename-tests branch November 25, 2024 14:32
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.

Router errors on queries that contains only __typename on root level that wrapped in fragment

4 participants