Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matepaiva/wp-graphql-crb
Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.
https://github.com/matepaiva/wp-graphql-crb
Last synced: about 1 month ago
JSON representation
Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.
- Host: GitHub
- URL: https://github.com/matepaiva/wp-graphql-crb
- Owner: matepaiva
- Created: 2019-12-23T20:55:47.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-18T14:43:57.000Z (10 months ago)
- Last Synced: 2024-09-23T01:57:49.699Z (3 months ago)
- Language: PHP
- Size: 28.3 KB
- Stars: 23
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-wordpress-gatsby - WPGraphQL for Carbon Fields - This FREE plugin from @matepaiva exposes fields registered using Carbon Fields to the WPGraphQL Schema. (Plugins / WordPress)
README
# WpGraphQLCrb
A Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.
## Important
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`, `user_meta`, `comment_meta` or `theme_options`.
> Note: This is a very experimental version, so it is probably shipped with bugs.
## Usage
1. First you have to install Carbon Fields and WpGraphQL.
1. Then install this package via packagist: `composer require matepaiva/wp-graphql-crb`
1. Wrap every Carbon Field container that you want to expose via GraphQL with the static method `WpGraphQLCrb\Container::register`. For example:```php
where('term_taxonomy', '=', 'category')
->add_fields([
Field::make('image', 'crb_img')
->set_value_type('url')
])
);
```5. Now the query below will work:
```graphql
{
categories {
edges {
node {
id
crb_img
}
}
}
}
```## About Theme Options
Theme options are not part of any structure already known by Wordpress, so it has its own root. Every `theme_options` fields will be displayed in GraphQL as direct children of `crb_ThemeOptions`. Be carefull about name collision.