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: Custom stack not pushing

See original GitHub issue

Describe the bug Using version 0.2.2-multienv.1, I have created a custom stack that adds resolvers for a mutation. I have followed the guide and used the example: https://github.com/mikeparisstuff/amplify-cli-nested-api-sample. But the stack is not being pushed when I call amplify push

To Reproduce The custom stack (amplify/backend/myAPI/stacks/custom.json):

{
  "AWSTemplateFormatVersion":"2010-09-09",
  "Description":"An auto-generated nested stack.",
  "Metadata":{

  },
  "Parameters":{
    "AppSyncApiId":{
      "Type":"String",
      "Description":"The id of the AppSync API associated with this project."
    },
    "AppSyncApiName":{
      "Type":"String",
      "Description":"The name of the AppSync API",
      "Default":"AppSyncSimpleTransform"
    },
    "env":{
      "Type":"String",
      "Description":"The environment name. e.g. Dev, Test, or Production",
      "Default":"NONE"
    },
    "S3DeploymentBucket":{
      "Type":"String",
      "Description":"The S3 bucket containing all deployment assets for the project."
    },
    "S3DeploymentRootKey":{
      "Type":"String",
      "Description":"An S3 key relative to the S3DeploymentBucket that points to the root\nof the deployment directory."
    }
  },
  "Resources":{
    "MutationAddTicketResolver":{
      "Type":"AWS::AppSync::Resolver",
      "Properties":{
        "ApiId":{
          "Ref":"AppSyncApiId"
        },
        "DataSourceName":"Questionnaire",
        "TypeName":"Mutation",
        "FieldName":"addTicket",
        "RequestMappingTemplateS3Location":{
          "Fn::Sub":[
            "s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Mutation.addTicket.req.vtl",
            {
              "S3DeploymentBucket":{
                "Ref":"S3DeploymentBucket"
              },
              "S3DeploymentRootKey":{
                "Ref":"S3DeploymentRootKey"
              }
            }
          ]
        },
        "ResponseMappingTemplateS3Location":{
          "Fn::Sub":[
           "s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Mutation.addTicket.res.vtl",
            {
              "S3DeploymentBucket":{
                "Ref":"S3DeploymentBucket"
              },
              "S3DeploymentRootKey":{
                "Ref":"S3DeploymentRootKey"
              }
            }
          ]
        }
      }
    }
  },
  "Conditions":{
    "HasEnvironmentParameter":{
      "Fn::Not":[
        {
          "Fn::Equals":[
            {
              "Ref":"env"
            },
            "NONE"
          ]
        }
      ]
    },
    "AlwaysFalse":{
      "Fn::Equals":[
        "true",
        "false"
      ]
    }
  },
  "Outputs":{
    "EmptyOutput":{
      "Description":"An empty output. You may delete this if you have at least one resource above.",
      "Value":""
    }
  }
}

The request resolver (amplify/backend/myAPI/resolvers/Mutation.addTicket.req.vti):

{
  "version": "2017-02-28",
  "operation": "UpdateItem",
  "key": { "id": { "S": "$context.args.questionnaire" } },
  "update": {
    "expression" : "SET #tickets = list_append(if_not_exists(#tickets, :empty), :vals)",
    "expressionNames": {
      "#tickets" : "tickets"
    },
    "expressionValues": {
      ":vals" : {
        "L": [{
          "M": {
            "id": { "S": $util.autoId() },
            "user": { "S": $context.args.user },
            "expiresAt": { "S": $context.args.expiresAt }
          }
        }]
      },
      ":empty": { "L": [] }
    }
  }
}

The response resolver (amplify/backend/myAPI/resolvers/Mutation.addTicket.res.vti):

$util.toJson($context.result)

The schema:

type Ticket {
  id: ID!
  user: ID!
  expiresAt: String!
}

type Mutation {
  addTicket(expiresAt: String!, user: ID!, questionnaire: ID!): Ticket
}

Expected behavior Addition of a custom resolver for the addTicket mutation in AppSync

Desktop (please complete the following information):

  • OS: OSX
  • Version 10.14

Additional context This is an amplify installation that was migrated from non-multienv but has been rebuilt since (all resources re-added from scratch). The push is completing successfully, just without the stack.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kaustavghosh06commented, Mar 7, 2019

@RickCraig Custom resolvers are not supported as a part of @multienv CLI version but is now a part of the main CLI version. You can go ahead and install the v1 version of the CLI using npm install -g @aws-amplify/cli and let me know if you’re still seeing this issue.

0reactions
github-actions[bot]commented, May 27, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to override AppSync auto generated input types ...
When pushing above schema to AppSync via AWS Amplify, the following is created in the autogenerated graphql schema.
Read more >
AWS::AppSync::FunctionConfiguration - AWS CloudFormation
Describes a runtime used by an AWS AppSync pipeline resolver or AWS AppSync function. Specifies the name and version of the runtime to...
Read more >
API (GraphQL) - Overwrite & customize resolvers - Amplify Docs
After running amplify push open the AppSync console with amplify api console and test your API with this simple query: query { echo(msg:"Hello,...
Read more >
Lessons learned: AWS AppSync Subscriptions
AWS AppSync, simply said API Gateway for GraphQL since it allows you to connect your GraphQL schema to different data sources like RDS,...
Read more >
Making AppSync Easier with Thundra
I am not saying that building Lambda data sources for GraphQL operations is a ... order not to hijack the topic to tutorials...
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