Open paolospag opened 2 years ago
Hello, I'm new to this plugin and WPGraphQL and I would like to know if it's correct that the fields are empty with asPreview or if I rather need to change something.
asPreview
This is my query:
const GET_POST_BY_ID = gql` query PostBySlug($id: ID!, $idType: PostIdType = URI, $asPreview: Boolean = false) { post(id: $id, idType: $idType, asPreview: $asPreview) { id slug isPreview title(format: RENDERED) content(format: RENDERED) featuredImage { node { uri altText } } seo { title metaDesc metaKeywords breadcrumbs { text url } } } } `
And this is the method I use to run the query:
async function getSinglePost(id, asPreview = false) { const idType = asPreview ? 'DATABASE_ID' : 'URI'; const { data } = await client.query({ query: GET_POST_BY_ID, variables: { id, idType, asPreview, }, }); return data?.post || {}; }
When the variable asPreview is set to true, some fields related to Yoast SEO are empty. In particular:
seo { title metaDesc metaKeywords breadcrumbs { text url } }
Am I wrong something or is it correct that it behaves like this?
Hello, I'm new to this plugin and WPGraphQL and I would like to know if it's correct that the fields are empty with
asPreview
or if I rather need to change something.This is my query:
And this is the method I use to run the query:
When the variable
asPreview
is set to true, some fields related to Yoast SEO are empty. In particular:Am I wrong something or is it correct that it behaves like this?