Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppSync Simulator: TypeError: Cannot convert undefined or null to object #170

Open
jamsmd opened this issue Jun 28, 2022 · 10 comments
Open

Comments

@jamsmd
Copy link

jamsmd commented Jun 28, 2022

Describe the bug
When following these steps: https://www.npmjs.com/package/serverless-appsync-simulator
I try to run sls offline start and it gives me the following error: AppSync Simulator: TypeError: Cannot convert undefined or null to object

To Reproduce
I created a new serverless project with the aws-http-api template.
Follow these steps: https://www.npmjs.com/package/serverless-appsync-simulator

So I ran

yarn install -D serverless-appsync-simulator serverless-offline serverless-dynamodb-local serverless-appsync-plugin

added a schema.graphql in the root

Added the plugins in following order:

plugins:
  - serverless-dynamodb-local # only if you need dynamodb resolvers and you don't have an external dynamodb
  - serverless-appsync-plugin
  - serverless-appsync-simulator
  - serverless-offline

Expected behavior
I expect it to spit out the urls like this:
image

Versions:

    "serverless-appsync-plugin": "^1.13.0",
    "serverless-appsync-simulator": "^0.20.0",
    "serverless-dynamodb-local": "^0.2.40",
    "serverless-offline": "^8.8.0"


@jamsmd
Copy link
Author

jamsmd commented Jun 28, 2022

Also found this question: https://stackoverflow.com/questions/72695038/appsync-simulator-typeerror-cannot-convert-undefined-or-null-to-object

The solution did not resolve it for me

@snadeau
Copy link

snadeau commented Jun 29, 2022

I ran into the same issue. The solution proposed at https://stackoverflow.com/questions/72695038/appsync-simulator-typeerror-cannot-convert-undefined-or-null-to-object (downgrading cfn-resolver-lib from 1.1.8 to 1.1.7) did resolve the issue in my case.

@jamsmd
Copy link
Author

jamsmd commented Jun 29, 2022

Thank you for responding

I finally fixed it..

Had to switch to npm and remove serverless-plugin-typescript >.<

@ericmaicon
Copy link

I don't have serverless-plugin-typescript installed here. How did you guys solve this?

@allycallow
Copy link

Just started a new project and get this error also. Any updates?

@snadeau
Copy link

snadeau commented Jul 9, 2022

I'm using yarn, so I added the following to my package.json to force the use of the previous version of cfn-resolver-lib:

"resolutions": {
    "serverless-appsync-simulator/cfn-resolver-lib": "1.1.7"
}

Not sure what the equivalent would be with npm.

@katesclau
Copy link
Contributor

katesclau commented Jul 25, 2022

Another option is to update serverless-appsync-simulator/lib/index.js

  resolveResources(toBeResolved) {
    // Pass all resources to allow Fn::GetAtt and Conditions resolution
    const node = { ...this.serverless.service.resources,
      toBeResolved,
      Parameters: {}, // Passing {} would avoid the issue on latest cnf-resolver-lib version
    };
    const evaluator = new _cfnResolverLib.default(node, this.resourceResolvers);
    const result = evaluator.evaluateNodes();

    if (result && result.toBeResolved) {
      return result.toBeResolved;
    }

    return toBeResolved;
  }

@bboure
Copy link
Member

bboure commented Oct 13, 2022

Thank you @katesclau

Could you open a PR to fix this? That would be great.

Thanks

@sergueidmitriev
Copy link

in npm I just installed cfn-resolver-lib "1.1.7" explicitly and it helped

@QAnders
Copy link

QAnders commented Jul 17, 2024

I can also confirm adding:

npm i [email protected] --save-dev

solves the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants