ashhitch / wp-graphql-yoast-seo

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

Plugin refactor with Interfaces. #125

Closed justlevine closed 1 year ago

justlevine commented 2 years ago

This PR is a complete refactor of the plugin. There are no breaking schema changes.

Highlights:

Notes:

  1. As the plugin now uses PSR-4, composer dump-autoload --no-dev --optimize should be run before committing. To autoload dev dependencies (for typehints and to stan/lint), run composer dump-autoload.
  2. There are still several remaining issues from composer phpcs and composer phpstan. These seem to be mostly bad types / non-existent properties, but without unit tests in place I didnt feel comfortable deviating from the original code.
  3. Searching the project for @todo will show a list of things that need to be edited. They are mostly file versions or missing GraphQL descriptions.
  4. WPPageInfo.seo doesnt actually do anything. However, as far as I can tell, neither did the original type (there is no native WP{post_type}Info only WPPageInfo ).
  5. The new interfaces: This is what prompted the entire rewrite, but i couldnt figure out how to place it in the original monolith file. If you wish to just backport this, the interfaces are defined in src/Type/WPInterface, and theyre added to the existing WPGraphQL interfaces in src/CoreSchemaFilters.php

PHP Breaking Changes

As mentioned above, theres been a minimum PHP version bump and a namespace change. Most function signatures have changed as well (they now type safety). I left all the global functions alone (in access-functions.php ), but the build functions that werent reused across classes are now in the relevant php class. (Imo all the global functions should be deprecated and moved to WPGraphQL\YoastSEO\Utils ).

Schema Changes

Detected the following changes (58) between schemas:

⚠  Category object implements TermNodeWithSEO interface
⚠  ExternalProduct object implements ContentNodeWithSeo interface
⚠  GroupProduct object implements ContentNodeWithSeo interface
⚠  MediaItem object implements ContentNodeWithSeo interface
⚠  Page object implements ContentNodeWithSeo interface
⚠  Post object implements ContentNodeWithSeo interface
⚠  PostFormat object implements TermNodeWithSEO interface
⚠  PostTypeSEO object implements SEOBaseFields interface
⚠  ProductCategory object implements TermNodeWithSEO interface
⚠  ProductTag object implements TermNodeWithSEO interface
⚠  ProductType object implements TermNodeWithSEO interface
⚠  ProductVariation object implements ContentNodeWithSeo interface
⚠  ShippingClass object implements TermNodeWithSEO interface
⚠  SimpleProduct object implements ContentNodeWithSeo interface
⚠  Tag object implements TermNodeWithSEO interface
⚠  TaxonomySEO object implements SEOBaseFields interface
⚠  VariableProduct object implements ContentNodeWithSeo interface
⚠  VisibleProduct object implements TermNodeWithSEO interface
✔  Description was removed from field Category.seo
✔  Field seo was added to interface ContentNode
✔  Type ContentNodeWithSeo was added
✔  Description was removed from field ExternalProduct.seo
✔  Description was removed from field GroupProduct.seo
✔  Description was removed from field MediaItem.seo
✔  Field seo was added to interface NodeWithFeaturedImage
✔  Description was removed from field Page.seo
✔  Description was removed from field Post.seo
✔  Description was removed from field PostFormat.seo
✔  Field PostToCategoryConnectionEdge.isPrimary description changed from The Yoast SEO Primary category to The Yoast SEO primary Categories.
✔  Field PostToPostFormatConnectionEdge.isPrimary description changed from The Yoast SEO Primary post_format to The Yoast SEO primary Formats.
✔  Field PostToTagConnectionEdge.isPrimary description changed from The Yoast SEO Primary post_tag to The Yoast SEO primary Tags.
✔  Object type PostTypeSEO has description The Yoast SEO data for the type.
✔  Description was removed from field Product.seo
✔  Description was removed from field ProductCategory.seo
✔  Description was removed from field ProductTag.seo
✔  Field ProductToProductCategoryConnectionEdge.isPrimary description changed from The Yoast SEO Primary product_cat to The Yoast SEO primary Product categories.
✔  Field ProductToProductTagConnectionEdge.isPrimary description changed from The Yoast SEO Primary product_tag to The Yoast SEO primary Product tags.
✔  Field ProductToProductTypeConnectionEdge.isPrimary description changed from The Yoast SEO Primary product_type to The Yoast SEO primary Product type.
✔  Field ProductToShippingClassConnectionEdge.isPrimary description changed from The Yoast SEO Primary product_shipping_class to The Yoast SEO primary Product shipping classes.
✔  Field ProductToVisibleProductConnectionEdge.isPrimary description changed from The Yoast SEO Primary product_visibility to The Yoast SEO primary Product visibility.
✔  Description was removed from field ProductType.seo
✔  Field seo was added to object type ProductVariation
✔  Field RootQuery.seo description changed from Returns seo site data to Returns seo site data.
✔  Type SEOBaseFields was added
✔  Description The Yoast SEO site level configuration data on type SEOConfig has changed to The Yoast SEO site level configuration data.
✔  Description he Yoast SEO search appearance content types fields on type SEOContentType has changed to The Yoast SEO search appearance content types fields
✔  Description he Yoast SEO search appearance content types fields on type SEOContentTypeArchive has changed to The Yoast SEO search appearance content types fields.
✔  Description The Schema for post type on type SEOPageInfoSchema has changed to The Schema for post type.
✔  Description The Yoast SEO  webmaster fields on type SEOWebmaster has changed to The Yoast SEO webmaster fields
✔  Description was removed from field ShippingClass.seo
✔  Description was removed from field SimpleProduct.seo
✔  Description was removed from field Tag.seo
✔  Object type TaxonomySEO has description The Schema types
✔  Field seo was added to interface TermNode
✔  Type TermNodeWithSEO was added
✔  Description was removed from field VariableProduct.seo
✔  Description was removed from field VisibleProduct.seo
✔  Field WPPageInfo.seo description changed from Raw schema for page to Raw schema for archive
success No breaking changes detected