Skip to content

v0.5.0 - Add Gatsby Support, Email Confirmation, and more!

Choose a tag to compare

@justlevine justlevine released this 24 Apr 14:14
· 370 commits to main since this release
4340056

** ⚠️ This release contains multiple breaking changes. **

This release moves entry.formField values from edges to nodes, slimming down the query boilerplate and making the plugin compatible with gatsby-source-wordpress. We also added support for submitting an email confirmationValue and retrieving PostImage values, squashed a few bugs, and made the wp_graphql_gf_can_view_entries filter more useful.

We also complete removed the form/entry fields property. All usage should be replaced with formFields.

New features

  • [Breaking] Removed fields from entry and form. Please update your code to use formFields instead.
  • [Breaking] Added support for submitting email confirmation values by using a new input type FieldValuesInput.emailValues.
{
  submitGravityFormsForm(
    input: {
      formId: 1
      clientMutationId: "123abcc"
      fieldValues: [
        {
          id: 1
-         value: "[email protected]"
+         emailValues: {
+           value: "[email protected]"
+           confirmationValue: "[email protected]" # Only necessary if Email confirmation is enabled.
         }
        }
      ]
    }
  )
}
  • [Breaking] The wp_graphql_gf_can_view_entries filter now passes entry_ids instead of field_ids. This lets you do cool things like allowing authenticated users to edit only their own entries:
add_filter(
  'wp_graphql_gf_can_view_entries',
  function( bool $can_view_entries, array $entry_ids ) {
    if ( ! $can_view_entries ) {
      $current_user_id = get_current_user_id();

      // Grab each queried entry and check if the `created_by` id matches the current user id.
      foreach ( $entry_ids as $id ) {
        $entry = GFAPI::get_entry( $id );

        if ( $current_user_id !== (int) $entry['created_by'] ) {
          return false;
        }
      }
    }

    return true;
  },
  10,
  2
);
  • Deprecated formFields.edges.fieldValue in favor of formFields.nodes.{value|typeValues}. Not just does this dramatically slim down the boilerplate needed for your queries, but it also works with gatsby-source-wordpress.
{
  gravityFormsEntry(id: 2977, idType: DATABASE_ID) {
    formFields{
-     edges {
-       fieldValue {
-         ... on TextFieldValue {
-           value
-         }
-         ... on CheckboxFieldValue {
-           checkboxValues {
-             inputId
-             value
-           }
-         }
-         ... on AddressFieldValue {
-           addressValues {
-             street
-             lineTwo
-             city
-             state
-             zip
-             country
-           }
-         }
-       }
-     }
      nodes {
        ... on TextField {
          # Other field properties
+         value
        }
        ... on CheckboxField {
          # Other field properties
+         checkboxValues {
+           inputId
+           value
+         }
        }
        ... on AddressField {
          # Other field properties
+         addressValues {
+           street
+           lineTwo
+           city
+           state
+           zip
+           country
+         }
        }
      }
    }
  }
}
  • Added support for retrieving PostImage field values.

Bugfixes

  • Fixed field ids missing from UpdateDraftEntry{Type}FieldValue errors.
  • Prevented PHP notices about missing entry_id when `submitGravityFormsDraftEntry fails.
  • Prevented UpdateDraftEntry{Type}FieldValue from deleting the previously stored ip.
  • Entry queries now correctly check for gform_full_access permission when gravityforms_edit_entries doesn't exist.
  • Undeprecate InputKeyProperty on name and address fields. Although this is not part of the GF api, it is helpful to associate the inputs with their entry values.

Under the hood

  • Added more unit tests for TextField, TextAreaField, and AddressField.
  • Refactored FieldProperty classes to use AbstractProperty.