generated from alleyinteractive/create-wordpress-plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
WPGraphQL Integration
Matthew Ell edited this page Mar 25, 2024
·
2 revisions
As of #152, WP Curate has built-in integration with WPGraphQL to support GraphQL applications.
- The interface type named
WPCurateInterface
is registered to GraphQL via WPGraphQL. - A connection field named
wpCuratePosts
onRootQuery
use to access WP Curate posts. Supports Inline Fragments when constructing your GraphQL queries.
Add custom post types using wp_curate_allowed_post_types
which will apply the WPCurateInterface
to each of the registered GraphQL Types.
An example GraphQL query that takes an array of IDs from various post types. The wpCuratePosts
connection will identify the post type based on the ID and apply the appropriate inline fragment according to it's registered type.
query myQuery($ids: [ID!]!) {
wpCuratePosts(where: {in: $ids}) {
nodes {
type: __typename
id: databaseId
title
cleanTitle
url: uri
date
updatedAt: modified
slug
... on MyCustomPostType {
tags {
nodes {
name
slug
}
}
}
... on Post {
excerpt: excerptRawRaw
categories {
nodes {
id: databaseId
title: name
url: uri
}
}
}
}
},
}