AxeWP / wp-graphql-rank-math

Add GraphQL support for RankMath SEO
GNU General Public License v3.0
50 stars 7 forks source link

`seo` fields should resolve directly to the GraphQL object (instead of the interface) when possible. #79

Closed justlevine closed 4 months ago

justlevine commented 5 months ago

Description

Currently ${objectType}.seo is typed as RankMathSeo instead of RankMath${ObjectType}Seo.

This requires you to unnecessarily drill down the interface, like in https://github.com/AxeWP/wp-graphql-rank-math/pull/76/commits/53efda569ee0796a120b127aa66d77da7dffd5e5

We should leave the NodeWithSeo interface to use the RankMathSeo type, but for all direct connections we should resolve straight to the object. This would reduce complexity on both the query and implementation (i.e. graphql-Codegen) side of this.

[!important] This may be a breaking change to implement.

Steps to reproduce

query UserSeo( $id: ID! ) {
user( id: $id, idType: DATABASE_ID ){
    databaseId
    seo {
        fullHead
        # this should not be necessary 👇
        ... on RankMathUserSeo {
            additionalProfiles
            facebookProfileUrl
            twitterUserName
        }
    }
}

Additional context

No response

Plugin Version

0.1.0

WordPress Version

6.4.3

WPGraphQL Version

1.22.0

RankMath SEO Version

1.215.1

Additional enviornmental details

No response

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

Please confirm that you have disabled ALL plugins except for RankMath SEO, WPGraphQL, and WPGraphQL for Rank Math

justlevine commented 5 months ago

Ref: https://github.com/wp-graphql/wp-graphql/issues/3096