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

Upgrading to 0.7.1 throws Error: GUID must provide "serialize" function #53

Closed
brno32 opened this issue Oct 29, 2020 · 19 comments
Closed

Comments

@brno32
Copy link

brno32 commented Oct 29, 2020

Describe the bug
Upgrading to serverless-appsync-simulator version 0.7.1 has caused the following error to be thrown when running the local server:

Error: GUID must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.

To Reproduce
Upgrade to 0.7.1. Use these dependencies as well

"serverless": "^1.60.0",
"serverless-appsync-plugin": "^1.1.2",
"serverless-appsync-simulator": "^0.7.1",
"serverless-offline": "^5.12.1",

And create a graphql schema making use of only ID, String, Int, Float types and types based off of enums.
We're also using various aws decorators like @aws_subscribe

Expected behavior
The api should start successfully and not die on the error listed above

Screenshots
Screenshot 2020-10-29 at 09 46 55

Additional context
I apologize for not providing more info, but I'm not sure where exactly this error is coming from. I'm moreso sharing because I cannot find any information elsewhere, and am wondering if anyone else has the same issue

@FilipPyrek
Copy link
Contributor

I also got the same error when upgrading from 0.7.0 to 0.7.1.

@bboure
Copy link
Member

bboure commented Oct 31, 2020

@brno32 Thanks for opening this issue.
As I understand, you are not using any custom scalar like GUID in your project?

Error seems to come from node?modules/src/scalars.GUID.ts which I don't know what this is.

It looks like it is from this module https://www.npmjs.com/package/src but looking at the source, I doubt it.

@bboure
Copy link
Member

bboure commented Oct 31, 2020

Thanks @FilipPyrek for confirming this.
I am not getting this error on my side.
Any idea on on to reproduce?

@FilipPyrek
Copy link
Contributor

FilipPyrek commented Oct 31, 2020

@bboure
I can see in my package-lock.json:

"serverless-appsync-simulator": {
    "version": "0.7.1",
    "resolved": "https://registry.npmjs.org/serverless-appsync-simulator/-/serverless-appsync-simulator-0.7.1.tgz",
    "integrity": "sha512-onos8JKuuoy9Dcux+VEWPHvm9su6dninGH18UOEqY/3jUmAOSFPpsYgPhZ4zLsdhZXuxbgFVNvxZjtm6ckMk/A==",
    "dev": true,
    "requires": {
        "amplify-appsync-simulator": "^1.23.3",
        "amplify-nodejs-function-runtime-provider": "^1.1.5",
        "aws-sdk": "^2.720.0",
        "axios": "^0.19.2",
        "cfn-resolver-lib": "^1.1.6",
        "dataloader": "^2.0.0",
        "lodash": "^4.17.19",
        "merge-graphql-schemas": "^1.5.8"
    },

And I saw there: "amplify-appsync-simulator": "^1.23.3",

Then I also found in the same package-lock.json this:

"amplify-appsync-simulator": {
    "version": "1.23.9",
    "resolved": "https://registry.npmjs.org/amplify-appsync-simulator/-/amplify-appsync-simulator-1.23.9.tgz",
    "integrity": "sha512-iC9bzW3KMb33VlNJ6QN9oSwDzMUnKlvlNHfT9PXP15lY7jl1hXoKqbh0SrJw1UJl2kILWinQZQgVBrAII85Cow==",
    "dev": true,

We can see there "version": "1.23.9",,
When I took a look at node_modules/amplify-appsync-simulator/package.json I could really see there version 1.23.9.

When I tried removing this 👆 record in package-lock.json and removed node_modules and reinstalled dependencies, it got back with version 1.23.9.

And according to amplify-appsync-simulator/CHANGELOG.md I can see that in version 1.23.9 was a change in appsync scalars.

And I can see in the stack trace:
Error: GUID must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.
      at invariant (...X.X.X.X.X...node_modules/graphql/jsutils/invariant.js:19:11)
      at new GraphQLScalarType (...X.X.X.X.X...node_modules/graphql/type/definition.js:407:73)
      at Object.<anonymous> (...X.X.X.X.X...node_modules/src/scalars/GUID.ts:8:42)
      at Module._compile (internal/modules/cjs/loader.js:1158:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
      at Module.load (internal/modules/cjs/loader.js:1002:32)
      at Function.Module._load (internal/modules/cjs/loader.js:901:14)
      at Module.require (internal/modules/cjs/loader.js:1044:19)
      at require (internal/modules/cjs/helpers.js:77:18)
      at Object.<anonymous> (...X.X.X.X.X...node_modules/amplify-appsync-simulator/src/schema/appsync-scalars/index.ts:6:1)
      at Module._compile (internal/modules/cjs/loader.js:1158:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
      at Module.load (internal/modules/cjs/loader.js:1002:32)
      at Function.Module._load (internal/modules/cjs/loader.js:901:14)
      at Module.require (internal/modules/cjs/loader.js:1044:19)
      at require (internal/modules/cjs/helpers.js:77:18)
      at Object.<anonymous> (...X.X.X.X.X...node_modules/amplify-appsync-simulator/src/schema/index.ts:5:1)
      at Module._compile (internal/modules/cjs/loader.js:1158:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
      at Module.load (internal/modules/cjs/loader.js:1002:32)
      at Function.Module._load (internal/modules/cjs/loader.js:901:14)
      at Module.require (internal/modules/cjs/loader.js:1044:19)
      at require (internal/modules/cjs/helpers.js:77:18)
      at Object.<anonymous> (...X.X.X.X.X...node_modules/amplify-appsync-simulator/src/index.ts:3:1)
      at Module._compile (internal/modules/cjs/loader.js:1158:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
      at Module.load (internal/modules/cjs/loader.js:1002:32)
      at Function.Module._load (internal/modules/cjs/loader.js:901:14)
      at Module.require (internal/modules/cjs/loader.js:1044:19)
      at require (internal/modules/cjs/helpers.js:77:18)
      at Object.<anonymous> (...X.X.X.X.X...node_modules/serverless-appsync-simulator/lib/index.js:3:32)
      at Module._compile (internal/modules/cjs/loader.js:1158:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
      at Module.load (internal/modules/cjs/loader.js:1002:32)
      at Function.Module._load (internal/modules/cjs/loader.js:901:14)
      at Module.require (internal/modules/cjs/loader.js:1044:19)
      at require (internal/modules/cjs/helpers.js:77:18)
      at requireServicePlugin (...X.X.X.X.X...node_modules/serverless/lib/classes/PluginManager.js:26:10)
      at ...X.X.X.X.X...node_modules/serverless/lib/classes/PluginManager.js:126:20
      at Array.map (<anonymous>)
      at PluginManager.resolveServicePlugins (...X.X.X.X.X...node_modules/serverless/lib/classes/PluginManager.js:123:8)
      at PluginManager.loadAllPlugins (...X.X.X.X.X...node_modules/serverless/lib/classes/PluginManager.js:110:15)
      at ...X.X.X.X.X...node_modules/serverless/lib/Serverless.js:96:35
      at tryCatcher (...X.X.X.X.X...node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:729:18)
      at Promise._fulfill (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:673:18)
      at Promise._resolveCallback (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:466:57)
      at Promise._settlePromiseFromHandler (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:559:17)
      at Promise._settlePromise (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:729:18)
      at Promise._fulfill (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:673:18)
      at PromiseArray._resolve (...X.X.X.X.X...node_modules/bluebird/js/release/promise_array.js:127:19)
      at PromiseArray._promiseFulfilled (...X.X.X.X.X...node_modules/bluebird/js/release/promise_array.js:145:14)
      at Promise._settlePromise (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:609:26)
      at Promise._settlePromise0 (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:729:18)
      at Promise._fulfill (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:673:18)
      at Promise._resolveCallback (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:466:57)
      at Promise._settlePromiseFromHandler (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:559:17)
      at Promise._settlePromise (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:729:18)
      at Promise._fulfill (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:673:18)
      at PropertiesPromiseArray.PromiseArray._resolve (...X.X.X.X.X...node_modules/bluebird/js/release/promise_array.js:127:19)
      at PropertiesPromiseArray._promiseFulfilled (...X.X.X.X.X...node_modules/bluebird/js/release/props.js:78:14)
      at Promise._settlePromise (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:609:26)
      at Promise._settlePromise0 (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (...X.X.X.X.X...node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (...X.X.X.X.X...node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (...X.X.X.X.X...node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (...X.X.X.X.X...node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (...X.X.X.X.X...node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:456:21)

that the error comes also through amplify-appsync-simulator/src/schema/appsync-scalars/index.ts which is the exact file which was updated in the new version 1.23.9.

So according to my findings it seems that aws-amplify/amplify-cli#5705 caused this issue. 🤔 🤷‍♂️

@bboure
Copy link
Member

bboure commented Oct 31, 2020

Thanks for these detailed info @FilipPyrek
I had the version of amplify-appsync-simulator locked to 1.23.7.
I forced-upgraded it. Now using 1.23.9

However, I am still not reproducing the error.

What troubles me is that I cannot find the following file in my node_modules:
node_modules/src/scalars/GUID.ts

are you?

@bboure
Copy link
Member

bboure commented Oct 31, 2020

What do you see when you run the following command?

npm ls graphql-scalars
or
yarn why graphql-scalars

@FilipPyrek
Copy link
Contributor

IMO the issue with node_modules/src/scalars/GUID.ts could be incorrect source maps.
Because I can see the same path /src/scalars/GUID.ts in graphql-scalars

Output of npm ls graphql-scalars:

api@ /Users/filippyrek/projects/buttonize/buttonize/api
└─┬ serverless-appsync-simulator@0.7.1
  └─┬ amplify-appsync-simulator@1.23.9
    └── graphql-scalars@1.4.1 

Also I can see that 25 days ago was added GUID to graphql-scalars. And I can see that the serialize function is really missing there https://github.com/Urigo/graphql-scalars/blob/master/src/scalars/GUID.ts .

@FilipPyrek
Copy link
Contributor

When upgrading to 0.7.1 I can also see this change in package-lock.json

"graphql-scalars": {
-	"version": "1.2.6",
+	"version": "1.4.1",
-	"resolved": "https://registry.npmjs.org/graphql-scalars/-/graphql-scalars-1.2.6.tgz",
+	"resolved": "https://registry.npmjs.org/graphql-scalars/-/graphql-scalars-1.4.1.tgz",
-	"integrity": "sha512-k/88kZVXIuUKQuVLokokkKU2lnFEZ9aTn7O0fDweJpISd0pP5fQU1wzPN0jarH4Lnadr4092PfyIUtCcKzkeAw==",
+	"integrity": "sha512-QCT9sHYkEns9jp3fYqzmoUtS7GiWn+IKrWvSKYDrGOEqlUVP66DDtR0HQmebIbnaSuww239drYnq6JNP0VIDTg==",
	"dev": true
},

@bboure
Copy link
Member

bboure commented Oct 31, 2020

IMO the issue with node_modules/src/scalars/GUID.ts could be incorrect source maps.

yes, this is also what I figured out.

I am also on the same versions now

└─┬ serverless-appsync-simulator@0.7.1
  └─┬ amplify-appsync-simulator@1.23.9
    └── graphql-scalars@1.4.1 

Still no error on my side.
I suspect it might be schema-related.
Are you using any particular scalar in your schema?

@FilipPyrek
Copy link
Contributor

My schema is quite simple

schema {
	query: Query
	mutation: Mutation
}
type Query {
	triggers(organisation: ID!, namespace: ID!): [Trigger!]!
	namespaces(organisation: ID!): [String!]!
}
type Mutation {
	runTrigger(id: ID!): TriggerRunResponse!
}

type Trigger {
	id: ID!
	arn: String!
	label: String!
}

type TriggerRunResponse {
	message: String
	error: String
}

I tried replacing ID with String, but that didn't help.

@bboure
Copy link
Member

bboure commented Oct 31, 2020

Thanks.

Still no luck on my side after creating a fresh new project.
I suspect there is some kind of incompatibility in you package-lock.json

could you try to

  • rm -rf node_modules
  • rm package-lock.json (keep a copy of it just in case)

then npm install again and see if the problem persists.

@FilipPyrek
Copy link
Contributor

My findings:

I cloned graphql-scalars and I added console.log(GraphQLGUIDConfig) to GUID.ts file to see what is value of GraphQLGUIDConfig and I ran tests.
I got this:

{
    name: 'GUID',
    description: 'A field whose value is a generic Universally Unique Identifier: https://en.wikipedia.org/wiki/Universally_unique_identifier.',
    serialize: [Function: serialize],
    parseValue: [Function: parseValue],
    parseLiteral: [Function: parseLiteral]
}

when I did it in node_modules of the project and then I started serverless-appsync-simulator, I got this:

{
  name: 'GUID',
  description: 'A field whose value is a generic Universally Unique Identifier: https://en.wikipedia.org/wiki/Universally_unique_identifier.',
  astNode: undefined,
  _scalarConfig: {
    name: 'UUID',
    description: 'A field whose value is a generic Universally Unique Identifier: https://en.wikipedia.org/wiki/Universally_unique_identifier.',
    serialize: [Function: serialize],
    parseValue: [Function: parseValue],
    parseLiteral: [Function: parseLiteral]
  }
}

Which is quite strange.

I'm going to proceed to package-lock suggestion of yours @bboure

@FilipPyrek
Copy link
Contributor

FilipPyrek commented Oct 31, 2020

I found it!
It caused by graphql versions mismatch.
I've had installed one dependency which used graphql version 0.13.2 and I can see that _scalarConfig is present in that old version: https://github.com/graphql/graphql-js/blob/5f50543f7608d52403b1440d1a617626f412a63f/src/type/definition.js#L454

So graphql-scalars was using that old version becuase in they have graphql^0.13.0 in their peerDependencies: https://github.com/Urigo/graphql-scalars/blob/master/package.json#L71

I will create an issue in graphql-scalars.

Thanks for help ❤️ and sorry for bothering you @bboure 🙈

@bboure
Copy link
Member

bboure commented Oct 31, 2020

Great job!

graphql version mismatch was also in my suspicions.

What is your dependency that is using an old version of graphql ?
It might be worth suggesting them to upgrade too

@FilipPyrek
Copy link
Contributor

It was this old deprecated package @conduitvc/appsync-emulator-serverless. So in this case there is nobody to notify.
But anyway installation of that package served as a hotfix of some other issue.. but the issue was already fixed so I just removed it and it works okay.

@FilipPyrek
Copy link
Contributor

Here is the issue in graphql-scalars: Urigo/graphql-scalars#578

@bboure
Copy link
Member

bboure commented Nov 2, 2020

Thanks for feedback @FilipPyrek

@brno32 Does that help into fixing your issue?

@brno32
Copy link
Author

brno32 commented Nov 2, 2020

I removed aws-appsync from my dependencies, which in turn removed graphql^0.13.0. I upgraded to 0.7.1 of this package and can confirm the issue is gone. Thanks!

@bboure
Copy link
Member

bboure commented Nov 2, 2020

Great thanks @brno32

Closing this issue

@bboure bboure closed this as completed Nov 2, 2020
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

3 participants