Returns type
I have a actions likes this
elixir
I want to override the default return type which defaults to the resource . and instead return a map type with fields user of type user resource and token of type string.
12 Replies
you could probably put it into the metadata to expose it along the resource https://ash-hq.org/docs/dsl/ash-resource#actions-update-metadata, or use a generic action https://ash-hq.org/docs/guides/ash/latest/topics/actions#generic-actions
Metadata is probably the best fit here IMO
Oh okay, I still don't how this will look like , will the API still return a user type ? If so how can the token be accessed?
It will be the user type with an extra metadata key
in the action you declare the type of the metadata
metadata :token, :string, allow_nil?: false
in the after action you would do
the api will return
this does not work as this is a graphql API
since the return type is a User the fields I query need to exist on the user.
it generates a different type for the graphql api
i'm already using this with graphql
hmm, might be only implemented for reads https://ash-hq.org/docs/dsl/ash-resource#graphql-queries-get
there are options for metadata fields
No i just checked I definetly have mutations using this.


it is part of the result type not the user, my bad
this worked thanks @barnabasj