aws-appsync-community
aws-appsync-community copied to clipboard
Pass default argument and input values to resolvers
AWS AppSync allows to define default values in schema like that
type Foo {
bar(
arg: Int = 20
): Bar!
}
or that
type Foo {
bar(
arg: Int! = 20
): Bar!
}
But either way when the value is not explicitly defined, the default value is not passed to the resolver.
The default argument and input values defined in the schema should be passed to the resolvers.
As a workaround I'm forced to define default values at the schema level and at the resolver level. This leads to redundancy and to possible out of sync default values.
PS: In the GraphQL specs
If no value is provided for a defined input object field and that field definition provides a default value, the default value should be used. If no default value is provided and the input object field’s type is non‐null, an error should be thrown. Otherwise, if the field is not required, then no entry is added to the coerced unordered map.
See Also https://stackoverflow.com/questions/51302462/how-to-pass-default-graphql-arguments-to-aws-appsync-resolver
Thank you for reporting the issue, this is a known issue and I will make sure the team sees this.
@tinnou Any update on this.
I also have a problem with defaultValue. When I make an introspection query, defaultValue of my fields are null
So I get this:
{
"description": "Input type of myMutation.",
"inputFields": [
{
"defaultValue": null,
"description": "foo description.",
"name": "foo"
}
]
}
Instead of this:
{
"description": "Input type of myMutation.",
"inputFields": [
{
"defaultValue": "bar",
"description": "foo description.",
"name": "foo"
}
]
}
@tinnou - ping. any word on when this bug might be addressed?
@tinnou - ping. any word on when this bug might be addressed?
This bug has not been prioritized yet. Stay tuned.
Any updates on this topic?
I would love to be able to use defaults, that is certain!!
@tinnou ping. any word on if this bug has been prioritized as yet?
Any update?
I believe users expect a public product by Amazon to be spec compliant.
bumping as this is still an issue several years later, is this on the backlog to fix?
Nearly 4 years later and AppSync still doesn't forward default arguments and inputs to resolvers, is there some unexpected complexity to implementing this or has it just not been prioritized?
We have run into this, and requesting that the fix be prioritized.
Is this problem present with JS resolvers as well? Because if it is then I would stay away from AppSync.
In my eyes presence of this single problem is enough to qualify entire product as immature. Not being able to fix it in 4 years tells me the product never be mature. I spent last 2 days evaluating AppSync for an uprooting project. Now I doubt I would use it :(