Skip to content

feat: Add phone format properties to resolve issue #441 - #475

Merged
justlevine merged 7 commits into
AxeWP:developfrom
chetanupare:develop
Feb 14, 2026
Merged

justlevine merged 7 commits into
AxeWP:developfrom
chetanupare:develop

Conversation

@chetanupare

@chetanupare chetanupare commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

[edited by @justlevine ]

What

Adds a new GfPhoneFormat GraphQL type to Phone fields, providing detailed format information (label, mask, regex, instruction, type).

Additionally, deprecates PhoneField.phoneFormat in favor of PhoneField.phoneFormatType to prepare for a future breaking change where phoneFormat will return the GfPhoneFormat type.

Why

How

Created PhoneFormatProperties object type
Added field to FieldWithPhoneFormat interface with resolver
Supports custom formats via gform_phone_formats filter
Updated tests and registered new type

Testing Instructions

  1. Create form with phone field
  2. Query: phoneFormatProperties { label mask regex instruction type }
  3. Verify returns format details for standard/international formats

Additional Info

Example Query

query GetPhoneField($formId: ID!) {
  gfForm(id: $formId, idType: DATABASE_ID) {
    formFields {
      nodes {
        ... on PhoneField {
          # New field for format type
          phoneFormatType
          
          # Deprecated - will change type in future
          phoneFormat @deprecated(reason: "Use phoneFormatType instead")
          
          # Experimental - format properties
          _phoneFormatExperimental {
            label
            mask
            regex
            instruction
            type
          }
        }
      }
    }
  }
}

Response:

{
  "phoneFormatType": "STANDARD",
  "phoneFormat": "STANDARD",
  "_phoneFormatExperimental": {
    "label": "(###) ###-####",
    "mask": "(999) 999-9999",
    "regex": "/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/",
    "instruction": "(###) ###-####",
    "type": "STANDARD"
  }
}

Checklist:

  • This PR is tested to the best of my abilities.
  • This PR follows the WordPress Coding Standards.
  • This PR has proper inline documentation.
  • This PR has unit tests to verify the code works as intended.
  • The changes in this PR have been noted in CHANGELOG.md

Chetan Upare added 2 commits January 29, 2026 01:41
- Create new PhoneFormatProperties object type with label, mask, regex, instruction, and type fields
- Add phoneFormatProperties field to FieldWithPhoneFormat interface with resolver
- Support custom phone formats via gform_phone_formats filter
- Update tests to include new phoneFormatProperties field
- Register PhoneFormatProperties type in TypeRegistry

Resolves: AxeWP#441
- Fix PHPCS violations in FieldWithPhoneFormat.php
- Add proper inline comment punctuation
- Add phpcs:ignore for third-party gform_phone_formats hook
- Add changelog entry for phoneFormatProperties feature
@justlevine justlevine added status: needs review 🧐 Needs to be reviewed by a codeowner type: enhancement ⚡ Improves on an existing feature labels Jan 29, 2026
@justlevine

Copy link
Copy Markdown
Member

Thanks so much for submitting this @chetanupare 🙇 I should hopefully have time over the weekend to review. (Feel free to ignore the copilot comments I just triggered - 80% of the time they're slop, but every once in a while they catch something helpful)

@codecov

codecov Bot commented Jan 29, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a phoneFormatProperties field to phone fields in the GraphQL schema to expose detailed phone format configuration (label, mask, regex, instruction, and type) from Gravity Forms. This addresses issue #441 where users needed access to format properties beyond just the format name for frontend implementation.

Changes:

  • Added new PhoneFormatProperties GraphQL object type to represent phone format configuration details
  • Extended FieldWithPhoneFormat interface with phoneFormatProperties field including resolver that uses the gform_phone_formats filter
  • Updated tests to query the new field and added test expectations

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Type/WPObject/PhoneFormatProperties.php New GraphQL object type defining the structure for phone format properties
src/Type/WPInterface/FieldSetting/FieldWithPhoneFormat.php Added phoneFormatProperties field with resolver that applies gform_phone_formats filter
src/Registry/TypeRegistry.php Registered the new PhoneFormatProperties type in the type registry
tests/wpunit/PhoneFieldTest.php Updated test query to include phoneFormatProperties field
tests/_support/Helper/GFHelpers/ExpectedFormFields.php Added test expectations for phoneFormatProperties field
CHANGELOG.md Documented the new feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/wpunit/PhoneFieldTest.php Resolved
- Add dedicated PhoneFieldInternationalFormatTest
- Normalize phone format properties for null/false values
- Adjust phone format expectations for international mask/regex

@chetanupare chetanupare left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test: Added international phone format coverage

  • Added dedicated PhoneFieldInternationalFormatTest
  • Normalized phone format properties for null/false values
  • Adjusted phone format expectations for international mask/regex

@chetanupare chetanupare left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: Used callable descriptions for phone format properties

@chetanupare chetanupare left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please Review!

Comment thread CHANGELOG.md Resolved
@justlevine

Copy link
Copy Markdown
Member

Ack - just realized that my pending notes to myself were published instead of pending for me to get to... should be able to polish this off and merge this week.

@justlevine

Copy link
Copy Markdown
Member

Failing schema test is from the fix in #483. I think this is good to merge now 🤔

@justlevine

justlevine commented Feb 14, 2026 •

Copy link
Copy Markdown
Member

@chetanupare take a look at the updated schema shape (and PR description), and lemme know what you think (here or on the issue). This gets it into the plugin asap while keeping the breaking schema change for the ideal implementation.

@justlevine
justlevine merged commit b17f342 into AxeWP:develop Feb 14, 2026
24 of 25 checks passed
@chetanupare

Copy link
Copy Markdown
Contributor Author

@chetanupare take a look at the updated schema shape (and PR description), and lemme know what you think (here or on the issue). This gets it into the plugin asap while keeping the breaking schema change for the ideal implementation.

Looked at the updated schema and PR description
this approach makes sense. Shipping _phoneFormatExperimental and phoneFormatType now gives us the format details and enum without a breaking change, and deprecating phoneFormat sets up the future change to return GfPhoneFormat. Happy with it as merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs review 🧐 Needs to be reviewed by a codeowner type: enhancement ⚡ Improves on an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants