Suggestion for possible Typing Improvements
I was trying to abstract my SEO information into my layout so I didn't have to repeat myself in each post/page/tag/category/etc template. The query I started writing looks like this:
query SEO_QUERY($path: ID!) {
nodeByUri(uri: "/blog/post-1") {
... on Page {
seo {
...SeoData
}
}
... on Post {
seo {
...SeoData
}
}
... on Tag {
seo {
...SeoData
}
}
}
}
`;
This seems extremely verbose given the same fields are available on all (or so I suppose). WPGraphQL already has types that solve this issue for things like Title/Author/etc:
{
nodeByUri(uri: "/blog/post-1/") {
... on NodeWithTitle {
title
}
}
}
What I'm recommending is we create type like NodeWithSeo for yoast:
{
nodeByUri(uri: "/blog/post-1/") {
... on NodeWithSeo {
seo {
...SeoData
}
}
}
}
Thoughts?
Based on the Readme it looks like not all seo fields are created with the same data. But even if we combined post/pages, tag/categories, etc... that could still be helpful. e.g.
{
nodeByUri(uri: "/blog/post-1/") {
... on TermNodeWithSeo {
seo {
...SeoData
}
}
... on ContentNodeWithSeo {
seo {
...SeoData
}
}
}
}
Looks like the ContentNode or TermNode types might be valuable here.
@moonmeister This seems like a really good idea!
Thanks, I unfortunately don't have much for PHP skills...so can't help with implementation. I also had the though that NodeWithFullHead or NodeWithCommonSeo could be other helpful types.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Not stale
@ashhitch would love to help with this, PMing you on the wp-graphql slack
Not stale
Sorry really need to remove this action