Open jimjiminyjimjim opened 8 months ago
UPDATE:
After looking more at this I have worked out how to do the following:
const amplifyApi = new AmplifyGraphqlApi(this, "AmplifyCdkGraphQlApi", {
//...rest of graphql definition
functionSlots: [queryFunctionSlot]
const existingResolverResource = amplifyApi.resources.cfnResources.cfnResolvers['Query.listRegistryItems'];
existingResolverResource.addPropertyOverride('ResponseMappingTemplate', `$util.toJson($ctx.result)`);
But I don't seem to be able to override or add an appSync resolver for the main data request or response function of a generated query by the api definition?
Using addResolver seems to work on listRegistryItems if I define a custom Query or Mutation in the schema and disable the generated one like this but ideally I'd like to do something to override the generated Query.listRegistryItems.req.vtl that I would do normally do with Amplify:
type RegistryItem
@model #(queries: { list: null })
) {
id: ID!
name: String
version: Int
}
type Query {
listRegistryItems(id: ID!): String
}
Any further information on this would be much appreciated.
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:
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"