ashhitch / wp-graphql-yoast-seo

This is an extension to the WPGraphQL plugin for Yoast SEO
GNU General Public License v3.0
216 stars 49 forks source link

Duplicate field notice of seo and isPrimary fields #167

Open okansahin opened 5 months ago

okansahin commented 5 months ago

I am getting these notices when I use this plugin:

    "type": "DUPLICATE_FIELD",
    "message": "You cannot register duplicate fields on the same Type. The field 'seo' already exists on the type 'Product'. Make sure to give the field a unique name.",
    "field_name": "seo",
    "type_name": "Product"

And for each taxonomies:

    "type": "DUPLICATE_FIELD",
    "message": "You cannot register duplicate fields on the same Type. The field 'isPrimary' already exists on the type 'ProductToProductCategoryConnectionEdge'. Make sure to give the field a unique name.",
    "field_name": "isPrimary",
    "type_name": "ProductToProductCategoryConnectionEdge",

After I for quick lookup I see that

https://github.com/ashhitch/wp-graphql-yoast-seo/blob/56600b12d3c2a0b73cb3b73020e23d4d9d5ad858/wp-graphql-yoast-seo.php#L315

line is already contains 'product' item. So we don't need to add it manually

https://github.com/ashhitch/wp-graphql-yoast-seo/blob/56600b12d3c2a0b73cb3b73020e23d4d9d5ad858/wp-graphql-yoast-seo.php#L320

And also for 'Product' type https://github.com/ashhitch/wp-graphql-yoast-seo/blob/56600b12d3c2a0b73cb3b73020e23d4d9d5ad858/wp-graphql-yoast-seo.php#L842-L851

after I comment out these lines, the notices has gone and the functionality still works as expected.

I didn't examine the repo in detail, as I said, I just did a quick debug to get rid of the problem. Can the repo authors comment on this?

I can also create a PR for this. And I think https://github.com/ashhitch/wp-graphql-yoast-seo/issues/40 is also related with

Thank you

ashhitch commented 5 months ago

@okansahin a PR would be very welcome.