Skip to content

Commit

Permalink
Release/0.8.0 (#144)
Browse files Browse the repository at this point in the history
* dev: make FormFieldEnum names shorter.

* dev: version bump

* dev: update docs

* dev: update changelog
  • Loading branch information
justlevine authored Aug 12, 2021
1 parent 29a0865 commit d02c82e
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 29 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## v0.8.0 - Revamped GraphQL Connections

** :warning: This release requires Gravity Forms v2.5.0 or higher. **

This release reworks all GraphQL connections, implementing data loaders, optimizing database queries, and adding support for more where args in more situations.

### New Features
- `gravityFormsForms` can now be filtered by a list of form IDs.
- `FormEntry` connections now have access to the following `where` args: `status`, `dateFilters`, `fieldFilters`, `fieldFiltersMode`.
- `formField` can now be filtered by a list of field IDs, `adminLabels`, and the field type.
- [Breaking] Full pagination support has been added to `Forms` and `Entries`. **Note**: cursor generation has changed, so if you are manually generating form or entry cursors, you will need to update your code.
- [Breaking] `FieldFiltersOperatorInputEnum` now supports all remaining Gravity Forms entry search operators, such as `LIKE`, `IS`, `IS_NOT`. The `GREATER_THAN` and `LESS_THAN` operators have been removed, as they are not supported by Gravity Forms.

### Bugfixes
- Correctly handle `sourceUrl` changes in `submitGravityFormsForm` and `updateGravityFormsDraftEntry` mutations.
- `wp_graphql_gf_can_view_entries` filter now correctly passes `$form_ids` instead of non-existent `$entry_ids`.
- `fieldFilters` now correctly search through `array` entry values.
- `EntriesFieldFiltersInput.key` is now optional.

### Under the Hood
- [Breaking] Bumped minimum GF version to v2.5.x.
- [Breaking] Connections have been completely refactored. The new classes are `EntryConnections`, `FieldConnections` and `FormConnections`.
- [Breaking] `RootQueryEntriesConnectionResolver` and `RootQueryFormsConnectionResolver` classes were renamed to `EntriesConnectionsResolver` and `FormConnectionResolver`. They now properly extend `AbstractConnectionResolver`.
- Form connections now implement a `DataLoader`.
- Added `GFUtils::get_forms()` for speedy requests from $wpdb.
- Fixed various code smells.
- docs: Updated information about queries to reflect pagination and new `where` args.
- tests: WPUnit tests now extend `GFGraphQLTestCase`.
- tests: [Breaking] `WPGraphQLGravityForms\Tests` namespace has been renamed to `Tests\WPGraphQL\GravityForms`.

## v0.7.3 - WPGraphQL v1.6.x Compatibility

This release adds compatibility with WPGraphQL v1.6.x, [and its new lazy/eager type loading](https://github.com/wp-graphql/wp-graphql/releases/tag/v1.6.0).
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Project Status: Active.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
![Packagist License](https://img.shields.io/packagist/l/harness-software/wp-graphql-gravity-forms?color=green)
![Packagist Version](https://img.shields.io/packagist/v/harness-software/wp-graphql-gravity-forms?label=stable)
![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/harness-software/wp-graphql-gravity-forms/0.7.3)
![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/harness-software/wp-graphql-gravity-forms/0.8.0)
![GitHub forks](https://img.shields.io/github/forks/harness-software/wp-graphql-gravity-forms?style=social)
![GitHub Repo stars](https://img.shields.io/github/stars/harness-software/wp-graphql-gravity-forms?style=social)

Expand Down Expand Up @@ -46,12 +46,13 @@ Our hope for this open source project is that it will enable more teams to lever

## Future Feature Enhancements

[_View all Feature Requests_](https://github.com/harness-software/wp-graphql-gravity-forms/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement)
- Add support for missing form fields [Github Issue](https://github.com/harness-software/wp-graphql-gravity-forms/issues/119)
- Add support for backwards pagination of lists of entries.
- Ability to query for lists of draft entries, or both entries and draft entries
- Ability to get the total count for a list of entries.
- Ability to create, update, and delete an individual Gravity Form.
- Create & update integration tests. [Github Issue](https://github.com/harness-software/wp-graphql-gravity-forms/issues/116).
-

## Documentation

Expand Down
7 changes: 2 additions & 5 deletions docs/deleting-entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can use the `deleteGravityFormsEntry` mutation to delete a [Gravity Forms en

```graphql
mutation {
deleteGravityFormsEntry(input: { clientMutationId: "123abc", entryId: 5 }) {
deleteGravityFormsEntry(input: { entryId: 5 }) {
entryId
}
}
Expand All @@ -23,10 +23,7 @@ Similarly, you can use `deleteGravityFormsDraftEntry` to delete a [Gravity Forms
```graphql
mutation {
deleteGravityFormsDraftEntry(
input: {
clientMutationId: "123abc"
resumeToken: "524d5f3a30c845b29a8db35c9f2aaf29"
}
input: { resumeToken: "524d5f3a30c845b29a8db35c9f2aaf29" }
) {
resumeToken
}
Expand Down
9 changes: 6 additions & 3 deletions docs/querying-entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ To query a Draft Entry, simply pass the `resumeToken` to the input `id` field, a

## Get a List of Entries

The code comments in the example query below explain how you can get a filtered list of entries.
The code comments in the example query below shows how you can fetch and filter data for multiple entries at once.

The plugin supports `first, after` and `last, before` cursor-based [pagination](https://www.wpgraphql.com/docs/connections/#solution-for-pagination-naming-conventions-and-contextual-data), but does not support `first, before` or `last, after` pagination. It also does not yet support querying for a list of draft entries.
[Cursor-based pagination](https://www.wpgraphql.com/docs/connections/#solution-for-pagination-naming-conventions-and-contextual-data) is supported. You can use the `first`, `last`, `before` and `after` fields, along with the data inside of `pageInfo` and the cursors returned by the API to get each page of forms data.

By default, WPGraphQL sets the maximum query amount to 100. This can be overwritten using the [`graphql_connection_max_query_amount` filter](https://www.wpgraphql.com/filters/graphql_connection_max_query_amount/).


```graphql
{
gravityFormsEntries(
first: 20
after: "eyJvZmZzZXQiOjAsImluZGV4Ijo0fQ==" # Or pass null to start from the beginning.
after: "YXJyYXljb25uZWN0aW9uOjk=" # Or pass null to start from the beginning.
where: {
# List of all the form IDs to include.
formIds: [1]
Expand All @@ -102,6 +103,8 @@ By default, WPGraphQL sets the maximum query amount to 100. This can be overwrit
{ key: "created_by", intValues: [1], operator: IN }
# Find entries where field 5 has a value of "somevalue".
{ key: "5", stringValues: [ "somevalue" ], operator: IN }
# Search all entry meta fields for a value.
{ stringValues: "somevalue", operator: CONTAINS }
]
# Sort fields in ascending order by "date_created"
sort: { direction: ASC, isNumeric: false, key: "date_created" }
Expand Down
42 changes: 36 additions & 6 deletions docs/querying-formfields.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Querying `formFields` and their values
# Querying `formFields`

Both [forms](https://docs.gravityforms.com/form-object/) and [entries](https://docs.gravityforms.com/entry-object/) use the `formFields` GraphQL Interface to retrieve information about [Gravity Forms fields](https://docs.gravityforms.com/field-object/), and their submission values.
## Getting the `formFields` from a form or entry.

In addition to the shared fields available on the Interface, each GF Field has its own set of GraphQL fields that are accessible with query fragments.
Both [forms](https://docs.gravityforms.com/form-object/) and [entries](https://docs.gravityforms.com/entry-object/) use the `formFields` GraphQL Interface to retrieve information about [Gravity Forms fields](https://docs.gravityforms.com/field-object/), and their submission values.

You can pass `first:300` to `formFields`, where `300` is the maximum number of fields you want to query for.
In addition to the shared fields available on the Interface, each Gravity Forms Field type has its own set of GraphQL fields that are accessible with query fragments.

## Example Query
### Example Query

```graphql
{
Expand Down Expand Up @@ -46,6 +46,8 @@ You can pass `first:300` to `formFields`, where `300` is the maximum number of f
}
```

## Getting `formField` entry values.

Entry values can be accessed similarly to other Gravity Forms Field properties, by including the corresonding GraphQL field in the fragment.

**Note**: Due to GraphQL limitations regarding Union types, you must use the specific value type specific to that field. A full list of field value types and their corresponding field fragments are below.
Expand All @@ -61,7 +63,7 @@ Entry values can be accessed similarly to other Gravity Forms Field properties,
| `value` _( string )_ | `ConsentField`<br>`DateField`<br>`EmailField`<br>`HiddenField`<br>`NumberField`<br>`PhoneField`<br>`PostContentField`<br>`PostExcerptField`<br>`PostTitleField`<br>`RadioField`<br>`SelectField`<br>`SignatureField`<br>`TextAreaField`<br>`TextField`<br>`WebsiteField` | n/a |
| `values` _( [ string] )_ | `ChainedSelectField`<br>`FileUploadField`<br>`MultiSelectField`<br>`PostCategoryField`<br>`PostCustomField`<br>`PostTagsField` | n/a |

## Example Query
### Example Query

```graphql
{
Expand Down Expand Up @@ -92,3 +94,31 @@ Entry values can be accessed similarly to other Gravity Forms Field properties,
}
}
```

## Filtering `formFields`.

The code comments in the example query below explain how you can get a filtered list of form fields.

```graphql
{
gravityFormsEntry(id: 1, idType: DATABASE_ID) {
entryId
formFields(
first: 300
after: "YXJyYXljb25uZWN0aW9uOjI=" # Or pass null to start from the beginning.
where: {
# Return a specific list of form fields.
ids: [1,4,8]
# Find form fields by their `adminLabel`.
adminLabels: ['projectID', 'mylabel']
# Filter form fields by field types.
types: [ ADDRESS, MULTISELECT, TEXTAREA ]
}
) {
nodes {
id
type
}
}
}
```
15 changes: 10 additions & 5 deletions docs/querying-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,25 @@ The `id` input accepts either the Gravity Forms form ID (`idType: DATABASE_ID`)

## Get a List of Forms.

The code comments in the example query below shows how you can fetch data for multiple forms at once.
The code comments in the example query below shows how you can fetch and filter data for multiple forms at once.

[Cursor-based pagination](https://www.wpgraphql.com/docs/connections/#solution-for-pagination-naming-conventions-and-contextual-data) is supported. You can use the `first`, `last`, `before` and `after` fields, along with the data inside of `pageInfo` and the cursors returned by the API to get each page of forms data.

Filtering is also supported. For the `where` field, you can specify a `status` to get forms that are active, inactive, in the trash, etc.

#### Example Query

```graphql
{
gravityFormsForms(
first: 10
after: "eyJvZmZzZXQiOjAsImluZGV4Ijo0fQ==" # Or pass null to start from the beginning.
where: { status: ACTIVE }
after: "YXJyYXljb25uZWN0aW9uOjM=" # Or pass null to start from the beginning.
where: {
# List of all the form IDs to include.
formIds: [1]
# Sort fields in ascending order by "title
sort: { direction: ASC, key: "title }
# Show only active forms.
status: ACTIVE
}
) {
pageInfo {
startCursor
Expand Down
1 change: 0 additions & 1 deletion docs/submitting-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ The `fieldValues` input takes an array of objects containing the `id` of the fie
submitGravityFormsForm(
input: {
formId: 50
clientMutationId: "123abc"
createdBy: 1 # The user ID.
fieldValues: [
{
Expand Down
2 changes: 0 additions & 2 deletions docs/updating-entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ You can update a [Gravity Forms entry](https://docs.gravityforms.com/entry-objec
{
updateGravityFormsEntry(
input: {
clientMutationId: "123abc"
entryId: 1
isRead: false # Optional. Used to mark the entry as read.
isStarred: false # Optional. Used to mark the entry as 'starred'.
Expand Down Expand Up @@ -47,7 +46,6 @@ Updating a [Gravity Forms draft entry](https://docs.gravityforms.com/database-st
{
updateGravityFormsEntry(
input: {
clientMutationId: "123abc"
resumeToken: "f82a5d986f4d4f199893f751adee98e9"
fieldValues: [
{
Expand Down
4 changes: 2 additions & 2 deletions docs/using-global-ids.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Global IDs vs Database IDs

The `id` input for Form and Entry queries accepts either the Gravity Forms ID (`idType: DATABASE_ID`) assigned to the WordPress database, or a global (base-64 encoded) ID (`idType: ID`).
The `id` input for Form and Entry queries accepts either the Gravity Forms ID ( `idType: DATABASE_ID` ) assigned to the WordPress database, or a global (base-64 encoded) ID ( `idType: ID` ).

To generate global ID for an object, you encode the name of the GraphQL type, followed by the database ID. This can be done in JavaScript using the `btoa()` function like this, where `GravityFormsForm` is the GraphQL type and `1` is the form ID:

Expand All @@ -13,7 +13,7 @@ You can also retrieve the global ID by returning the `id` field on the object.
The example query below shows how you can use a Global ID as your input, and how you can include the global ID in the query's response:

```graphql
{
query GravityFormsForm{
gravityFormsForm(id: "R3Jhdml0eUZvcm1zRm9ybTox", idType: ID) {
formId # This is the (int) `DATABASE_ID`.
id # This is the (string) global `ID`.
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tested up to: 5.8
Requires PHP: 7.4
Requires Gravity Forms: 2.5.0+
Requires WPGraphQL: 1.0.0+
Stable tag: 0.7.3
Stable tag: 0.8.0
Maintained at: https://github.com/harness-software/wp-graphql-gravity-forms
License: GPL-3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Enum/FormFieldsEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function get_values() : array {
$values = [];

foreach ( $fields as $field ) {
$values[ WPEnumType::get_safe_name( $field::$type ) ] = [
$values[ WPEnumType::get_safe_name( $field::$gf_type ) ] = [
'value' => $field::$gf_type,
// translators: GF Field type.
'description' => sprintf( __( 'FormField enum %s.', 'wp-graphql-gravity-forms' ), $field::$gf_type ),
Expand Down
2 changes: 1 addition & 1 deletion wp-graphql-gravity-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author: Harness Software
* Author URI: https://www.harnessup.com
* Update URI: https://github.com/harness-software/wp-graphql-gravity-forms/releases
* Version: 0.7.3
* Version: 0.8.0
* Text Domain: wp-graphql-gravity-forms
* Domain Path: /languages
* Requires at least: 5.4.1
Expand Down

0 comments on commit d02c82e

Please sign in to comment.