Skip to content

Latest commit

 

History

History
480 lines (326 loc) · 20.1 KB

actions-and-filters.md

File metadata and controls

480 lines (326 loc) · 20.1 KB

Actions & Filters

Actions

graphql_gf_init

Fires after the plugin has been initialized.

do_action( 'graphql_gf_init', $instance );

Parameters

  • $instance (GF) : The plugin instance.

graphql_gf_after_register_types

Fires after plugin registers types to the GraphQL schema

do_action( 'graphql_gf_after_register_types' );

graphql_gf_before_register_types

Fires before plugin registers types to the GraphQL schema

do_action( 'graphql_gf_before_register_types' );

graphql_gf_after_register_form_field

gaphql_gf_after_register_form_field_{graphql_type}

Fires after the Gravity Forms field has been hooked to be registered WPGraphQL schema.

The fields themselves will only be registered on the next get_graphql_register_action() call.

do_action( 'graphql_gf_after_register_form_field', $field, $field_settings );
do_action( 'graphql_gf_after_register_form_field_' . $field->graphql_single_name, $field, $field_settings );

Parameters

  • $field (GF_Field) : The Gravity Forms field object.
  • $field_settings (array) : The Gravity Forms field settings.

Parameters

  • $field (GF_Field) : The Gravity Forms field object.
  • $field_settings (array) : The Gravity Forms field settings.
  • $config (array) : The config array as expected by WPGraphQL.

graphql_gf_after_register_form_field_object

gaphql_gf_after_register_form_field_object_{graphql_type}

Fires after the Gravity Forms field object has been registered to WPGraphQL schema.

do_action( 'graphql_gf_after_register_form_field_object', $field, $field_settings, $config );
do_action( 'graphql_gf_after_register_form_field_object_' . $field->graphql_single_name, $field, $field_settings, $config );

Parameters

  • $field (GF_Field) : The Gravity Forms field object.
  • $field_settings (array) : The Gravity Forms field settings.
  • $config (array) : The config array as expected by WPGraphQL.

Filters

graphql_gf_can_view_draft_entries

Filter to control whether the user should be allowed to view draft entries.

apply_filters( 'graphql_gf_can_view_draft_entries', bool $can_view_entries, int $form_id, string $resume_token, array $draft_entry );

Parameters

  • $can_view_entries (bool) : Whether the user can view draft entries. By default this anyone.
  • $form_id (int) : The GF form ID being queried by GraphQL.
  • $resume_token (string) : The draft entry resume token being queried by GraphQL.
  • $draft_entry (array) : The Gravity Forms draft entry data array.

graphql_gf_can_view_entries

Filter to control whether the user should be allowed to view submitted entries.

apply_filters( 'graphql_gf_can_view_entries', bool $can_view_entries, int $form_id, int $entry_id, array $entry );

Parameters

  • $can_view_entries (bool) : Whether the user can view draft entries. By default this is the user who submitted the entry, and any user with the gravityforms_view_entries and gform_full_access capabilities.
  • $form_id (int) : The GF form ID being queried by GraphQL.
  • $entry_id (string) : The entry ID being queried by GraphQL.
  • $draft_entry (array) : The Gravity Forms entry data array.

graphql_gf_entries_connection_query_args

Filter the Submitted Entry's $query_args to allow folks to customize queries programmatically.

apply_filters( 'graphql_gf_entries_connection_query_args', array $query_args, \WPGraphQL\GF\Data\Connection\EntriesConnectionResolver $resolver );

Parameters

  • $query_args (array<string,mixed>) : The query args that will be passed to GF_Query.
  • $resolver (WPGraphQL\GF\Data\Connection\EntriesConnectionResolver) : The resolver object.

graphql_gf_field_value_input_class

Filters the AbstractFieldValueInput class used to process form field submissions. Useful for adding mutation support for custom Gravity Forms fields.

apply_filters( 'graphql_gf_field_value_input_class', string $input_class, array $args, GF_Field $field, array $form, array|null $entry, bool $is_draft_mutation  );

Parameters

  • $input_class (string) : The FieldValueInput class to use. The class must extend AbstractFieldValueInput.
  • $args (array) : The GraphQL input value name to use. E.g. checkboxValues.
  • $field (GF_Field) : The current Gravity Forms field object.
  • $form (array) : The current Gravity Forms form object.
  • $entry (array|null) : The current Gravity Forms entry object. Only set when using update (gfUpdateEntry, gfUpdateDraftEntry) mutations.
  • $is_draft_mutation (bool) : Whether the mutation is handling a Draft Entry, i.e. on gfUpdateDraftEntry, or gfSubmitForm with saveAsDraft is true).

graphql_gf_field_value_input_args

Filters the GraphQL input args provided from the field value input. Useful for supporting custom Gravity Forms field value input types.

apply_filters( 'graphql_gf_field_value_input_args', array|string $args, GF_Field $field, array $form, array|null $entry, bool $is_draft_mutation, string $field_name );

Parameters

  • $args (string|array) : The input args from the field value input.
  • $field (GF_Field) : The current Gravity Forms field object.
  • $form (array) : The current Gravity Forms form object.
  • $entry (array|null) : The current Gravity Forms entry object. Only set when using update (gfUpdateEntry, gfUpdateDraftEntry) mutations.
  • $is_draft_mutation (bool) : Whether the mutation is handling a Draft Entry, i.e. on gfUpdateDraftEntry, or gfSubmitForm with saveAsDraft is true).
  • $name (string) : The GraphQL input value name to use. E.g. checkboxValues.

graphql_gf_field_value_input_name

Filters the accepted GraphQL input value key for the form field. Useful for adding support for custom Gravity Forms field value inputs.

apply_filters( 'graphql_gf_field_value_input_name', string $name, GF_Field $field, array $form, array|null $entry, bool $is_draft_mutation  );

Parameters

  • $name (string) : The GraphQL input value name to use. E.g. checkboxValues.
  • $field (GF_Field) : The current Gravity Forms field object.
  • $form (array) : The current Gravity Forms form object.
  • $entry (array|null) : The current Gravity Forms entry object. Only set when using update (gfUpdateEntry, gfUpdateDraftEntry) mutations.
  • $is_draft_mutation (bool) : Whether the mutation is handling a Draft Entry, i.e. on gfUpdateDraftEntry, or gfSubmitForm with saveAsDraft is true).

graphql_gf_field_value_input_prepared_value

Filters the prepared field value to be submitted to Gravity Forms. Useful for supporting custom Gravity Forms field value submissions.

apply_filters( 'graphql_gf_field_value_input_prepared_value', array|string $prepared_field_value, array|string $args, GF_Field $field, array $form, array|null $entry, bool $is_draft_mutation, string $field_name );

Parameters

  • $prepared_field_value : The field value formatted for use in Gravity Forms submissions.
  • $args (string|array) : The input args from the field value input.
  • $field (GF_Field) : The current Gravity Forms field object.
  • $form (array) : The current Gravity Forms form object.
  • $entry (array|null) : The current Gravity Forms entry object. Only set when using update (gfUpdateEntry, gfUpdateDraftEntry) mutations.
  • $is_draft_mutation (bool) : Whether the mutation is handling a Draft Entry, i.e. on gfUpdateDraftEntry, or gfSubmitForm with saveAsDraft is true).
  • $name (string) : The GraphQL input value name to use. E.g. checkboxValues.

graphql_gf_forms_connection_query_args

Filter the Form $query_args to allow folks to customize queries programmatically.

apply_filters( 'graphql_gf_forms_connection_query_args', array $query_args, \WPGraphQL\GF\Data\Connection\FormsConnectionResolver $resolver );

Parameters

  • $query_args (array<string,mixed>) : The query args that will be passed to GFAPI::get_forms().
  • $resolver (\WPGraphQL\GF\Data\Connection\FormsConnectionResolver) : The resolver object.

graphql_gf_form_field_child_types

Filter for altering the child types of a specific GF_Field.

apply_filters( 'graphql_gf_form_field_child_types', array $child_types, string $field_type );

Parameters

  • $child_types (array) : An array of GF_Field::$type => GraphQL type names. E.g.:
// For $type = 'quiz'.
$child_types = [
  'checkbox' => 'QuizCheckboxField',
  'radio'    => 'QuizRadioField',
  'select'   => 'QuizSelectField',
];
  • $field_type (string) : The 'parent' GF_Field::$type. E.g. quiz.

Parameters

graphql_gf_form_field_setting_choice_fields

graphql_gf_form_field_setting_choice_fields_{graphql_type}

Filter to modify the Form Field Choice GraphQL fields.

apply_filters( 'graphql_gf_form_field_setting_choice_fields', $fields, $choice_name, $field, $settings, $interfaces );
apply_filters( 'graphql_gf_form_field_setting_choice_fields_' . $choice_name, $fields, $field, $settings, $interfaces );

Parameters

  • $fields (array) : An array of WPGraphQL field $config arrays.
  • $choice_name (string) : The name of the choice type.
  • $field (GF_Field) : The Gravity Forms Field object.
  • $settings (array) : The form_editor_field_settings() keys.
  • $interfaces (array) : The list of interfaces for the GraphQL type.

graphql_gf_form_field_setting_input_fields

graphql_gf_form_field_setting_input_fields_{graphql_type}

Filter to modify the Form Field Input GraphQL fields.

apply_filters( 'graphql_gf_form_field_setting_input_fields', $fields, $input_name, $field, $settings, $interfaces );
apply_filters( 'graphql_gf_form_field_setting_input_fields_' . $input_name, $fields, $field, $settings, $interfaces );

Parameters

  • $fields (array) : An array of WPGraphQL field $config arrays.
  • $input_name (string) : The name of the input type.
  • $field (GF_Field) : The Gravity Forms Field object.
  • $settings (array) : The form_editor_field_settings() keys.
  • $interfaces (array) : The list of interfaces for the GraphQL type.

graphql_gf_form_field_setting_fields

graphql_gf_form_field_setting_fields_{graphql_type}

Filter to modify the Form Field Input GraphQL fields.

apply_filters( 'graphql_gf_form_field_setting_fields', $fields, $field, $settings, $interfaces );
apply_filters( 'graphql_gf_form_field_setting_fields_' . $field->graphql_single_nane, $fields, $field, $settings, $interfaces );

Parameters

  • $fields (array) : An array of WPGraphQL field $config arrays.
  • $field (GF_Field) : The Gravity Forms Field object.
  • $settings (array) : The form_editor_field_settings() keys.
  • $interfaces (array) : The list of interfaces for the GraphQL type.

graphql_gf_form_field_settings_with_choices

Filters the Gravity Forms field settings that should have a choices GraphQL Field.

apply_filters( 'graphql_gf_form_field_settings_with_choices', $settings_with_choices, $field_settings, $field, $as_interface );

Parameters

  • $settings_with_choices (array) : The Gravity Forms Field settings that should have a choices GraphQL Field.
  • $field_settings (array) : The Gravity Forms field settings.
  • $field (array) : The Gravity Forms field object.
  • $as_interface (array) : Whether the choice is a GraphQL interface.

graphql_gf_form_field_settings_with_inputs

Filters the Gravity Forms field settings that should have an inputs GraphQL Field.

apply_filters( 'graphql_gf_form_field_settings_with_inputs', $settings_with_inputs, $field_settings, $field, $as_interface );

Parameters

  • $settings_with_inputs (array) : The Gravity Forms Field settings that should have an inputs GraphQL Field.
  • $field_settings (array) : The Gravity Forms field settings.
  • $field (array) : The Gravity Forms field object.
  • $as_interface (array) : Whether the choice is a GraphQL interface.

graphql_gf_form_field_value_fields

graphql_gf_form_field_value_fields_{graphql_type}

Filter to modify the Form Field Input GraphQL fields.

apply_filters( 'graphql_gf_form_field_value_fields', $fields, $field );
apply_filters( 'graphql_gf_form_field_value_fields_' . $field->graphql_single_nane, $fields, $field);

Parameters

graphql_gf_form_field_values_input_fields

Filter to modify the Form Field value GraphQL fields. Useful for adding support for inputs used by custom Gravity Forms fields.

apply_filters( 'graphql_gf_form_field_values_input_fields', array $fields );

Parameters

graphql_gf_form_fields_name_map

Filter to map the Gravity Forms Field type to a safe GraphQL type (in PascalCase ).

apply_filters( 'graphql_gf_form_fields_name_map', array $fields_to_map );

Parameters

  • $fields_to_map (array) : An array of GF field types to GraphQL type names. E.g. 'fileupload' => 'FileUpload'.

graphql_gf_form_object

Filter to modify the form data before it is sent to the client. This hook is somewhat similar to GF's gform_pre_render hook, and can be used for dynamic field input population among other things.

apply_filters( 'graphql_gf_form_object', array $form, \WPGraphQL\GF\Data\Connection\FormsConnectionResolver $resolver );

Parameters

  • $form (array<string,mixed>) : The GF Form object.
  • $resolver (\WPGraphQL\GF\Data\Connection\FormsConnectionResolver) : The resolver object.

graphql_gf_gatsby_enabled_actions

Filter for overriding the list of enabled actions that WPGatsby should monitor.

apply_filters( 'graphql_gf_gatsby_enabled_actions', array $enabled_actions );

Parameters

  • $enabled (array) : An array of the enabled actions for WPGatsby to monitor. Possible array values: create_form, update_form, delete_form, create_entry, update_entry.

graphql_gf_ignored_field_types

Filters the list of ignored field types. Useful for adding/removing support for a specific Gravity Forms field.

apply_filters( 'graphql_gf_ignored_field_types', array $ignored_fields );

Parameters

  • $ignored_fields (array) : An array of GF_Field::$type names to be ignored by WPGraphQL.

graphql_gf_registered_{$type}_classes

Filters the list of PHP classes that register GraphQL types. Useful for adding/removing GF specific GraphQL types to the schema.

Possible types are connection (e.g. graphql_gf_registered_connection_classes ), enum , field , input , interface , mutation and object .

apply_filters( 'graphql_gf_registered_{$type}_classes', array $classes_to_register );

Parameters

  • $classes_to_register (array) : Array of PHP classes with GraphQL types to be registered to the schema.

graphql_gf_registered_form_field_setting_classes

graphql_gf_registered_form_field_setting_choice_classes

graphql_gf_registered_form_field_setting_input_classes

Filters the list of PHP classes that register GraphQL Interfaces based on a particular Gravity Forms field setting.

apply_filters( 'graphql_gf_registered_{$type}_classes', array $classes_to_register );

Parameters

  • $classes_to_register (array<string, class-string>) : Array of Gravity Forms setting keys and their PHP class that registers the setting's GraphQL Interface.

graphql_gf_registered_entry_types

Filter for modifying the Gravity Forms Entry types supported by WPGraphQL.

apply_filters( 'graphql_gf_registered_entry_types', array $entry_types );

Parameters

  • $entry_types (array) : An array of Data Loader names => GraphQL Types. E.g: [ [ 'gf_entry' => 'GfSubmittedEntry ] ]

graphql_gf_update_repo_url

Filters the repo url used in the update checker.

Useful for checking updates against a fork.

apply_filters( 'graphql_gf_update_repo_url', string $repo_link );

Parameters