serverless-appsync-plugin
serverless-appsync-plugin copied to clipboard
Updating resolver on a field
Here is the details of the problem:
- attach resolver on a field on AppSync console
- delete or update resolver for that field in
mappingTemplates
property of serverless.yml - no effects on AppSync when I deploy
Agree,
CloudFormation will not update the stack unless there is a change in properties of the resources already created in the stack.
I have tried to delete a resolver, then deploy again by using different properties of the resolver (in fact just added a time stamp to the response mapping template). ex: (index.js line 194)
ResponseMappingTemplate: fs.readFileSync(respTemplPath, 'utf8'),
=(becomes)=>
ResponseMappingTemplate: `${(new Date()).getTime().toString()}` + fs.readFileSync(respTemplPath, 'utf8'),
but an error raised [No resolver found.] !
The only working solution I found is to use a new logical Id for the graphqlAPI on every deployment. For example, we define a logical Id as
const graphQlApiLogicalId = `GraphQlApi${(new Date()).getTime().toString()}`;
and use it in line 93 of index.js
GraphQlApi: {
=(becomes)=>
[graphQlApiLogicalId]: {
and in all other places where GraphQlApi is mentioned.
The PROBLEM is that we will get a new graphql API id and API key on every deployment. This may not be a problem if you have a custom domain.
I am interested to find a solution also so I will keep looking for a better one. Any feedback is highly appreciated.
I had to detach existing resolver manually in the console and deploy again. It worked at the moment.