Skip to content

adding @fromContext directive validation #7563

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

Draft
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

clenfest
Copy link
Contributor

@clenfest clenfest commented May 23, 2025

  • Add complete @fromContext directive validation in from_context.rs validator
  • Implement field value type validation with support for:
    • Single field selections and nested field selections
    • Type compatibility checking between context and argument types
    • Multiple context locations with duck typing support
    • Inline fragment validation with type conditions
    • Interface object detection and error reporting
  • Add validation rules for @fromContext usage:
    • Deny usage on abstract types (interfaces/unions directly)
    • Deny usage on interface implementation fields
    • Require context to be defined via @context directive
    • Require at least one resolvable key on types using contextual args
    • Deny default values on @fromContext arguments
    • Deny usage on directive definition arguments
  • Add comprehensive test coverage with 35+ test cases covering:
    • Basic success cases and error conditions
    • Type validation edge cases and compatibility rules
    • Selection format validation (aliases, directives, multiple selections)
    • Context reference validation and type condition matching
  • Add proper port notes documenting relationship to JavaScript test suite
  • Export validate_from_context_directives function from validators module
  • Update schema upgrader and subgraph module to integrate validation

🎫 FED-497

clenfest added 4 commits May 8, 2025 09:27
- Add complete @fromcontext directive validation in from_context.rs validator
- Implement field value type validation with support for:
  - Single field selections and nested field selections
  - Type compatibility checking between context and argument types
  - Multiple context locations with duck typing support
  - Inline fragment validation with type conditions
  - Interface object detection and error reporting
- Add validation rules for @fromcontext usage:
  - Deny usage on abstract types (interfaces/unions directly)
  - Deny usage on interface implementation fields
  - Require context to be defined via @context directive
  - Require at least one resolvable key on types using contextual args
  - Deny default values on @fromcontext arguments
  - Deny usage on directive definition arguments
- Add comprehensive test coverage with 35+ test cases covering:
  - Basic success cases and error conditions
  - Type validation edge cases and compatibility rules
  - Selection format validation (aliases, directives, multiple selections)
  - Context reference validation and type condition matching
- Add proper port notes documenting relationship to JavaScript test suite
- Export validate_from_context_directives function from validators module
- Update schema upgrader and subgraph module to integrate validation

🎫 FED-497
Copy link
Contributor

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

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented May 23, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: cade0146dd00b11f89cb2fe4

@goto-bus-stop goto-bus-stop changed the title adding @fromContext directive validation adding @fromContext directive validation Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants