sid88in / serverless-appsync-plugin

serverless plugin for appsync
MIT License
951 stars 189 forks source link

Undefined Error using resolvers directive #615

Closed alire-alavi closed 1 year ago

alire-alavi commented 1 year ago

Using resolvers mapping return the following error on sls deploy command: TypeError: Cannot read properties of undefined (reading 'map')

omarjam97 commented 1 year ago

I faced the same problem, it's probably related with the migration from the V1 to V2 i suggest you to read the documentation for Example in my case this was the problem: `

Query.getBookById:
  dataSource: dynamoDBbookTable
  request: 'graphql/mapping-templates/Query.getBookById.request.vtl'
  response: 'graphql/mapping-templates/Query.getBookById.response.vtl'`

Correction: `

Query.getBookById:
  kind: UNIT #i had to specify the kind since the default value is PIPELINE
  dataSource: dynamoDBbookTable
  request: 'graphql/mapping-templates/Query.getBookById.request.vtl'
  response: 'graphql/mapping-templates/Query.getBookById.response.vtl'`
lavirez commented 1 year ago

I agree with @WomaWoma, you are probably encountering the error because of using unmatched versions of plugin and serverless framework, take a look at the docs in repo, you might be using the old docs:

I faced the same issue with js resolvers, here's what I did:

  ExampleResolver:
    type: Query
    field: searchTopics
    dataSource: APIHandler #dataSource name
    kind: UNIT
    code: "appsync/Resolver.js"