serverless-appsync / serverless-appsync-simulator

A simple wrapper around Amplify AppSync Simulator to test serverless AppSync Apis
MIT License
127 stars 69 forks source link

plugin not working as expected after update depedencies #186

Closed tttaisgt closed 9 months ago

tttaisgt commented 1 year ago

Describe the bug I'm using serverless-appsync-simulator with serverless-offline and serverless-appsync-plugin to simulate appsync(graphql) in local env

but after updated serverless-offline from v7.0.0 to the latest version(because I upgrade nodejs version from 14.x->18.x and the old version of serverless-offline not support it), the simulator not working anymore, all the response is null and sometimes cause an error

To Reproduce

Expected behavior It can work normally

Screenshots image image

Additional context Sample Code

frameworkVersion: '3'
service: my-service

provider:
  runtime: nodejs18.x
  stage: dev

functions:
  main:
    handler: handler.main

appSync:
  name: Appsync
  authenticationType: API_KEY
  lambdaAuthorizerConfig:
      functionName: appsync-auth
  schema: ${file(./conf/schema.yml)}
  dataSources:
    - type: AWS_LAMBDA
          name: main
          description: 'Lambda DataSource'
          config:
            functionName: main
            iamRoleStatements:
              - Effect: "Allow"
                Action:
                  - "lambda:invokeFunction"
                Resource:
                  - "*"
  defaultMappingTemplates:
      request: false
      response: false
   mappingTemplates:
      - dataSource: main
        type: Query
        field: getData

appsync-simulator:
    watch: false
    port: 3000
    apiKey: da2-fakeApiId123456

plugins:
  - serverless-layers
  - serverless-appsync-plugin
  - serverless-appsync-simulator
  - serverless-offline
  - serverless-offline-direct-lambda
  - serverless-step-functions
'use strict'

const { stringify } = JSON

exports.main = async function main() {
          callback(null, await controller.getData(event.arguments.request, event.info.selectionSetList));
}

type Data { id:Int name:String type:String created_at:AWSDateTime deleted:Boolean updated_at:AWSDateTime }



**Environment**

- `serverless`: v3.31.0
- `serverless-offline`: v12.0.4
- `serverless-appsync-simulator`: v0.20.0
- `node.js` version: nodejs18.x
- `OS`: macOS monterey 12.6.5
plezan commented 9 months ago

Sorry for the late answer, it looks like the same issue as #178 : The v0.20 of this plugin is not compatible with serverless-appsync-plugin v2

We just released a new beta version that added support for node >= 18 and that should fix your issue