Skip to content

Interface Recursion Issues #3106

@zngly-vlad

Description

@zngly-vlad

Description

possible regression from #3100

In v1.24.0 - interface resolvers no longer run when similar pre-existing fields exist

Steps to reproduce

example code:

$type_registry->register_interface_type('MyTestNodeInterface', [
    'fields' => [
        'id' => [
            'type' => ['non_null' => 'ID'],
            'resolve' => function ($source, $args, $context, $info) {
                // check correct format
                return 'correctFormat==';
            },
        ],
        'databaseId' => [
            'type' => 'ID',
            'resolve' => function ($source, $args, $context, $info) {
                return 'interface_db_id==';
            },
        ],
    ]
]);

$type_registry->register_object_type('MyTestObject', [
    'interfaces' => ['MyTestNodeInterface'],
    'fields' => [
        'id' => [
            'type' => ['non_null' => 'ID'],
            'resolve' => function ($source, $args, $context, $info) {
                return 'not_correct_format==';
            },
        ],
        'hello' => [
            'type' => 'String',
            'resolve' => function ($source, $args, $context, $info) {
                return 'hello from object';
            },
        ],
    ],
]);

$type_registry->register_field('RootQuery', 'myTestQuery', [
    'type' => 'MyTestObject',
    'description' => 'A field that returns a MyTestObject',
    'resolve' => function ($source, $args, $context, $info) {
        return [];
    },
]);

actual:

{
  "data": {
    "myTestQuery": {
      "id": "not_correct_format==",
      "databaseId": "interface_db_id==",
      "hello": "hello from object"
    }
}

expected:

{
  "data": {
    "myTestQuery": {
      "id": "correctFormat==",
      "databaseId": "interface_db_id==",
      "hello": "hello from object"
    }
}

Additional context

For my use case I use interfaces to ensure data is formatted correctly on existing fields.

WPGraphQL Version

1.24.0

WordPress Version

Version 6.5.2

PHP Version

8.2.17

Additional environment details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

Labels

component: interfacesRelating to GraphQL Interface TypesregressionBug that causes a regression to a previously working featurescope: testsDeveloping unit tests, integration tests, and ensuring coveragestatus: actionableReady for work to begintype: bugIssue that causes incorrect or unexpected behavior

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions