WPGraphQL for Posts 2 Posts
This FREE plugin from @KellenMace of @harness_up automatically creates GraphQL connections for all of your Posts 2 Posts connections.
Community Plugin
View Plugin on GithubPlugin README
📄↔📄 WPGraphQL for Posts 2 Posts
WordPress plugin that creates GraphQL connections for all of your Posts 2 Posts connections.
Overview
- All registered Posts 2 Posts connections will be automatically added as connections in the GraphQL schema.
- The field for each in the GraphQL schema will be the name of the Posts 2 Post connection, converted to camelCase and with the word "Connection" appended to it. So if the Posts 2 Posts connection is registered as
projects_to_managers
, the field in the GraphQL schema will be namedprojectsToManagersConnection
(see the example below). - Supports posts
Example
Let's say you have registered a Posts 2 Posts connection between the project
custom post type on your site and the user
object, like this:
With this plugin activated, you can query for the users connected to projects, like this:
You can also query from the other direction, and get the projects connected to users, like this:
Minimum Software Requirements
- PHP 7.4+
- WPGraphQL 0.12.1+
- Posts 2 Posts 1.6.6+
Future Enhancements
- Register a
where
arg for each post type/user object so you can query to find posts/users that are connected to them. - Expose connection metadata as edge fields in the GraphQL schema.
- Register input fields for the create & update mutations so you can update the connections.
I think the input fields for #3 will end up looking something like this: