Arguments defined on Interface Fields are not inherited by the fields on the Implementing Object Type
jasonbahl opened this issue · comments
Jason Bahl commented
Description
When registering an Interface Type with fields that have arguments, then registering an Object Type that implements that Interface, the fields of the Interface Type are inherited by the ObjectType, but the argument(s) on the fields are not inherited, causing invalid schema issues.
Steps to reproduce
- register an interface type that contains a field with an argument:
register_graphql_interface_type( 'InterfaceWithArgs', [
'fields' => [
'fieldWithArgs' => [
'type' => 'String',
'args' => [
'interfaceArg' => [
'type' => 'String',
],
],
'resolve' => function( $source, $args ) {
return $args['arg'];
}
],
]
] );
- register an object type that contains a field with the same name, but with no arguments:
register_graphql_object_type( 'ObjectTypeImplementingInterfaceWithArgs', [
'interfaces' => [ 'InterfaceWithArgs' ],
'fields' => [
'fieldWithArgs' => [
'type' => 'String',
'resolve' => function() {
return 'object value';
}
],
],
] );
- Register a field to add the Types to the Schema:
register_graphql_field( 'RootQuery', 'interfaceArgsTest', [
'type' => 'ObjectTypeImplementingInterfaceWithArgs',
'resolve' => function() {
return true;
},
]);
- Open the GraphQL IDE and see the following error:
Interface field argument InterfaceWithArgs.fieldWithArgs(interfaceArg:) expected but
ObjectTypeImplementingInterfaceWithArgs.fieldWithArgs does not provide it.
Additional context
This appears to be a regression of v1.24.0 release (specifically #3100).
WPGraphQL Version
1.24.0
WordPress Version
6.5.2
PHP Version
8.2
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.
Jason Bahl commented
related: #3115