admin管理员组文章数量:1289845
So, I started to experiment with a GraphQL plugin for WP, and was wondering how it'd work with Pods.
I came across a question on that plugin's GitHub that's pretty much the same thought I had. The maintainers supplied an answer:
Each Custom Post Type and Custom Taxonomy you want to add to the Schema should have the following fields set:
show_in_graphql (bool)
graphql_single_name (string)
graphql_plural_name (string)
I think I know how to do it with directly creating a custom post type register_post_type()
in PHP, but not sure how I'd do it in Pods.
So, I started to experiment with a GraphQL plugin for WP, and was wondering how it'd work with Pods.
I came across a question on that plugin's GitHub that's pretty much the same thought I had. The maintainers supplied an answer:
Each Custom Post Type and Custom Taxonomy you want to add to the Schema should have the following fields set:
show_in_graphql (bool)
graphql_single_name (string)
graphql_plural_name (string)
I think I know how to do it with directly creating a custom post type register_post_type()
in PHP, but not sure how I'd do it in Pods.
1 Answer
Reset to default 3You can definitely add filters for pods_register_post_type_{your_pod}
and pods_register_taxonomy_{your_pod}
. I'd love to build in support for GraphQL into Pods itself at some point. Just a matter of adding the checks if GraphQL is available and showing the options in the UI, similar to how we do our REST API options in the UI.
<?php
add_filter( 'pods_register_post_type_mycpt', 'add_pods_graphql_support' );
add_filter( 'pods_register_taxonomy_mytax', 'add_pods_graphql_support' );
function add_pods_graphql_support( $options ) {
$options['show_in_graphql'] = true;
$options['graphql_single_name'] = $options['labels']['name'];
$options['graphql_plural_name'] = $options['labels']['singular_name'];
return $options;
}
本文标签: custom post typesUsing GraphQL Plugin with Pods Framework
版权声明:本文标题:custom post types - Using GraphQL Plugin with Pods Framework 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741460792a2380026.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论