Skip to content

graphql-api-construct addResolver for Query failing #2346

Open
@jimjiminyjimjim

Description

Amplify CLI Version

12.2.5

Question

I can successfully add Appsync JS resolvers for any field in my api schema. However, if I try and add my own resolver for a Query such as getRegistryItem or listRegistryItems I receive the following error on deploy:

Resource handler returned message: "Resource already exists: arn:aws:appsync:eu-west-2::apis/*********/types/Query/resolvers/getRegistryItem"

Here is my resolver code:

    const registryItemTable = Table.fromTableName(
      this,
      "RegistryItemTable",
      amplifyApi.resources.cfnResources.cfnTables["RegistryItem"].ref
    );

    const registryItemDS = amplifyApi.addDynamoDbDataSource(
      "RegistryItemDataSource",
      registryItemTable
    );

    amplifyApi.addResolver("ListRegistryItems", {
      dataSource: registryItemDS,
      typeName: "Query",
      fieldName: "listRegistryItems",
      code: AppsyncCode.fromAsset(
        path.join(__dirname, "resolvers/registryItem/query", "listRegistryItems.js")
      ),
      runtime: FunctionRuntime.JS_1_0_0,
    });
    

Am I doing something wrong? I've tried disabling the creation of the query in the schema but then I get the following error:

"No field named listRegistryItems found on type Query"

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions