aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
506 stars 32 forks source link

Pass default argument and input values to resolvers #59

Open yvele opened 5 years ago

yvele commented 5 years ago

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

tinnou commented 5 years ago

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

yelhow commented 4 years ago

@tinnou Any update on this.

arsenipachkovski commented 4 years ago

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"
    }
  ]
}
morficus commented 4 years ago

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

tinnou commented 4 years ago

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

This bug has not been prioritized yet. Stay tuned.

mmierzwa commented 4 years ago

Any updates on this topic?

hutber commented 4 years ago

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

morficus commented 3 years ago

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

MontoyaAndres commented 3 years ago

Any update?

vicary commented 3 years ago

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

jaismith commented 1 year ago

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

tqhoughton commented 1 year ago

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?

aaronkaka commented 10 months ago

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

Kikimora commented 9 months ago

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