fix: don't pass select to mutations, fixes notification data#406
Open
DGollings wants to merge 2 commits intoash-project:mainfrom
Open
fix: don't pass select to mutations, fixes notification data#406DGollings wants to merge 2 commits intoash-project:mainfrom
DGollings wants to merge 2 commits intoash-project:mainfrom
Conversation
AshGraphQL passes `select: get_select(...)` to mutations based on the
fields requested in the GraphQL query. This causes Ash's action_select
system to mask all unrequested attributes with %Ash.NotLoaded{} on the
result — including the notification data sent to notifiers.
Downstream consumers (PubSub subscribers, GenServers) that access
attributes like foreign keys from belongs_to relationships crash because
those fields are NotLoaded.
The fix removes the `select` option from create, update, and destroy
mutation paths. Ash defaults to loading all select_by_default attributes,
which is what notifiers need. Absinthe already filters the GraphQL
response to only the requested fields.
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.
Problem
AshGraphQL passes select: get_select to create/update/destroy mutations, restricting the Ash operation to only the fields the GraphQL client requested. Since Ash v3.4.8's action_select system, this masks all
unrequested attributes with %Ash.NotLoaded{} — including on notification data sent to Ash notifiers.
This means any mutation like:
produces notifications where order_id, company_id, and other foreign keys are Ash.NotLoaded, crashing downstream PubSub subscribers and GenServers that rely on those fields.
The issue became more visible after ash-project/ash#2544 (manage_relationship returning {:not_atomic}), which forces more actions through the non-atomic bulk path where the masking is applied more aggressively.
Fix
Remove the select option from all three mutation paths (create, update, destroy). Ash defaults to loading all select_by_default attributes, which is what notifiers need. Absinthe already filters the GraphQL response to only
the requested fields.
Test plan
Contributor checklist
Leave anything that you believe does not apply unchecked.