aws-appsync-community icon indicating copy to clipboard operation
aws-appsync-community copied to clipboard

Pass default argument and input values to resolvers

Open yvele opened this issue 4 years ago • 14 comments

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

yvele avatar Oct 07 '19 17:10 yvele

Thank you for reporting the issue, this is a known issue and I will make sure the team sees this.

tinnou avatar Oct 18 '19 18:10 tinnou

@tinnou Any update on this.

yelhow avatar Nov 12 '19 09:11 yelhow

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"
	}
  ]
}

arsenipachkovski avatar Nov 25 '19 15:11 arsenipachkovski

@tinnou - ping. any word on when this bug might be addressed?

morficus avatar Feb 05 '20 04:02 morficus

@tinnou - ping. any word on when this bug might be addressed?

This bug has not been prioritized yet. Stay tuned.

tinnou avatar Feb 08 '20 19:02 tinnou

Any updates on this topic?

mmierzwa avatar Jun 26 '20 11:06 mmierzwa

I would love to be able to use defaults, that is certain!!

hutber avatar Oct 06 '20 21:10 hutber

@tinnou ping. any word on if this bug has been prioritized as yet?

morficus avatar Dec 05 '20 10:12 morficus

Any update?

MontoyaAndres avatar Jul 12 '21 20:07 MontoyaAndres

I believe users expect a public product by Amazon to be spec compliant.

vicary avatar Sep 07 '21 14:09 vicary

bumping as this is still an issue several years later, is this on the backlog to fix?

jaismith avatar Feb 01 '23 03:02 jaismith

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?

tqhoughton avatar Mar 05 '23 06:03 tqhoughton

We have run into this, and requesting that the fix be prioritized.

aaronkaka avatar Dec 06 '23 15:12 aaronkaka

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 :(

Kikimora avatar Jan 11 '24 03:01 Kikimora