Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws-appsync] Deploy fails when trying to change datasource #11522

Closed
thiagothies opened this issue Nov 17, 2020 · 4 comments · Fixed by #12973
Closed

[aws-appsync] Deploy fails when trying to change datasource #11522

thiagothies opened this issue Nov 17, 2020 · 4 comments · Fixed by #12973
Assignees
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@thiagothies
Copy link

When trying to remove a datasource and create a new one, the deploy fails with the message: Only one resolver is allowed per field.

Reproduction Steps

The first step is to deploy a stack with a simple data source:

const api = new appsync.GraphqlApi(this, 'Api', {
      name: 'demo',
      schema: appsync.Schema.fromAsset('src/schema.graphql'),
});
const lambdaFunction = new lambda.Function(this, 'lambdaId', {
      runtime: lambda.Runtime.NODEJS_12_X,
      code: lambda.Code.fromAsset('src'),
      handler: 'main.handler',
});
const lambdaDS = api.addLambdaDataSource('lambdaDS', lambdaFunction);
lambdaDS.createResolver({
      typeName: 'Query',
      fieldName: 'getDemos',
      requestMappingTemplate: appsync.MappingTemplate.lambdaRequest(),
      responseMappingTemplate: appsync.MappingTemplate.lambdaResult()
})

then when trying to change the datasource, deploying this:

const api = new appsync.GraphqlApi(this, 'Api', {
      name: 'demo',
      schema: appsync.Schema.fromAsset('src/schema.graphql'),
});
const otherDS = api.addNoneDataSource('otherDS')
otherDS.createResolver({
      typeName: 'Query',
      fieldName: 'getDemos',
      requestMappingTemplate: appsync.MappingTemplate.fromString('{}'),
      responseMappingTemplate: appsync.MappingTemplate.fromString(JSON.stringify([{id: '1', version: '1.0'}]))
})

it fails.

What did you expect to happen?

it should update the datasource and resolver, but apparently it's not deleting the old resolver (or not doing it in order), and the deploy is failing

I was trying to update the resolver, but it only works when I deploy twice, first time deleting the old one, and the second time creating the new one

What actually happened?

Deploy fails with message Only one resolver is allowed per field.

Only one resolver is allowed per field. (Service: AWSAppSync; Status Code: 400; Error Code: BadRequestException; Request ID: 3ab24c35-8cae-43c7-9abd-a506f6879f0c; Proxy: null)

Environment

  • CDK CLI Version: 1.74.0

  • Node.js Version:10.16.2

  • OS: macos 10.15.7

  • Language: javascript

Other


This is 🐛 Bug Report

@thiagothies thiagothies added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 17, 2020
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Nov 17, 2020
@MrArnoldPalmer MrArnoldPalmer added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Dec 7, 2020
@p0wl
Copy link

p0wl commented Dec 10, 2020

We ran into this issue as well. Detaching the resolver manually in the console partially helped, because the new ds and resolver were created, but not attached to the field.

@BryanPan342
Copy link
Contributor

hm.. from your comment

I was trying to update the resolver, but it only works when I deploy twice, first time deleting the old one, and the second time creating the new one

I would assume the problem lies in the fact that the CFN template isn't updating in the order we might want. I'm not an expert in the ordering of CFN updates but maybe someone who has more expertise in this domain can take this for a swing.

@p0wl
Copy link

p0wl commented Feb 8, 2021

Yeah, this is the case. Running into this again while trying to revert #12635... Any idea how we can move this forward?

@mergify mergify bot closed this as completed in #12973 Feb 22, 2021
mergify bot pushed a commit that referenced this issue Feb 22, 2021
)

* Revert to old behavior of allowing a data source to create a resolver as UNIT resolvers stem from data sources.
* Maintaining new behavior of having `GraphqlApi` create resolvers as PIPELINE resolvers stem from the `GraphqlApi` itself

Fixes #12635
Fixes #11522

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

eladb pushed a commit that referenced this issue Feb 22, 2021
)

* Revert to old behavior of allowing a data source to create a resolver as UNIT resolvers stem from data sources.
* Maintaining new behavior of having `GraphqlApi` create resolvers as PIPELINE resolvers stem from the `GraphqlApi` itself

Fixes #12635
Fixes #11522

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants