Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for possible Typing Improvements #119

Open
moonmeister opened this issue Dec 10, 2021 · 8 comments
Open

Suggestion for possible Typing Improvements #119

moonmeister opened this issue Dec 10, 2021 · 8 comments

Comments

@moonmeister
Copy link

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?

@moonmeister
Copy link
Author

moonmeister commented Dec 10, 2021

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
      }
    }
  }
}

@moonmeister
Copy link
Author

moonmeister commented Dec 10, 2021

Looks like the ContentNode or TermNode types might be valuable here.

@ashhitch
Copy link
Owner

@moonmeister This seems like a really good idea!

@moonmeister
Copy link
Author

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.

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the Stale label Feb 12, 2022
@moonmeister
Copy link
Author

Not stale

@github-actions github-actions bot removed the Stale label Feb 13, 2022
@justlevine
Copy link

@ashhitch would love to help with this, PMing you on the wp-graphql slack

@ashhitch
Copy link
Owner

Not stale

Sorry really need to remove this action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants