Internal server error when querying SEO fields for a user that has no posts
marcusforsberg opened this issue · 1 comments
marcusforsberg commented
Running a query such as:
query GET_USER {
user(id: 2, idType: DATABASE_ID) {
name
seo {
title
}
}
}
This triggers an internal server error. Debug mode shows this specific error message: Call to a member function get_head() on bool
The cause seems to be in get_post_type_graphql_fields()
:
'fullHead' => is_string(
YoastSEO()
->meta->for_author($user->userId)
->get_head()
)
? YoastSEO()
->meta->for_author($user->userId)
->get_head()
: YoastSEO()
->meta->for_author($user->userId)
->get_head()->html,
for_author()
will return false
if the user has no post since it is considered to not be indexable by Yoast.
Can we add a check so that get_head()
is not run if for_author()
returns false? 😊
pascalroget commented
Same issue here:
Query:
user(idType: SLUG, id: $slug) {
id
slug
name
avatar {
url
}
seo {
canonical
fullHead
metaDesc
}
}
}
Errors:
{
"debugMessage": "Call to a member function get_head() on bool",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 9,
"column": 5
}
],
"path": [
"user",
"seo"
],