Skip to content

Commit

Permalink
fix: correctly use filtered form fields when preparing the connection…
Browse files Browse the repository at this point in the history
… data. (#395)

* fix: correctly use filtered form fields when preparing the connection data.

* tests: fix CaptchaFieldTest::testField
  • Loading branch information
justlevine authored Feb 4, 2024
1 parent e0df04d commit 18014a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
## Unreleased

- fix: Ensure `EmailField` inputs are hydrated when Email Confirmation is disabled. H/t @gytjarek.
- fix: Correctly use filtered form fields when preparing the connection data. H/t @samuelhadsall.
- chore: Update `yahnis-elsts/plugin-update-checker` to v5.3.
- chore: Update `axepress/wp-graphql-cs` to v2.0.0-beta.2 and fix resulting issues.
- chore: Update Composer dev deps.
- chore: Test compatibility with WordPress 6.4.x
- ci: Test compatibility with WordPress 6.4.x
- docs: Add docs on troubleshooting i18n issues. H/t @dev-ditrict-web.

## v0.12.4
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Connection/FormFieldsConnectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function resolve( $source, array $args, AppContext $context, Resol

$fields = self::filter_form_fields_by_connection_args( $source, $args );

$fields = self::prepare_data( $source );
$fields = self::prepare_data( $fields );

$connection = Relay::connectionFromArray( $fields, $args );

Expand Down Expand Up @@ -172,7 +172,7 @@ private static function filter_form_fields_by_connection_args( $fields, $args ):
if ( isset( $args['where']['pageNumber'] ) ) {
$page = absint( $args['where']['pageNumber'] );

$fields = array_filter( $fields, static fn ( $field ) => $page === (int) $field['pageNumber'] );
$fields = array_filter( $fields, static fn ( $field ) => $page === (int) $field->pageNumber );
}

return $fields;
Expand Down
2 changes: 1 addition & 1 deletion tests/wpunit/CaptchaFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function entry_query() : string {
return "
query getFieldValue(\$id: ID!, \$idType: EntryIdTypeEnum) {
gfEntry(id: \$id, idType: \$idType ) {
formFields(where:{fieldTypes:CAPTCHA}) {
formFields {
nodes {
{$this->field_query}
}
Expand Down

0 comments on commit 18014a5

Please sign in to comment.