What shall the graphql server return if a child object does not exist?
Example schema:
type Person {
name: String!
address: Address
}
type Address {
street: String
city: String
}
On the server, there is a Person, but no Address exist on that person.
The fact that the address is missing is not an error, it is just not yet set.
Then I have this query:
query Person(name: "Otto") {
name
address {
street
city
}
}
What is the correct response?
I can think of two alternatives:
Alt 1:
{
"data": {
"person": {
"name": "Otto",
"address": null
"__typename": "Person"
}
}
}
Alt 2:
{
"data": {
"person": {
"name": "Otto",
"address": {
"street": null,
"city": null
"__typename": "Address"
}
"__typename": "Person"
}
}
}