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

Support for Relationship Meta #22

Open
jasonbahl opened this issue Mar 24, 2018 · 0 comments
Open

Support for Relationship Meta #22

jasonbahl opened this issue Mar 24, 2018 · 0 comments

Comments

@jasonbahl
Copy link

It would be awesome to have support for relationship meta.

There’s often situations where data isn’t a property of one entity or the other, but exists only in the context of their relationship with each other, and it doesn’t make sense to store said data in the meta of one or the other object, but ideally somewhere between, such as relationship meta.

For example, let’s say we were making an activity stream, and we wanted “activity items” to show as “unread” or “read” (similar to email). Since activity items and users would be a many-to-many relationship, we wouldn’t want an activity to be marked “read” when any user read it, we’d only want it to be marked “read” for you, if you read it.

Currently, the options are to store an array of user IDs in the activity item meta, and use that to determine if the current user has or has not “read” the item, or you could store an array of items in each users meta. . . Neither are good solutions. Storing user IDs on the activity is likely the better of the two, but still doesn’t scale
If you have a lot of users.

It would be awesome to have a formal way to store this contextual data, and in some cases even query by it.

I believe Posts 2 Posts has support for relationship meta. Might be worth looking at for inspiration 🤷‍♂️🤔

Anyway, I can think of heaps of examples where this would be useful.

Gotta throw out mention of GraphQL while I’m at it... 😀

In the WPGraphQL Schema, there’s a concept of “edges” which is the space between two nodes. For example, there’s an edge between a user and a post, or a Post and a Featured Image. This “edge” space is used for exposing contextual information that’s only relevant in the context of the relationship between the two connected nodes.

WPGraphQL could easily take advantage of relationship meta by exposing it on the edges.

@jeffpaul jeffpaul added this to the Future Release milestone Jul 14, 2020
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

No branches or pull requests

2 participants