Skip to content

Commit

Permalink
feat!: implement FormField model, dataloader, and ConnectionResolver (#…
Browse files Browse the repository at this point in the history
…416)

* feat!: implement FormField model, dataloader, and ConnectionResolver

* fix: implement `Node` interface on `FormField`

* chore: add changelog
  • Loading branch information
justlevine authored May 26, 2024
1 parent 2be7e1e commit de8beb6
Show file tree
Hide file tree
Showing 33 changed files with 1,043 additions and 336 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- feat!: Implement `FormField` model and `DataLoader`, and refactor `FormFieldsConnectionResolver` to extend `AbstractConnectionResolver`.
- feat!: Refactor `FormsConnectionResolver` and `EntriesConnectionResolver` for compatibility with WPGraphQL v1.26.0 improvements.
- feat!: Narrow `FormField.choices` and `FormField.inputs` field types to their implementations.
- chore!: Bump minimum WPGraphQL version to v1.26.0.
Expand Down
86 changes: 43 additions & 43 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/querying-entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Entries that include [Pricing Fields](https://docs.gravityforms.com/category/use
name
price
options {
connectedFormField{
connectedFormField {
... on OptionCheckboxField {
databaseId
}
Expand Down
30 changes: 0 additions & 30 deletions src/CoreSchemaFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,5 @@ public static function register_hooks(): void {

// Change max query amount for form fields.
add_filter( 'graphql_connection_max_query_amount', [ Factory::class, 'set_max_query_amount' ], 11, 5 );

// Strip `Connection` interface from form fields.
add_filter( 'graphql_type_interfaces', [ self::class, 'strip_connection_interface_from_gf_fields' ], 10, 2 );
}

/**
* Strip `Connection` interface from form fields.
*
* @param string[] $interfaces Array of interfaces.
* @param array<string,mixed> $config The type config.
*
* @return string[]
*/
public static function strip_connection_interface_from_gf_fields( array $interfaces, array $config ): array {
// Bail early if Connection, 'Edge, or 'OneToOneConnection' arent in the interfaces.
if ( ! in_array( 'Connection', $interfaces, true ) && ! in_array( 'Edge', $interfaces, true ) && ! in_array( 'OneToOneConnection', $interfaces, true ) ) {
return $interfaces;
}

// If the config name contains `FormFieldConnection`, remove the `Connection` interface.
if ( false !== strpos( $config['name'], 'FormFieldConnection' ) || false !== strpos( $config['name'], 'QuizFieldConnection' ) ) {
$interfaces = array_filter(
$interfaces,
static function ( $interface_name ) {
return ! in_array( $interface_name, [ 'Connection', 'Edge', 'OneToOneConnection' ], true );
}
);
}

return $interfaces;
}
}
Loading

0 comments on commit de8beb6

Please sign in to comment.