Skip to content

improvement: validate field references in graphql DSL options at compile time#415

Merged
zachdaniel merged 3 commits intoash-project:mainfrom
nallwhy:improvement/verify-field-references
Mar 6, 2026
Merged

improvement: validate field references in graphql DSL options at compile time#415
zachdaniel merged 3 commits intoash-project:mainfrom
nallwhy:improvement/verify-field-references

Conversation

@nallwhy
Copy link
Copy Markdown
Contributor

@nallwhy nallwhy commented Mar 6, 2026

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Summary

  • Add VerifyFieldReferences verifier that validates field names in show_fields, hide_fields, field_names, sortable_fields, filterable_fields, nullable_fields, and relationships options actually exist on the resource
  • Raises Spark.Error.DslError with clear error message including the invalid field name and available fields
  • Catches typos and non-existent field references at compile time instead of silently ignoring them

Copilot AI review requested due to automatic review settings March 6, 2026 05:53
@nallwhy nallwhy force-pushed the improvement/verify-field-references branch from 92e78ef to 74a34cb Compare March 6, 2026 05:53
Copy link
Copy Markdown

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 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.VerifyFieldReferences to validate field references in multiple GraphQL DSL options and raise Spark.Error.DslError with 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.

Copy link
Copy Markdown

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

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.

@nallwhy nallwhy force-pushed the improvement/verify-field-references branch from 992970e to 3187133 Compare March 6, 2026 06:39
@zachdaniel zachdaniel merged commit 55df7bc into ash-project:main Mar 6, 2026
23 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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.

3 participants