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

WPGraphQL for Carbon Fields

This FREE plugin from @matepaiva exposes fields registered using Carbon Fields to the WPGraphQL Schema

Community Plugin

View Plugin on Github
Plugin README

WpGraphQLCrb

A Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.

Usage

  1. First you have to install Carbon Fields and WpGraphQL.
  2. As this package is not published at Packagist yet, you must add the repository to your composer:
  1. Add the package to the required packages in your composer:
  1. Wrap every Carbon Field container that you want to expose via GraphQL with the static method WpGraphQLCrb\Container::register. For example:
  1. Now the query below will work:

Note: This is just the first version. There is a lot of work to be done. This packages exposes all the fields of the container, if the container type is post_meta, term_meta, or user.

Important: about Association_Field!

To make it work, I had to modify the original Carbon Fields package. Currently the Carbon_Fields\Field\Association_Field don't expose the types of the association, so it is not possible to make the GraphQL Union. To make this happen, I forked the original package and added a getter method in the Association_Field class:

I think this is the only way to get the types of the Association_Field and I hope that this change will be included in the next version, as it has very low impact to the package and a very high benefit to this integration.

If you need the Association_Field exposed in the GraphQL queries right now, you can use my temporary repository. Just add it to your composer.json:

Example

Query:

Result: