Is it possible to get extra fields including joins returned from `useAuth`
I.e I want to request user org permissions, which is only available via a join
3 Replies
Hi @Noah. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the provided knowledge sources, it appears that the current implementation of
useAuth
in Wasp does not directly support returning extra fields including joins. However, there are a couple of relevant points to consider:
1. The user
object returned by useAuth
typically contains the fields defined in your User
entity, plus an auth
field with auth identities. This is mentioned in the Auth Overview documentation.
2. There is an open GitHub issue discussing the need to allow adding more information to the user
object that gets passed to Pages. This issue suggests that currently, if you want to enrich the user object with extra details or populate it with additional information, you would need to do additional queries in your React component for that Page. The proposed solution involves allowing a custom Query for fetching the user, which could include joins. You can find more details in this GitHub issue.
Given this information, it seems that currently, you cannot directly get extra fields including joins returned from useAuth
. To achieve what you're looking for (requesting user org permissions via a join), you would likely need to perform an additional query in your component after getting the basic user information from useAuth
.
It's worth noting that this limitation is recognized by the Wasp team, and there are discussions about improving this functionality in the future. However, as of now, you would need to implement a workaround by fetching the additional data separately.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Noah, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?It's not currently possible to include extra fields on the
AuthUser
that the useAuth
returns. You'd need to create a separate query to fetch the extra info for the user.
How do your models look like? User
-> Org
?User -> OrganizationUser -> Org
Thanks for quick response - do you have any recommendation for like currentOrganization? Including org info in the user auth session