-
Notifications
You must be signed in to change notification settings - Fork 676
Closed
Description
Currently I am migrating AppSync sdk (although it embedded an internal Apollo sdk, it is way too outdated) to Apollo sdk v2.
However, I found that below query will be compile error:
query myQueryABCD(
$page: Int = 1,
$first: Int = 20
) {
myQueryABCD(first: $first, page: $page) {
...MyFragmentABCD
}
}
because in query definition, the field first
is optional with default value, but in schema query first
is required.
So i change the query to below:
query myQueryABCD(
$page: Int = 1,
$first: Int! = 20 // adding '!' as required
) {
myQueryABCD(first: $first, page: $page) {
...MyFragmentABCD
}
}
Then apollo client can generate query class successfully, and project got compile. Yeah!!
However, the problem is apollo client respond error because of Variable "$first" of type "Int!" is required and will not use the default value. Perhaps you meant to use type "Int".
I would suggest
- allowing required field to have default value, or
- do not return error. Just warn me in project