Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Getting memberships for a user via jsonapi #730

Open
ebeyrent opened this issue Nov 24, 2021 · 1 comment
Open

Getting memberships for a user via jsonapi #730

ebeyrent opened this issue Nov 24, 2021 · 1 comment

Comments

@ebeyrent
Copy link

Problem/Motivation

As a front-end developer, I want to be able to show a list of all groups a given user has a membership in. With jsonapi, that's fairly trivial:

GET /jsonapi/og_membership/default?filter[uid.id][value]=<uuid>

However, the response gives me the related entity bundle, id, and type of the group associated with the membership. What it's missing is the title of the related group. Because of the field structure here, I can't get all the information I need about the group without making extra requests.

Screen Shot 2021-11-24 at 9 46 33 AM

I see some potential solutions here:

  • Add a new base field for the related group title
  • Add a computed field for the related group title
  • Add a new typed data normalizer to add in the missing group title

Perhaps there are other approaches I haven't considered?

@ebeyrent
Copy link
Author

Similarly, once you have the list of these membership entities and you wish to use jsonapi to create a relationship between one entity and the group referenced in the membership, you'll need the UUID of the group. That uuid ought to be included with the membership entity so you don't have to make another request just to get it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant