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:
Tag Archives:
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:
Register object and field for custom list of users
The following code creates an object type called StuntPerformer and creates a field on the RootQuery called stuntPerformers that returns a custom list of users. In this case, the list of users are the admins of the website, but custom logic could be added to return a curated list of users. You can now query …
Continue reading “Register object and field for custom list of users”
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: