If the Custom Post Type (CPT) has a type that has been mapped to the schema, we can add it to the
Otherwise, we can support retrieving the CPT data via the
Let's see how to configure both alternatives.
1. CPTs mapped to the schema permalink
CustomPostUnion type is used whenever an entity may return entities from different CPT types (such as
The different CPT modules can make their type be part of
CustomPostUnion through their Settings.
For instance, type
Page is added to
CustomPostUnion under the Settings for
CustomPostUnion to a single type instead permalink
If there is only one type added to
CustomPostUnion, we can then have the fields that resolve to
CustomPostUnion be instead resolved to that unique type instead:
For instance, if
Post is the only type, field
customPosts from type
Root resolves to it directly:
2. CPTs not mapped to the schema permalink
Tab "Schema Generic Custom Posts" in the Settings has input
Included custom post types, listing down all the Custom Post Types registered in the WordPress site.
From the list, select those CPTs that need to be queried through GraphQL (more than one can be selected by pressing the
shift keys), and field
genericCustomPosts will fetch their entries: