(appsync): Fails with error "Only one resolver is allowed per field." in using 1.91.0
See original GitHub issue❓ General Issue
The Question
After upgrading to 1.91.0 from 1.90.1 my AppSync API is failing with the error:
Only one resolver is allowed per field. (Service: AWSAppSync; Status Code: 400; Error Code: BadRequestException; Request ID: ea61d8d6-1d06-4009-8054-8a2493ceb42b; Proxy: null)
My API has a mix of templated resolvers and a Lambda, none are duplicated as far as I can tell. Here is the relevant code:
const api = new appsync.GraphqlApi(this, "API", {
name: "dataset-requests",
schema: appsync.Schema.fromAsset("graphql/schema.graphql"),
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.API_KEY,
apiKeyConfig: {
expires: cdk.Expiration.after(cdk.Duration.days(365)),
},
},
},
xrayEnabled: true,
});
const dataSource = api.addDynamoDbDataSource("dataSource", table);
dataSource.createResolver({
typeName: "Query",
fieldName: "getDatasetRequests",
requestMappingTemplate: appsync.MappingTemplate.dynamoDbScanTable(),
responseMappingTemplate: appsync.MappingTemplate.dynamoDbResultList(),
});
dataSource.createResolver({
typeName: "Mutation",
fieldName: "createDatasetRequest",
requestMappingTemplate: appsync.MappingTemplate.fromFile(
"lib/appsync/templates/Mutation.createDatasetRequest.req.vtl",
),
responseMappingTemplate: appsync.MappingTemplate.dynamoDbResultItem(),
});
dataSource.createResolver({
typeName: "Query",
fieldName: "getDatasetRequestById",
requestMappingTemplate: appsync.MappingTemplate.dynamoDbGetItem("id", "id"),
responseMappingTemplate: appsync.MappingTemplate.dynamoDbResultItem(),
});
const graphqlLamda = new lambdaNodeJS.NodejsFunction(this, "GraphQLLambda", {
entry: "../lambda-graphql/src/graphql/index.ts",
handler: "handler",
runtime: lambda.Runtime.NODEJS_14_X,
environment: {
TABLE_NAME: table.tableName,
},
});
table.grantFullAccess(graphqlLamda);
// Set the new Lambda function as a data source for the AppSync API
const lambdaDs = api.addLambdaDataSource("lambdaDatasource", graphqlLamda);
lambdaDs.createResolver({
typeName: "Mutation",
fieldName: "approveDatasetRequest",
});
lambdaDs.createResolver({
typeName: "Mutation",
fieldName: "rejectDatasetRequest",
});
–
Environment
- CDK CLI Version: 1.91.0
- Module Version: @aws-cdk/aws-appsync 1.91.0
- Node.js Version: v14.15.1
- OS: macOS Big Sur
- Language (Version): TypeScript 4.2
Other information
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Changing logical ID of AppSync resolver result in error upon ...
Only one resolver is allowed per field. (Service: AWSAppSync; Status Code: 400; Error Code: BadRequestException; Request ID: ...
Read more >Troubleshooting and Common Mistakes - AWS AppSync
Missing Resolver If you execute a GraphQL operation, such as a query, and get a null response, this may be because you don't...
Read more >aws-cdk.aws-appsync - PyPI
AppSync provides a data source for executing SQL commands against Amazon Aurora Serverless clusters. You can use AppSync resolvers to execute SQL statements ......
Read more >@aws-cdk/aws-lambda-event-sources - Package Manager
You can use event source mappings to process items from a stream or queue in services that don't invoke Lambda functions directly. Lambda...
Read more >node packages | Corvid by Wix
This package name was not found in the npm registry. 11/14/2022. @badgateway/oauth2-client. 2.0.17. available. 11/14/2022. @botisimo/loyalty-api. 0.0.1.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Parallel instances won’t work if you use API keys, as you cannot specify the key value when creating them.
I had this issue for the last 2 days… My structure is several microservices expose their schemas to AppSync which then compiles them to gether with their resolvers into one. My bug was caused by one microservice that was trying to create the resolver’s datasource. The fix was to ensure that no microservices is trying to create the datasources. Create is only done by Appsync API…
Might be worth looking into if you are also facing this.