Omit optional parameter in the variables field of a request when the parameter value is null #1867
Replies: 1 comment
-
When I posed the following question to ChatGPT-4,
the bot responded:
|
Beta Was this translation helpful? Give feedback.
-
There is a compatibility issue when using a ChilliCream StrawberryShake generated client to fetch data from an Azure Data API Builder CLI-generated GraphQL endpoint.
If a query is defined with an optional
$filter
parameter such as:When a
null
value is passed tofilter
parameter via a ChilliCream StrawberryShake-generated client query's.ExecuteAsync(filter: null)
method, the request does not include the"filter": null
node in thevariables
section:Unfortunately, the Azure Data API Builder CLI's GraphQL endpoint responds to this request with:
unless the
null
-valuedfilter
variable is specifically included in the request payload. I.e., this works:I haven't discovered a workaround for this issue either on the client side with StrawberryShake or on the server side with Azure Data API Builder. Is there a particular reason why it is necessary to include the unused null
filter
variable? If so, this seems unintuitive since the query parameter is declared as nullable$filter: TodoFilterInput
. I.e., it's not suffixed with the required operator (!
).Beta Was this translation helpful? Give feedback.
All reactions