Created
November 16, 2020 16:34
-
-
Save ben-wright/932aa80a2bf671d462b1533dba52827e to your computer and use it in GitHub Desktop.
ACF Gravity Form Field Support for WPGraphQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( | |
| 'wpgraphql_acf_register_graphql_field', | |
| function ($field_config, $type_name, $field_name, $config) { | |
| if (isset($config['acf_field']['type']) && 'forms' === $config['acf_field']['type']) { | |
| $field_config['type'] = 'GravityFormsForm'; | |
| $field_config['resolve'] = function ($root, $args, $context, $info) { | |
| $formRaw = GFAPI::get_form($root['field_5f90411866d06']); // ACF gravity form field ID here | |
| $fieldManipulator = new WPGraphQLGravityForms\DataManipulators\FieldsDataManipulator($formRaw['fields']); | |
| $formManipulator = new WPGraphQLGravityForms\DataManipulators\FormDataManipulator($fieldManipulator); | |
| $formattedData = $formManipulator->manipulate($formRaw); | |
| return $formattedData; | |
| }; | |
| } | |
| return $field_config; | |
| }, | |
| 10, | |
| 4, | |
| ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used in combination with: https://github.com/dannyvanholten/acf-gravityforms-add-on