Amplify codegen iOS: Unable to import custom transformer module(graphql-assert-transformer)
Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
14.17.1
Amplify CLI Version
5.1.0
What operating system are you using?
Mac
Amplify Codegen Command
codegen models
Describe the bug
Unable to import custom transformer module(graphql-assert-transformer). You may fix this error by editing transformers at /XXX/XXX/XXX/XXX/amplify/backend/api/XXX/transform.conf.json Error: Cannot find module '/Users/XXX/XXX/XXX/~/.npm-global/lib/node_modules/graphql-assert-transformer' Require stack:
- /snapshot/node_modules/import-global/index.js
- /snapshot/node_modules/amplify-provider-awscloudformation/lib/transform-graphql-schema.js
- /snapshot/node_modules/amplify-provider-awscloudformation/lib/push-resources.js
- /snapshot/node_modules/amplify-provider-awscloudformation/lib/amplify-service-migrate.js
- /snapshot/node_modules/amplify-provider-awscloudformation/lib/initializer.js
- /snapshot/node_modules/amplify-provider-awscloudformation/lib/index.js
- /snapshot/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/execute-provider-utils.js
- /snapshot/node_modules/@aws-amplify/cli/lib/domain/amplify-toolkit.js
- /snapshot/node_modules/@aws-amplify/cli/lib/domain/context.js
- /snapshot/node_modules/@aws-amplify/cli/lib/context-manager.js
- /snapshot/node_modules/@aws-amplify/cli/lib/index.js
- /snapshot/node_modules/@aws-amplify/cli/bin/amplify Unable to import custom transformer module(graphql-assert-transformer).
Transform.conf.json: "transformers": [ "graphql-default-value-transformer", "graphql-assert-transformer", "graphql-auto-transformer" ]
Expected behavior
Successfully generated models
Reproduction steps
iOS project: After pulling from the backend, I am unable to run $ amplify codegen models successfully. Updating Xcode project: ✅ Amplify project found. ✅ Amplify config files found. ✅ Successfully updated project /Users/XXX/XXX/XXX. ✅ Amplify models folder found at /Users/XXX/XXX/XXX/amplify/generated/models ✅ Successfully added models [] to 'AmplifyModels' group. Amplify setup completed successfully.
$ amplify codegen models
GraphQL schema(s)
# Put schemas below this line
Log output
# Put your logs below this line
Additional information
No response
The error is thrown by the schema validation, which depends on the graphql transformer package of CLI. I will transfer this to CLI so that they will better assist you
@nielsautrata I have a few questions:
- Was this working with a previous version of the CLI?
- I see that you're importing other modules as well (graphql-default-value-transformer, graphql-auto-transformer). Are those working properly?
- Is graphql-assert-transformer installed where it's expected?
- Yes, before version 5
- Yes, in the react and android projects there are no error for compiling with codegen
- Yes, there are installed generally, this is my transform.conf.json:
{
"Version": 5,
"ElasticsearchWarning": true,
"transformers": [
"graphql-default-value-transformer",
"graphql-assert-transformer",
"graphql-auto-transformer"
],
"StackMapping": {
"QuerylistResponsiblesByAssignmentResolver": "Responsible",
"QuerylistResponsiblesByEmployeeResolver": "ResponsibleM"
}
}
In the case, you want to download my graph.ql this my app id dl91s1m9oit3p and the region is us-east-1
Thanks for the info @nielsautrata. I'm marking this as a bug.
@nielsautrata I see that you are using the packaged CLI, right? Can you confirm that if you install the CLI from NPM then codegen models will work? (so the custom transformer is correctly installed?)
But that's the other question, how is the custom transformer installed, as you reference it by package name, CLI looks for it as a global module, which it is failed to find.
After Installing the custom transformer via npm locally in the respective project folder then codegen models will work. "Successfully added models".
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.