Support for Relationship Meta

Open
#22 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
graphql, php

Research direction

No source files, entry points, or tests are named. Start by mapping the repository’s relationship storage and query paths, then review how GraphQL edges are exposed. Done means relationship-scoped metadata can be stored and, where appropriate, queried and exposed on the corresponding edges.

Written by the indexing model from the issue text.

Description

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.

Dominant language
PHP
Stars
97
Forks
24
Avg merge
3d 3h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 10up/wp-content-connect

All issues in 10up/wp-content-connect

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.