Skip to content

improvement: validate cross-field dependencies in graphql DSL options at compile time#416

Merged
zachdaniel merged 2 commits intoash-project:mainfrom
nallwhy:improvement/verify-field-dependencies
Mar 7, 2026
Merged

improvement: validate cross-field dependencies in graphql DSL options at compile time#416
zachdaniel merged 2 commits intoash-project:mainfrom
nallwhy:improvement/verify-field-dependencies

Conversation

@nallwhy
Copy link
Copy Markdown
Contributor

@nallwhy nallwhy commented Mar 7, 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 compile-time validation for cross-field dependencies between graphql DSL options
  • Error when show_fields and hide_fields overlap (contradiction)
  • Warn when options like sortable_fields, filterable_fields, nullable_fields, field_names, relationships, paginate_relationship_with, attribute_input_types reference fields that are not visible (hidden or not in show_fields)
  • Warn when paginate_relationship_with, filterable_fields, field_names, nullable_fields reference relationships excluded from the relationships option

Copilot AI review requested due to automatic review settings March 7, 2026 06:20
@nallwhy nallwhy force-pushed the improvement/verify-field-dependencies branch from 20fafdb to 25aaa62 Compare March 7, 2026 06:20
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 adds a new Spark DSL verifier to validate cross-field dependencies among graphql DSL options for AshGraphql resources, raising on contradictions and emitting compile-time warnings for configurations that would have no runtime effect.

Changes:

  • Introduces AshGraphql.Resource.Verifiers.VerifyFieldDependencies to detect show_fields/hide_fields contradictions and warn on references to non-visible or excluded relationship fields.
  • Registers the new verifier in the AshGraphql resource extension verifier pipeline.
  • Adds a comprehensive ExUnit test suite covering contradiction errors and the expected warning scenarios.

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_dependencies.ex New verifier implementing compile-time cross-option dependency checks (errors + warnings).
lib/resource/resource.ex Registers the new verifier in the extension’s @verifiers list.
test/verify_field_dependencies_test.exs Adds unit tests validating contradictions and warning behavior across supported options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zachdaniel zachdaniel merged commit 8154766 into ash-project:main Mar 7, 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