ashhitch / wp-graphql-yoast-seo

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

SEO fields on Page Info Data #134

Closed evrenbal closed 2 years ago

evrenbal commented 2 years ago

It is possible to query all SEO fields (including raw schema) on single nodes (Post, Page etc.), but for Page Info Data, I can't query the SEO information other than raw schema.

Is this the intended behavior? Can someone suggest a workaround to query this information on ContentType nodes?

izzygld commented 2 years ago

Hi @evrenbal

Not sure what your question is:


`query contentBy($id: ID!) {
  contentNode(id: $id, idType: URI){
    ...Page
  }
}

query Pageby($id: ID!) {
  page(id: $id, idType: URI) {
    title
    ...Page
  }
}

fragment Page on Page {
  slug
  title
  author {
    node {
      name
    }
  }
  status
  dateGmt
  date
  desiredSlug
  modified
  modifiedGmt
  seo {
    title
    canonical
    metaKeywords
    metaRobotsNofollow
    metaRobotsNoindex
    opengraphAuthor
    opengraphDescription
    opengraphModifiedTime
    opengraphPublishedTime
    opengraphPublisher
    opengraphSiteName
    opengraphTitle
    opengraphType
    opengraphUrl
    twitterDescription
    twitterTitle
    cornerstone
    focuskw
    readingTime
    fullHead
    metaDesc
    schema {
      articleType
      pageType
      raw
    }
    opengraphImage {
      mediaItemUrl
      mediaDetails {
        width
        height
        file
      }
      mediaType
      mimeType
    }
    breadcrumbs {
      text
      url
    }
  }
}`
ashhitch commented 2 years ago

as of the latest release you can do:

query get_post {
  contentNode(id: "1", idType: DATABASE_ID) {
    id
    contentTypeName
    seo {
      title
      metaDesc
    }
  }

}