Skip to content

Conversation

@pavelnikolov
Copy link
Member

Add the ability to introspect the immediate selected fields of a resolver.

@pavelnikolov pavelnikolov requested a review from Copilot August 19, 2025 09:41

This comment was marked as outdated.

@pavelnikolov pavelnikolov force-pushed the selected-fields branch 4 times, most recently from d6b62e8 to 9c0b05e Compare August 19, 2025 10:40
@pavelnikolov pavelnikolov requested a review from Copilot August 19, 2025 11:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds resolver field selection inspection helpers to enable introspection of immediate child fields requested in GraphQL queries. This allows resolvers to conditionally fetch data or build database projections based on what fields were actually selected.

Key changes:

  • Added three helper functions: SelectedFieldNames, HasSelectedField, and SortedSelectedFieldNames
  • Implemented lazy computation of field selections with opt-out capability via DisableFieldSelections()
  • Added comprehensive test coverage including performance benchmarks

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
selection.go Core public API providing the three field selection helper functions
internal/selections/context.go Internal package handling lazy computation and context management of field selections
internal/exec/exec.go Integration point adding selection context to resolver execution when enabled
graphql.go Schema option to disable field selections and plumbing to execution layer
selection_test.go Comprehensive test suite covering various selection scenarios and edge cases
selection_bench_test.go Performance benchmarks comparing enabled vs disabled selection helpers
example_selection_test.go Example demonstrating SelectedFieldNames usage
example_selection2_test.go Example demonstrating HasSelectedField usage
README.md Documentation for the new field selection inspection feature
CHANGELOG.md Feature announcement in changelog

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

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.

2 participants