Gravity Forms is known for it's robust ecosystem of extenions. We aim to make it easy to support such customization, but there are limitations to what we can support out of the box.
By default, WPGraphQL for Gravity Forms adds basic query support for all Form fields recognized by Gravity Forms - including custom ones.
These types inherit the FormField interface.
Note: As of v0.10.0, Experimental fields are hidden by default and must be enabled. To track implementation status of experimental fields, please review this github issue
GraphQL fields are automatically registered to the type, based on the editor settings returned from GF_Field::get_form_editor_field_settings() .
Below is a list of supported editor settings:
add_icon_url_settingaddress_settingadmin_label_settingautocomplete_settingbackground_color_settingbase_price_settingborder_color_settingborder_style_settingborder_width_settingbox_width_settingcalculation_settingcaptcha_badge_settingcatcha_bg_settingcatcha_fg_settingcatcha_language_settingcatcha_size_settingcatcha_theme_settingcatcha_type_settingchained_choices_settingchained_selects_alignment_settingchained_selects_hide_inactive_settingcheckbox_label_settingchoices_settingcolumns_settingconditional_logic_field_settingconditional_logic_page_settingcontent_settingcopy_values_optioncredit_card_settingcss_class_settingdate_format_settingdate_input_type_settingdefault_value_settingdefault_value_textarea_settingdelete_icon_url_settingdescription_settingdisable_margins_settingdisable_quantity_settingduplicate_settingemail_confirm_settingenable_enhanced_ui_settingerror_message_settingfile_extensions_settingfile_size_settingforce_ssl_field_settinggquiz-setting-choicesgquiz-setting-randomize-quiz-choicesgquiz-setting-show-answer-explanationinput_mask_settinglabel_placement_settinglabel_settingmaxlen_settingmaxrows_settingmultiple_files_settingname_settingnext_button_settingnumber_format_settingother_choice_settingpassword_field_settingpassword_settingpassword_strength_settingpassword_visibility_settingpen_color_settingphone_format_settingplaceholder_settingplaceholder_textarea_settingpost_category_checkbox_settingpost_category_initial_item_settingpost_custom_field_settingpost_image_featured_imagepost_image_settingprepopulate_field_settingprevious_button_settingproduct_field_settingrange_settingrich_text_editor_settingrules_settingselect_all_choices_settingsize_settingsingle_product_inputs_settingsub_label_placement_settingtime_format_setting
Each setting is registered as a GraphQL Interface. Form fields that implement the above settings will have the GraphQL Interfaces and corresponding fields automatically registered to the type.
Custom field settings can be registered with the graphql_gf_form_field_setting_fields filter.
All Form fields have access to the value GraphQL field, which provides a string representation of the Form field's entry value, generated from GF_Field::get_value_export() .
Additionally, currently-supported Form Fields use type-specific value GraphQL fields.
By default, complex Gravity Forms form fields inherit the GraphQL fields set by their GF_Field::$inputType .
Some Gravity Forms form fields (for example, the Quiz Field or Custom Post Field) can be resolved dynamically to multiple types (for example, a Checkbox or Radio ).
For Gravity Forms core, these form fields are automatically registered as GraphQL interfaces, with each possible input type as GraphQL object that implements the interface.
For an example of the PostCategory field:
gfEntries{
formFields {
nodes {
databaseId
inputType
... on GfFieldWithPostCategoryCheckboxSetting { # the Form Field Setting Interface
hasAllCategories
}
... on GfFieldWithEnhancedUISetting {
hasEnhancedUI
}
... on PostCategoryCheckboxField {
checkboxValues {
id
value
}
}
# works the same as this:
... on PostCategoryField { # the complex Form Field inherited interface.
hasAllCategories
... on PostCategoryCheckboxField {
checkboxValues {
id
value
}
}
}
# works the same as this:
... on PostCategorySelectField {
hasEnhancedUI
value
hasAllCategories
checkboxValues {
id
value
}
}
}
}
}Developers wishing to support a custom Gravity Forms field that can resolve into multiple input types can make use of the graphql_gf_form_field_child_types filter.
Currently, only certain Form fields are supported by GraphQL mutations and can be used to submit entries and draft entries. Form fields without an explicitly registered FormFieldValuesInput are given the default value input, however most custom Gravity Forms fields will require replacing that with a different FieldValueInput instance
At this stage of development, we category Gravity Forms fields into three types.
These core (and a few first-party extension) Form fields are explicitly supported by the plugin. Their type-specific properties are registered in WPGraphQL, and they are extensively tested.
Currently supported form fields:
AddressFieldCaptchaFieldChainedSelectFieldCheckboxFieldConsentFieldDateFieldEmailFieldFileUploadFieldHiddenFieldHtmlFieldListFieldMultiSelectFieldNameFieldNumberFieldOptionFieldPageFieldPhoneFieldPostCategoryFieldPostContentFieldPostExcerptFieldPostImageFieldPostTagsFieldPostTitleFieldPriceFieldProductFieldQuantityFieldQuizFieldRadioFieldSectionFieldSelectFieldShippingFieldSignatureFieldTextAreaFieldTextFieldTimeFieldTotalFieldWebsiteField
These Gravity Forms core-only fields are not yet explicitly supported by the plugin. The only properties they have are those registered by the supported field settings and the string-formatted entry value and they are untested. Further, they are not supported by Form submissions.
These forms are hidden by default:
CreditCardField
To enable these plugins, you can define the WPGRAPHQL_GF_EXPERIMENTAL_FIELDS constant to true in wp-config.php[https://wordpress.org/support/article/editing-wp-config-php/].
// wp-config.php
define( `WPGRAPHQL_GF_EXPERIMENTAL_FIELDS`, true );You can also use the graphql_gf_ignored_field_types filter to add support on a field-by-field basis.
When a production-level version of this plugin is released, it is expected that all core Gravity Forms fields will be supported.
These Form fields - either custom or from extensions - are given basic query support out of the box, depending on their use use of supported field settings, and support for additional GraphQL fields, input types, and submit/update mutations must be added manually.
You can manually enable/disable support for individual Gravity Forms using the graphql_gf_ignored_field_types filter.
add_filter(
'graphql_gf_ignored_field_types',
function( array $ignored_fields ) : array {
// Disable the 'MultiSelect' field.
$ignored_fields[] = 'multiselect';
// Enable the repeater field:
$ignored_fields = array_diff( $ignored_fields, ['repeater'] );
return $ignored_fields;
}
);