AxeWP / wp-graphql-rank-math

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

feat: map user social meta fields #76

Closed colis closed 5 months ago

colis commented 5 months ago

What

This PR maps the social meta fields of the User object to the RankMathUserSeo type, i.e.

user(id: "5", idType: DATABASE_ID) {
  seo {
    ... on RankMathUserSeo {
      social {
        additionalProfiles
        facebookProfileUrl
        twitterUserName
      }
    }
  }
}

Why

The Rank Math plugin allows us to add user's Facebook URL, Twitter username and other profiles. Therefore this data needs to be mapped to the GraphQL schema.

How

Testing Instructions

  1. Populate the aforementioned fields on the User profile page
  2. Use the query above in the GraphiQL IDE

Additional Info

Checklist:

colis commented 5 months ago

Code looks great - thanks @colis !

From a schema perspective, I'm wondering if we really want to introduce the RankMathUserSocialMeta interface vs making these fields directly available on RankMathUserSeo.

The latter would make the schema more robust to future changes (i.e. less likely for a change to necessitate something breaking), but I don't want a tech argument to win out if there's a practical use case I'm missing. 🤔

yep, that probably makes everything a bit easier 👍

justlevine commented 5 months ago

(Note to self: schema should resolve directly to the Object type not to the interface type. having to do ... on RankMathUserSeo when we're already at user.seo is stupid. Tracking in #79 )