is there any way I can check if .arguments.connectionArgs is set, else fallback to empty string or default value instead of null? e.g. {{.arguments.connectionArgs.limit || 0}}
Also if the client didnt put connectionArgs as input, UDG cannot resolves the start & limit, but we cannot control how client construct their query, which it should be valid in common Graphql world
query MyQuery($start: Int, $limit: Int) {
notifications(connectionArgs: { start: $start, limit: $limit }) {
meta {
count
}
result {
id
}
}
}
Let me ask internally if this is possible. In the meantime, you could validate or insert a default value with the help of custom plugins. The Pre (Request) middleware section would be a good place for this. You do have to take note that since this is Graphql, the variables are within the body of the request and not the query params.
@Allen_Wong How did you get along using custom plugins?
I have got feedback internally
The problem with this approach is, that the input types are defined as nullable which means that if they are omitted they will be treated in the library as null .
So the easiest thing is to have 2 distinct root fields:
with allNotifications having the data source defined without query parameters. This is covered in the spec for input coercion. The spec distinguishes between explicit null and omitted, so that they could be treated differently but the library handles both as null
No, but we do like the idea of default values. I could open a feature request for this, however, decision to implement the said feature still rests with the engineering team.