Skip to content

Support for returning relay encoded id when subscribing to destroy events#307

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
mike1o1:fix_encoded_relay_ids_on_destroy_subscriptions
May 5, 2025
Merged

Support for returning relay encoded id when subscribing to destroy events#307
zachdaniel merged 1 commit intoash-project:mainfrom
mike1o1:fix_encoded_relay_ids_on_destroy_subscriptions

Conversation

@mike1o1
Copy link
Copy Markdown
Contributor

@mike1o1 mike1o1 commented May 4, 2025

Closes #306

Currently, if attempting to subscribe to a destroy event, the message that is received has the shape of something like:

"myResource": {
  "destroyed": "{myUUID}"
}

However, if a user has a schema with relay_ids?: true, this is the wrong type of ID, as it doesn't get encoded as a relay id.

This PR addresses that by passing the relay_ids? value down through the domains and resources, and eventually to the resolve/2 function which gets added to the Absinthe middleware. When encoding the id for a :destroy action, the relay_ids? setting will now be respected.


Tests

I couldn't find a way to change the relay_ids? value at runtime during the test, so this unfortunately requires setting up a whole new RelaySchema and associated RelayDomain and RelaySubscribable resource. While verbose, this seemed like the most straight forward way to keep existing tests and schema in place.

Contributor checklist

  • Bug fixes include regression tests
  • Features include unit/acceptance tests

@zachdaniel
Copy link
Copy Markdown
Contributor

Looks like some credo errors to fix.

@zachdaniel zachdaniel merged commit 70c266d into ash-project:main May 5, 2025
18 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

@mike1o1 mike1o1 deleted the fix_encoded_relay_ids_on_destroy_subscriptions branch May 5, 2025 18:46
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.

Subscriptions on :destroy action's don't respect relay_ids

2 participants