-
Notifications
You must be signed in to change notification settings - Fork 466
Description
Description
When using register_graphql_field(), a DUPLICATE_FIELD error is thrown even if the field being registered is compatible with the existing one.
For example, let's say a NodeWithSeo interface registers the seo: SeoInterface field. I should be able to overwrite PostObject.seo to be type PostObjectSeo implements SeoInterface. However, because at this point in the lifecycle, the interface fields are already merged with the fields in WPObjectType, the blind key-check sees that seo already exists and bails.
Ideally, if the field already exists, the new object type would be compared to see if it is compatible with the interface instead of throwing an error. (However I'm unaware of any internal methods for getting a list of implementing interfaces for a GraphQL object name).
Steps to reproduce
- Register your custom interface, e.g.
SeoInterface - Register your custom object that implements that interface. e.g.
PostObjectSeo. - Create a new interface to add a
seo: SeoInterfaceto allContentNodes. - Register a custom field on
PostObjectto override the type of your custom field:seo: PostObjectSeo. - Enable GraphQL Debugging and run the query.
Additional context
- The workaround is manually using the 'graphql_{$type_name}_fields' filter, but that's bad DX.
- This affects the schema usability for both WPGraphQL for Gravity Forms and WPGraphQL for RankMath Seo.
WPGraphQL Version
1.22.1
WordPress Version
6.5.0
PHP Version
8.1.15
Additional environment details
Ubuntu 20.04 ( wsl2 + devilbox).
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
Type
Projects
Status
