Skip to content

fix: don't pass select to mutations, fixes notification data#406

Open
DGollings wants to merge 2 commits intoash-project:mainfrom
sephianl:main
Open

fix: don't pass select to mutations, fixes notification data#406
DGollings wants to merge 2 commits intoash-project:mainfrom
sephianl:main

Conversation

@DGollings
Copy link
Contributor

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:

mutation { deliverParcel(id: "...") { result { id status } } }

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

  • Added NotificationSpy test notifier that captures raw Ash notifications
  • Tests verify that belongs_to foreign keys are loaded in notification data even when the GraphQL query only requests id
  • Verified the update test fails without the fix (actor_id becomes Ash.NotLoaded)
  • Full test suite passes (293 tests, 0 failures)

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

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.
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.

1 participant