feat: raise at compile time when related resource's domain is missing from schema#414
Merged
zachdaniel merged 1 commit intoash-project:mainfrom Mar 5, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a compile-time validation that detects when a resource has a relationship to another resource whose domain is not included in the AshGraphql schema's domain list. Instead of silently generating a broken schema that fails at runtime with an obscure Absinthe type error, users now get a clear, actionable error message at compile time. This closes issue #41.
Changes:
- Added
validate_domains_for_relationships!/2function inAshGraphqlthat checks each resource's public relationships and raises if the destination resource has theAshGraphql.Resourceextension but its domain is not registered in the schema. - Integrated the validation call during
use AshGraphqlafter all resources are collected. - Added a test that verifies a
RuntimeErroris raised when a related resource's domain is missing from the schema.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/ash_graphql.ex |
Adds the validate_domains_for_relationships!/2 function and calls it during schema compilation to catch missing domains early. |
test/missing_related_domain_test.exs |
New test file verifying that a compile-time error is raised when a related resource's domain is omitted from the schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e5ea822 to
70f35b8
Compare
70f35b8 to
e6144e0
Compare
zachdaniel
approved these changes
Mar 5, 2026
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
Closes #41
When a resource has a relationship to another resource whose domain is not included in the schema, AshGraphql now raises a compile-time error with a clear, actionable message — instead of silently generating a broken schema that fails at runtime with an obscure Absinthe type error.
Error message example
Changes
validate_domains_for_relationships!/2, called duringuse AshGraphqlafter all resources are collected. Checks each resource's public relationships — if the destination has theAshGraphql.Resourceextension but its domain isn't in the schema, raises with instructions to fix.