WPGraphQL for Carbon Fields
This FREE plugin from @matepaiva exposes fields registered using Carbon Fields to the WPGraphQL Schema
Community PluginView Plugin on Github
A Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.
- First you have to install Carbon Fields and WpGraphQL.
- As this package is not published at Packagist yet, you must add the repository to your composer:
- Add the package to the required packages in your composer:
- Wrap every Carbon Field container that you want to expose via GraphQL with the static method
WpGraphQLCrb\Container::register. For example:
- 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
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
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