aws / aws/aws-appsync-community

Pass default argument and input values to resolvers

Open
#59 14 comments 40 reactions 0 assignees View on GitHub
bug
Dominant language
HTML
Stars
507
Forks
37
PR merge metrics
No merged PRs in 30d

Description

AWS AppSync allows to define [default values](https://graphql.github.io/graphql-spec/June2018/#sec-Input-Objects) in schema like that

```graphql
type Foo {
bar(
arg: Int = 20
): Bar!
}
```

or that

```graphql
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](https://graphql.github.io/graphql-spec/June2018/#sec-Input-Objects)

> 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

Contributor guide

Open the contributing guide

Research direction

The issue names AWS AppSync resolvers and GraphQL schema defaults, but no repository file, test, or implementation entry point. Start by determining whether resolver argument coercion is implemented in this repository or controlled by AppSync; done means omitted arguments and input fields reach resolvers with their schema-defined defaults, covering both nullable and non-null examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql
Domain
api, backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.