Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gate)!: policies should affect visibility on introspection (#963)
This ended up becoming a full rewrite of the introspection logic. For context, the old implementation generated types dynamically but also did a few parts statically (the __schema.types list). This worked as long as we assume all object types fields are not context dependent. Which resulted in a few bugs on injected fields. In this new implementation, we "define" a type as required (it is added into the __schema.types list), still recursively but this allows emitting types with adhoc suffixes in demand depending on the policies or injections. Then when the type is refered we simply give a reference to it. #### Migration notes * There can be multiple empty object scalars (vs only one previously) * Fields can be missing if not authorized * Type names depends on its shape (e.g.Foo missing a field would have different name than Foo with all its field), this extends to unions (depends on the variant names with each following the same naming rule) - [x] The change comes with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Enhanced GraphQL introspection now offers a more comprehensive and consistent schema view with refined field visibility controls. - New introspection queries and fragments improve the introspection capabilities of the GraphQL API. - Introduced new functions for managing type visibility and policies within the type graph context. - Added new test functions to validate introspection queries and their structures. - **Refactor** - Improved runtime initialization and error handling lead to a smoother query engine performance and more robust schema generation. - Code structure has been enhanced for better organization and clarity, particularly in type visibility management. - Modifications to authorization checks and policy evaluations enhance granularity and processing efficiency. - **Tests** - Expanded test coverage validates the new introspection enhancements and policy enforcement, ensuring reliable operation. - New tests focus on visibility checks and policy rule logic during introspection on complex and simple type graphs. - Added tests for introspection functionalities and visibility policies in various scenarios, ensuring comprehensive validation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information