Skip to content

How to configure to use LambdaAuthorizer for custom VTL resolvers query? #14673

@nilyin

Description

@nilyin

Amplify CLI Version

14.2.5

Question

Hi, i can not manage Lambda Authorizer appsync auth for my custom query getComponentFiltered(id: ID!, organizationID: String): Component , which is using custom resolvers created with amplify add custom and then selecting CDK option. My custom VTL resolvers are created in backend and present locally in 'amplify\backend\custom\CustomResolvers\' folder along with 'cdk-stack.ts' and *.vtl files

real problem: when i invoke this query (either from client or from appsync web-console with a selection of Lambda Authorizer) i'm getting this error:

{
  "data": {
    "getComponentFiltered": null
  },
  "errors": [
    {
      "path": [
        "getComponentFiltered"
      ],
      "data": null,
      "errorType": "Unauthorized",
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "Not Authorized to access getComponentFiltered on type Query"
    }
  ]
}

my appsync has been set-up with Cognito UserPool as a default authorization method, with AWS_LAMBDA as a secondary method.

I tried adding @aws_lambda @aws_cognito_user_pools directives to my query in schema.graphql, but it leads to the fact that my custom resolvers are not detected anymore, as it seems appsync auto-generates own VTL templates based on these directives.

My question: is there a way to attach both AWS_LAMBDA and UserPool authentication capabilities to custom query with custom resolvers?

I am using Amplify JS Gen.1 v6 API (Transformer v2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions