GraphQL query: only include field if not null -


does graphql have possibility client tell server wants field if field not null?

given query

query heroandfriends {   hero {     name     friends {       name     }   } } 

the response should like

{   "data": {     "hero": {       "friends": [         {           "name": "luke skywalker"         },         {           "name": "han solo"         },         {           "name": "leia organa"         }       ]     }   } } 

instead of

{   "data": {     "hero": {       "name": null,       "friends": [         {           "name": "luke skywalker"         },         {           "name": "han solo"         },         {           "name": "leia organa"         }       ]     }   } } 

is possible without violating graphql specification?

as far know not possible, there directives @skip , @include. directives need variable, think can make case graphql team extend directives include field if it's not null.


Comments