Search code examples
aws-lambdaaws-amplify

I am getting "Syntax Error: Unexpected Name" error for query with custom lambda function


I want to create a query that will trigger the lambda function. I have created schema.graphql file as below, but I am getting "Syntax Error: Unexpected Name". It is unclear why the name of the query is the unexpected name.

type GetDashboardHeaderCountOutput {
  instituteCnt: Int, 
  memberCnt: Int,
  tournamentCnt: Int
}

type Query {
  getDashboardHeaderCount: GetDashboardHeaderCountOutput #Line 84
  @function(name: "getDashboardHeaderCount-${env}")
  @auth(
    rules: [
      {
        allow: groups
        groups: ["AdminGroup"]
      }
    ]
  )
}

Please help me why I am getting the following error?

{
    "name": "GraphQLError",
    "classification": "ERROR",
    "options": {
        "message": "Syntax Error: Unexpected Name \"getDashboardHeaderCount\"."
    },
    "downstreamException": {
        "message": "Syntax Error: Unexpected Name \"getDashboardHeaderCount\".",
        "locations": [
            {
                "line": 84,
                "column": 3
            }
        ]
    },
    "link": "https://docs.amplify.aws/cli/project/troubleshooting/"
}

Solution

  • For anyone who has a similar problem, this was my solution.

    1. Backup what ever you have
    2. Delete the amplify API
    3. Recreate the app from the beginning

    It seems that amplify was broken due to some reason, and re creating it resolve the problem.