Updating GraphQL to major version 16 breaks simulator
Closed this issue · 1 comments
Describe the bug
Our project uses multiple schema files (to make editing the whole schema easier), and trying to update GraphQL from ^15.5.3
to ^16.2.0
makes serverless-appsync-simulator stop working, with the following error:
AppSync Simulator: TypeError: graphql.getDescription is not a function
A bit investigation found that serverless-appsync-simulator
is using merge-graphql-schemas
which is deprecated and should be replaced according to a guide: https://www.graphql-tools.com/docs/migration/migration-from-toolkit
I also tinkered a bit and generated an stacktrace pointing to the TypeError in question, if that's useful:
at pushComment (project_root/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:117:15)
at collectComment (project_root/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:93:5)
at project_root/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:663:17
at Array.reduce (<anonymous>)
at mergeGraphQLNodes (project_root/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:658:18)
at mergeGraphQLTypes (project_root/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:755:25)
at Object.mergeTypeDefs (project_root/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:710:22)
at mergeTypes (project_root/node_modules/merge-graphql-schemas/index.cjs.js:24:26)
at getAppSyncConfig (project_root/node_modules/serverless-appsync-simulator/lib/getAppSyncConfig.js:251:50)
at ServerlessAppSyncSimulator.initIndividualServer (project_root/node_modules/serverless-appsync-simulator/lib/index.js:140:50)
at ServerlessAppSyncSimulator.initServers (project_root/node_modules/serverless-appsync-simulator/lib/index.js:135:12)
at ServerlessAppSyncSimulator.startServers (project_root/node_modules/serverless-appsync-simulator/lib/index.js:108:14)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async PluginManager.runHooks (project_root/node_modules/serverless/lib/classes/PluginManager.js:573:35)
at async PluginManager.invoke (project_root/node_modules/serverless/lib/classes/PluginManager.js:610:9)
at async PluginManager.run (project_root/node_modules/serverless/lib/classes/PluginManager.js:672:7)
at async Serverless.run (project_root/node_modules/serverless/lib/Serverless.js:468:5)
at async project_root/node_modules/serverless/scripts/serverless.js:836:9
To Reproduce
Create a Serverless AppSync project (all dependencies updated) which uses multiple .graphql
files and a glob pattern so schema merging is required.
Expected behavior
I expected the simulator to work, because it works with multiple schemas w/ GraphQL ^15.5.3
.
Additional context
package.json versions of all relevant dependencies:
{
"graphql": "^16.2.0",
"serverless": "^2.66.2",
"serverless-appsync-plugin": "^1.12.1",
"serverless-appsync-simulator": "^0.19.2",
"serverless-offline": "^8.2.0",
}
serverless.yml appsync schema:
appSync:
name: ${self:custom.stack-prefix}-appsync
schema: "serverless/graphql/**/*.graphql"
I finally managed to test all repositories affected and they all seem to work!