Skip to content

feat: improve apollo gateway compatible field selection validation#1169

Merged
endigma merged 16 commits into
masterfrom
jesse/eng-7185-router-more-apollo-compatibility-graphql-validation-400s
Jun 11, 2025
Merged

feat: improve apollo gateway compatible field selection validation#1169
endigma merged 16 commits into
masterfrom
jesse/eng-7185-router-more-apollo-compatibility-graphql-validation-400s

Conversation

@endigma

@endigma endigma commented Jun 4, 2025

Copy link
Copy Markdown
Member

Currently, we only have Apollo Gateway compatibility for a few basic types of field selection validation, this PR expands it to include and test:

  • selecting an undefined operation
  • selecting on an enum
  • selecting on a scalar
  • no select on object
  • select non-existent field
  • invalid fragment spread

The Apollo extension and 400 status compatibility should also extend to all operation validation errors now, and as such is governed by a new, less specific flag.

It also changes the format for a few existing errors:

Old Format New Format
field: %s not defined on type: %s Cannot query field "%s" on type "%s".
cannot select field: %s on scalar %s Field "%s" must not have a selection since type "%s" has no subfields.
non scalar field: %s on type: %s must have selections Field "%s" of type "%s" must have a selection of subfields. Did you mean "%[1]s { ... }"?
inline fragment on type: %s mismatches enclosing type: %s Fragment cannot be spread here as objects of type "%s" can never be of type "%s".

We also now pass ScalarLeafsRule ported tests from graphql-js, so I've enabled them to prevent regressions

@endigma endigma changed the title feat: Apollo compatible field selection validation feat: apollo gateway compatible field selection validation Jun 4, 2025
@endigma endigma changed the title feat: apollo gateway compatible field selection validation feat: improve apollo gateway compatible field selection validation Jun 4, 2025
@endigma endigma force-pushed the jesse/eng-7185-router-more-apollo-compatibility-graphql-validation-400s branch 2 times, most recently from 3c9be3f to 0b4397c Compare June 5, 2025 15:15
@endigma endigma marked this pull request as ready for review June 6, 2025 12:04
Comment thread v2/pkg/apollocompatibility/flags.go Outdated
Comment thread v2/pkg/astvalidation/operation_rule_validate_field_selections.go Outdated
Comment thread v2/pkg/astvalidation/operation_rule_validate_field_selections.go Outdated
Comment thread v2/pkg/operationreport/externalerror.go Outdated
@endigma endigma requested a review from devsergiy June 6, 2025 12:48
@endigma endigma requested a review from Aenimus June 6, 2025 13:08

@Aenimus Aenimus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@endigma endigma force-pushed the jesse/eng-7185-router-more-apollo-compatibility-graphql-validation-400s branch from f8830b2 to 57b5188 Compare June 10, 2025 11:08

@StarpTech StarpTech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@endigma endigma merged commit 8c1a063 into master Jun 11, 2025
9 checks passed
@endigma endigma deleted the jesse/eng-7185-router-more-apollo-compatibility-graphql-validation-400s branch June 11, 2025 17:33
endigma pushed a commit that referenced this pull request Jun 11, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.0.0-rc.188](v2.0.0-rc.187...v2.0.0-rc.188)
(2025-06-11)


### Features

* improve apollo gateway compatible field selection validation
([#1169](#1169))
([8c1a063](8c1a063))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
endigma pushed a commit that referenced this pull request Jul 2, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.4.0](execution/v1.3.1...execution/v1.4.0)
(2025-07-02)


### Features

* improve apollo gateway compatible field selection validation
([#1169](#1169))
([8c1a063](8c1a063))


### Bug Fixes

* support different kinds of close, correct client unsubscribe behaviour
([#1174](#1174))
([b6de322](b6de322))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Added a changelog entry for version 1.4.0, highlighting improved field
selection validation and enhanced client unsubscribe handling.

* **Chores**
  * Updated the component version to 1.4.0.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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