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

Unable to locate custom transformer during gql compile #6330

Closed
yaquawa opened this issue Jan 7, 2021 · 13 comments
Closed

Unable to locate custom transformer during gql compile #6330

yaquawa opened this issue Jan 7, 2021 · 13 comments
Labels
dependency-issue Issue with another dependency used graphql-transformer-v1 Issue related to GraphQL Transformer v1

Comments

@yaquawa
Copy link

yaquawa commented Jan 7, 2021

I have read this article https://docs.amplify.aws/cli/plugins/authoring#authoring-custom-graphql-transformers--directives
but no mention on how to use a custom transformer.

I have tried graphql-default-value-transformer, with the following setting in my amplify/backend/api/xx/transform.conf.json

{
    "Version": 5,
    "ElasticsearchWarning": true,
    "transformers": [
        "graphql-default-value-transformer"
    ]
}

But I got this error when I run amplify push

Cannot find module 'xxxxx/~/.npm-global/lib/node_modules/graphql-default-value-transformer'

(I have installed the package both locally and globally.)

How to fix the issue

I found this is an issue of the upstream lib global-dirs.
So I created an issue at here.
sindresorhus/global-directory#21
Amplify team should upgrade the global-dirs once the issue has been fixed.

@edwardfoyle
Copy link
Member

@yaquawa did you change the npm global path between when you installed the CLI and when you installed this transformer? Can you check if the package is actually installed at the path that the CLI is looking for it?

@edwardfoyle edwardfoyle added graphql-transformer-v1 Issue related to GraphQL Transformer v1 question General question labels Jan 7, 2021
@edwardfoyle edwardfoyle changed the title How to use a custom transformer? Unable to locate custom transformer during gql compile Jan 7, 2021
@yaquawa
Copy link
Author

yaquawa commented Jan 9, 2021

@edwardfoyle here is the global path of mine.

npm config get prefix
/Users/username/.npm-global

I could find graphql-default-value-transformer in /Users/username/.npm-global/lib/node_modules/graphql-default-value-transformer/.

By the way
the xxxxx in the error message is the path of my project, so the path xxxxx/~/.npm-global/lib/node_modules/graphql-default-value-transformer is an invalid path.

Cannot find module 'xxxxx/~/.npm-global/lib/node_modules/graphql-default-value-transformer'

@yaquawa
Copy link
Author

yaquawa commented Jan 11, 2021

@edwardfoyle

Here is the full error message:

Unable to import custom transformer module(graphql-default-value-transformer).
You may fix this error by editing transformers at /Users/xxx/Documents/htdocs/myproject/amplify/backend/api/testprojectapi/transform.conf.json
✖ An error occurred when pushing the resources to the cloud

Cannot find module '/Users/xxx/Documents/htdocs/myproject/~/.npm-global/lib/node_modules/graphql-default-value-transformer'
Require stack:
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/import-global/index.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/transform-graphql-schema.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/push-resources.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/amplify-service-migrate.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/initializer.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/index.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/lib/commands/push.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/lib/index.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/bin/amplify
An error occurred during the push operation: Cannot find module '/Users/xxx/Documents/htdocs/myproject/~/.npm-global/lib/node_modules/graphql-default-value-transformer'
Require stack:
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/import-global/index.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/transform-graphql-schema.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/push-resources.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/amplify-service-migrate.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/initializer.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/index.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/lib/commands/push.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/lib/index.js
- /Users/xxx/.npm-global/lib/node_modules/@aws-amplify/cli/bin/amplify

@edwardfoyle
Copy link
Member

@yaquawa I was able to successfully compile a schema using that transformer plugin and the latest version of the CLI.

Are you using a local installation of the CLI? The CLI only supports global installation

@edwardfoyle edwardfoyle added not-reproducible Not able to reproduce the issue pending-close-response-required and removed question General question labels Jan 11, 2021
@yaquawa
Copy link
Author

yaquawa commented Jan 12, 2021

@edwardfoyle can you tell me what's your npm config get prefix and your version of amplify?
I was not able to compile it in both local and global installation. I even don't have a package-lock.json becuase I'm using yarn.

I could find graphql-default-value-transformer in /Users/username/.npm-global/lib/node_modules/graphql-default-value-transformer/.

@edwardfoyle
Copy link
Member

my npm config get prefix is /usr/local. What does which amplify return for you? It should be equivalent to $(npm config get prefix)/bin/amplify

@yaquawa
Copy link
Author

yaquawa commented Jan 13, 2021

@edwardfoyle here is mine, looks fine?

npm config get prefix
/Users/xx/.npm-global

which amplify
/Users/xx/.npm-global/bin/amplify

@yaquawa
Copy link
Author

yaquawa commented Jan 14, 2021

@edwardfoyle can you tell me your amplify's version?

@yaquawa
Copy link
Author

yaquawa commented Jan 14, 2021

@edwardfoyle I found this is an issue of the upstream lib global-dirs.
So I created an issue at here.
sindresorhus/global-directory#21
Amplify team should upgrade the global-dirs once the issue has been fixed.

@edwardfoyle
Copy link
Member

Thanks for digging into that! Marking this as a dependency issue

@edwardfoyle edwardfoyle added dependency-issue Issue with another dependency used and removed external not-reproducible Not able to reproduce the issue labels Jan 14, 2021
@stale
Copy link

stale bot commented Jun 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Jun 18, 2021

This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.

@stale stale bot closed this as completed Jun 18, 2021
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependency-issue Issue with another dependency used graphql-transformer-v1 Issue related to GraphQL Transformer v1
Projects
None yet
Development

No branches or pull requests

2 participants