improvement: validate field references in graphql DSL options at compile time#415
Merged
zachdaniel merged 3 commits intoash-project:mainfrom Mar 6, 2026
Merged
Conversation
92e78ef to
74a34cb
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new compile-time verifier to ensure GraphQL DSL options only reference fields that actually exist on the resource, preventing typos and invalid configuration from being silently accepted.
Changes:
- Added
AshGraphql.Resource.Verifiers.VerifyFieldReferencesto validate field references in multiple GraphQL DSL options and raiseSpark.Error.DslErrorwith available fields. - Registered the new verifier in the AshGraphql resource extension verifier pipeline.
- Added ExUnit coverage for the verifier across the supported options (
show_fields,hide_fields,field_names,sortable_fields,filterable_fields,nullable_fields,relationships).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/resource/verifiers/verify_field_references.ex |
New verifier implementing field reference validation and error reporting. |
lib/resource/resource.ex |
Registers the new verifier in the resource extension’s verifier list. |
test/verify_field_references_test.exs |
Adds unit tests asserting correct failures/success for each validated option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
992970e to
3187133
Compare
zachdaniel
approved these changes
Mar 6, 2026
Contributor
|
🚀 Thank you for your contribution! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
VerifyFieldReferencesverifier that validates field names inshow_fields,hide_fields,field_names,sortable_fields,filterable_fields,nullable_fields, andrelationshipsoptions actually exist on the resourceSpark.Error.DslErrorwith clear error message including the invalid field name and available fields