WP Manifestindependent plugin directory
manifest / integrations / wp-graphql-metabox

WPGraphQL Meta Box Integration WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

WPGraphQL for Meta Box

★ 28stars
681composer installs
0.4.0latest · 5 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/hsimah-services/wp-graphql-metabox/archive/refs/heads/master.zip

On Packagist as hsimah-services/wp-graphql-metabox:

composer require hsimah-services/wp-graphql-metabox
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

WPGraphQL-MetaBox: WPGraphQL provider for Meta Box

Quick Install

Download and install like any WordPress plugin.

Documentation

The WPGraphQL documentation can be found here.

  • Requires PHP 7.3+
  • Requires WordPress 5.4+
  • Requires WPGraphQL 1.1.3+
  • Requires Meta Box 5.3.8+
    • Requires MB User Meta extension for User fields

Overview

This plugin provides an integration for Meta Box and WPGraphQL.

By simply adding an extra graphql_name property to the field registration the field will be exposed in the GraphQL schema.

Usage:

This assume you know how to expose custom post types in WPGraphQL - read their documentation for further info.

Using Meta Box, define a custom field. Copy and paste the generated code to your functions.php (or where ever you store your custom code).

wp-graphql-metabox options

option type effect
graphql_name string adds the field to the GraphQL object(s) identified in post_types
graphql_mutate boolean adds the field to the GraphQL object(s) create and update mutation input

Add in the graphql_name to the field definition:

$meta_boxes[] = [
    'title' => 'Extra Fields',
    'id' => 'extra-fields',
    'post_types' => [
        0 => 'post',
    ],
    'context' => 'after_title',
    'priority' => 'high',
    'autosave' => true,
    'fields' => [
        [
            'id' => 'a_random_number',
            'name' => 'A Random Number',
            'type' => 'number',
            'std' => 5,
            'columns' => 2,
            'size' => 3,
            'graphql_name' => 'randomNumber',
            'graphql_mutate' => true
        ],
    ],
];

That's it. The field randomNumber will be exposed on the type post. This will work for any custom post types you may create.

NB: You must expose custom types by adding show_in_graphql to the configuration of the CPT.

A simple query might look like this:

query {
    posts {
        nodes {
            title
            content
            randomNumber
        }
    }
}

Limitations

Currently the plugin only supports custom fields on post and user types (ie no Settings Pages).

Currently the plugin only supports using the following Meta Box types:

  • taxonomy
  • taxonomy_advanced
  • switch
  • checkbox
  • checkbox_list
  • background
  • color
  • custom_html
  • date
  • heading
  • datetime
  • oembed
  • password
  • radio
  • textarea
  • time
  • select
  • email
  • tel
  • text
  • url
  • wysiwyg
  • fieldset_text
  • select_advanced
  • text_list
  • key_value
  • number
  • range
  • single_image
  • user
  • post
  • group If you require a field which is not supported please feel free to submit an issue (or better yet, a PR!)

Releases

7 releases.

Tag
Published
0.4.0 latest
Jan 4, 2021 5 years ago
Jan 4, 2021 5 years ago
Jan 2, 2021 5 years ago
Nov 9, 2020 5 years ago
May 3, 2020 6 years ago
Apr 20, 2020 6 years ago
Apr 19, 2020 6 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A grade

Security

WPGraphQL Meta Box Integration 0.4.0 · audited by WP Registry

No security issues found.

Audited release
0.4.0
Findings
none
Worst severity
—
Content hash
0682948d63f041c0b8fdc684…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.