Homepage
Link to WPGraphQL on Github
Link to WPGraphQL on WordPress.org

WPGraphQL for Metabox

This FREE plugin from @hsimah exposes fields registered using the popular http://MetaBox.io to the WPGraphQL Schema.

Community Plugin

View Plugin on Github
Plugin README

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 0.8.1+
  • Requires Meta Box 5.2.10+
  • 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).

Add in the graphql_name to the field definition:

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:

Limitations

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

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

  • switch
  • checkbox
  • checkbox_list
  • background
  • color
  • custom_html
  • date
  • heading
  • datetime
  • oembed
  • password
  • radio
  • textarea
  • time
  • select
  • text
  • fieldset_text
  • number
  • range
  • text_list
  • key_value
  • select_advanced
  • url
  • single_image