Problem/Motivation
When I run the following query:
query getEpisode {
entityQuery(
entityType: NODE
limit: 1000
) {
items {
... on NodeEpisode {
id
title
fieldHeroImage {
entity {
urlAbsolute
}
}
}
}
}
}
The fieldHeroImage will cause the query to error out if any of the nodes do not have fieldHeroImage populated.
{
"errors": [
{
"message": "Unexpected token '<', \"<html>\r\n<h\"... is not valid JSON",
"stack": "SyntaxError: Unexpected token '<', \"<html>\r\n<h\"... is not valid JSON"
}
]
}
The fieldHeroImage is a regular image field.
If I remove the entity or any other nested object within fieldHeroImage and just use:
fieldHeroImage {
alt
}
The fieldHeroImage will return null for nodes missing the image.
{
"data": {
"entityQuery": {
"items": [
{
"id": "3996",
"fieldHeroImage": null
},
{
"id": "852775",
"fieldHeroImage": {
"alt": "test image"
}
}
]
}
}
}
Steps to Reproduce
Query for an image on a node and do not populate the image.
Proposed Resolution
Can we just return null instead of erroring out?