Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for required arguments with default values #3878

Closed
rev0lgenX opened this issue Feb 17, 2022 · 3 comments
Closed

Support for required arguments with default values #3878

rev0lgenX opened this issue Feb 17, 2022 · 3 comments

Comments

@rev0lgenX
Copy link

Question.
The Graphql Spec seems to have support for replacing required value with the default value. I think it was supported in version 2 as well, but currently if I try to generate by replacing query Media($includeAny:Boolean!) with query Media($includeAny:Boolean = true) it gives error Variable includeAny of type Boolean used in position expecting type Boolean!. Is this feature implemented or am I missing something? If it's missing is it possible to implement it?

@BoD
Copy link
Contributor

BoD commented Feb 17, 2022

Hi! Could it be that the field you're using the variable with expect a Boolean!? If yes, it should just be a matter of declaring your query like this: query Media($includeAny: Boolean! = true)

@rev0lgenX
Copy link
Author

rev0lgenX commented Feb 17, 2022

If I try to use it like that then the server gives Variable \"$includeAny\" of type \"Boolean!\" is required and will not use the default value. Perhaps you meant to use type \"Boolean\".. Its a third party server and I have no control over it, so I was wondering if it is standard(according to specs) to implement it like that in server side. I have like little to no idea about graphql-servers validation like it is according to specs or anything else. If its nothing like that then the issue could be closed or there could be support for query without ! sign for default values.

Message sent to sever is like
query Media($includeAny!:Boolean = true)

There wont be any issue without that exclamation.

@martinbonnin
Copy link
Contributor

This is a duplicate with #3227

The current workaround until we change the coercion rules is to set the default value in Kotlin

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants