question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(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:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bigkraigcommented, Feb 26, 2021

Parallel instances won’t work if you use API keys, as you cannot specify the key value when creating them.

0reactions
simiyu1commented, Sep 20, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found