hsimah-services/wp-graphql-mb-relationships

WPGraphQL集成MB关系的插件

0.4.0 2020-07-25 23:12 UTC

This package is auto-updated.

Last update: 2024-09-26 09:21:03 UTC


README

MB关系WPGraphQL提供者

这是一个简单的WPGraphQL集成插件,用于Meta Box关系。 目前只支持帖子类型。

需要添加到API配置中的三个新字段

  • show_in_graphql - 一个布尔值,用于在模式中显示连接
  • graphql_name - 模式中连接字段的名称
  • graphql_args - 连接参数(可选)
  • resolve - 解析处理程序(请参阅WPGraphQL文档)(实验性)
  • resolve_node - 节点解析处理程序(请参阅WPGraphQL文档)(实验性)
MB_Relationships_API::register( [ 
  'id'     => 'linked_posts', 
  'from'   => array(
      'show_in_graphql' => true,
      'graphql_name' => 'goingUp',
      'graphql_args' => [
        'higher' => [
	  'type' => 'Boolean',
	  'description' => 'Field Description',
         ],
       ],
      'object_type' => 'post', 
      'post_type'   => 'mypost', 
      'meta_box'    => [
          'title'         => 'Going Up!', 
          'context'       => 'side', 
      ],
    ], 
    'to'    => [
      'show_in_graphql' => true,
      'graphql_name' => 'goingDown',
      'object_type' => 'post', 
      'post_type'   => 'mypost', 
      'meta_box'    => [
          'title'         => 'Going Down!', 
          'context'       => 'side', 
          'empty_message' => 'None', 
      ], 
    ], 
  ]
);