wordpress:wp graphql无法使用自定义帖子类型

wordpress:wp graphql无法使用自定义帖子类型,wordpress,graphql,wp-graphql,Wordpress,Graphql,Wp Graphql,我创建了一个自定义的post类型,但是它没有显示在GraphiQL资源管理器中 function create_custom_visions_post_type() { register_post_type('visions', array( 'labels' => array( 'name' => __('Visions'),

我创建了一个自定义的post类型,但是它没有显示在GraphiQL资源管理器中

function create_custom_visions_post_type() {
       register_post_type('visions',
                  array(
                      'labels' => array(
                        'name' => __('Visions'),
                        'singular_name' => __('Visions')
                  ),
                    'public' => true,
                    'show_in_admin_bar' => true,
                    'show_in_graphql' => true,
                    'graphql_single_name' => 'Vision',
                    'graphql_plural_name' => 'Visions',
));
}

根据wp graphql文档,只有“show_in_graphql”、“graphql_single_name”和“graphql_Multiple_name”标志才需要向graphql模式公开自定义post类型


我遗漏了什么?

好吧,愚蠢的我,我忘了添加

{
  resolve: `gatsby-source-graphql`,
  options: {
    // This type will contain remote schema Query type
    typeName: `WPGraphQL`,
    // This is field under which it's accessible
    fieldName: `wpgraphql`,
    // Url to query from
    url: `blablabla.local/graphql`,
  },
到gatsby-config.js


现在我的自定义帖子类型在wpgraphql{}中可用了

好吧,愚蠢的我,我忘了添加

{
  resolve: `gatsby-source-graphql`,
  options: {
    // This type will contain remote schema Query type
    typeName: `WPGraphQL`,
    // This is field under which it's accessible
    fieldName: `wpgraphql`,
    // Url to query from
    url: `blablabla.local/graphql`,
  },
到gatsby-config.js


现在,我的自定义post类型在wpgraphql{}

中可用,请确保在wpgraphql初始化架构之前注册您的CPT。您可以通过在
graphql_init
钩子中运行CPT注册代码来实现这一点

function create_custom_visions_post_type() {
       register_post_type('visions',
                  array(
                      'labels' => array(
                        'name' => __('Visions'),
                        'singular_name' => __('Visions')
                  ),
                    'public' => true,
                    'show_in_admin_bar' => true,
                    'show_in_graphql' => true,
                    'graphql_single_name' => 'Vision',
                    'graphql_plural_name' => 'Visions',
));
add_action( 'graphql_init', 'create_custom_visions_post_type' );

确保在WPGraphQL初始化架构之前注册CPT。您可以通过在
graphql_init
钩子中运行CPT注册代码来实现这一点

function create_custom_visions_post_type() {
       register_post_type('visions',
                  array(
                      'labels' => array(
                        'name' => __('Visions'),
                        'singular_name' => __('Visions')
                  ),
                    'public' => true,
                    'show_in_admin_bar' => true,
                    'show_in_graphql' => true,
                    'graphql_single_name' => 'Vision',
                    'graphql_plural_name' => 'Visions',
));
add_action( 'graphql_init', 'create_custom_visions_post_type' );

安装/激活插件;)。。。确保您的代码段被调用。。。“刷新
/graphiql
每次架构更改”@xadm是的,插件“WP GraphQL”处于活动状态,我已经用“盖茨比开发”重新启动了盖茨比。。。。没有成功:(别管盖茨比,测试wp graphqlseparately@xadm找到了解决方案…必须安装gatsby源代码graphql:)thx tho以获得您的帮助!安装/激活插件;)。。。确保您的代码段被调用。。。“刷新
/graphiql
每次架构更改”@xadm是的,插件“WP GraphQL”处于活动状态,我已经用“盖茨比开发”重新启动了盖茨比。。。。没有成功:(别管盖茨比,测试wp graphqlseparately@xadm找到了解决方案…必须安装gatsby源代码graphql:)thx tho以获得您的帮助!