Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action metadata to the meta field #236

Open
mathieupost opened this issue Sep 30, 2024 · 0 comments
Open

Add action metadata to the meta field #236

mathieupost opened this issue Sep 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mathieupost
Copy link

mathieupost commented Sep 30, 2024

Feature request

I tried to return an additional field for my resource by adding a metadata option to my create action like this:

      metadata :additional_data, :string, allow_nil?: false

And setting this value in a change using:

        result = Ash.Resource.put_metadata(result, :signed_url, url)

But unfortunately this did not result in filling this field in the meta field of the returned resource data.

Would be convenient for certain use cases to be able to pass additional data this way. I'm for example generating a signed url with write permissions for a storage bucket on creation of a resource. I only want to return this after creation. On reads I may want a read-only url.

@zachdaniel suggested to use the metadata option on the route instead of the action instead, or use a calculated field. A combination of both options would do the job for me (action metadata for write-enabled url, calculated field for read-only url), but if I add a graphql api as well I've got to declare metadata for create there again, which this feature would prevent.

Also, for batch create actions, I think it makes sense to have this metadata per resource instead of on the route.

Curious for options on this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Someday
Development

No branches or pull requests

2 participants