I have a graphql query which gets a Meeting
object with Client
object:
type Meeting {
address: String!
client: Client
}
type Client {
displayName: String!
}
The displayName
is required, but client
isn't.
If I'm querying it as
{
getMeeting(meetingId: "43bbea6ea0c6112b0abcf11d") {
address
client {
displayName
}
}
}
And this meeting doesn't have a client, then I'm getting an error:
Error: Cannot return null for non-nullable field Client.displayName.
I just want that if there is a client, I will get its full details. And if there isn't, I will get client: null
.
If I will remove the required from the displayName
, it will work also when client is null and I will get
"client": {
"displayName": null
}
as I've expected. But I'm still looking for a way to enforce the required on the displayName
- only if there is a client.
Is there any way to do that in graphql?