aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.36k stars 3.77k forks source link

appsync: resolver should be in the datasource scope, not in the api scope #24620

Open fab-mindflow opened 1 year ago

fab-mindflow commented 1 year ago

Describe the bug

When creating nested stacks with AppSync resolvers, they are actually attached to the stack where the api is defined instead of the datasource.

https://github.com/aws/aws-cdk/blob/1105514fc88ae4637a5d187a48ff1a37a4932579/packages/%40aws-cdk/aws-appsync/lib/data-source.ts#L136

Expected Behavior

Resolvers should have their datasource as parent resource.

Current Behavior

Resolvers have the api as parent resource.

Reproduction Steps

Create nested stacks with datasource and resolvers attached to an api defined in the parent stack.

Possible Solution

Construct a Resolver directly, not the createResolver function.

Additional Information/Context

No response

CDK CLI Version

2.68.1

Framework Version

No response

Node.js Version

16

OS

macOS

Language

Typescript

Language Version

No response

Other information

No response

khushail commented 1 year ago

Hi @fab-mindflow , thanks for reporting this. It would be great if you could share the repro code for this as well.

github-actions[bot] commented 1 year ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

fab-mindflow commented 1 year ago

Sorry, tbh, I don't have time right now to create a small sample. And the workaround is ok for now.