Add Edit Link to All Post Types

The following snippet shows how to add the “Edit” link as a GraphQL field to all post types: This could then be queried like so:

Register Connection to Attached Media

This code shows how to register a connection to attached media in WPGraphQL You can then query for this new connection using the attachedMedia field on a ContentNode:

Tag to Content Node Connection

The following code registers a connection from Tags to ContentNodes. A field name called contentNodes will be added to the Tag type to make it easy to view all Posts that are tagged with that specific term.

List of Key Values

This is an example showing how to return a list of keys and values where the keys and values are both strings.

Popular Posts

The following code allows you to query for popular posts. It’s still up to you to determine the best way to store popular posts, but this example assumes a meta_key is involved. Beware though, meta queries can be expensive! You can query for the popular posts using this GraphQL query: