Skip to content

feat: selected fields #673

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

Merged
merged 1 commit into from
Aug 19, 2025
Merged

feat: selected fields #673

merged 1 commit into from
Aug 19, 2025

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
Copilot

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

@pavelnikolov pavelnikolov merged commit 29adc43 into master Aug 19, 2025
3 checks passed
@pavelnikolov pavelnikolov deleted the selected-fields branch August 19, 2025 13:01
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.

1 participant