graphql-ttl-transformer icon indicating copy to clipboard operation
graphql-ttl-transformer copied to clipboard

Unable to get my Amplify to see the plugin

Open AlessioVallero opened this issue 3 years ago • 16 comments

Hello! :) I'm trying to add the plugin to my Amplify environment, I'm using version 2 of the transformer. I followed the instructions and added it by running npm install --save graphql-ttl-transformer and then edited the amplify/backend/api/<YOUR_API>/transform.conf.json file, as instructed. However, I get the error below in response.

Screen Shot 2022-08-31 at 6 06 37 PM

Furthermore, I tried adding the plugin manually with the command amplify plugin add and the I provided the absolute path to the plugin and I received the following error.

Screen Shot 2022-08-31 at 6 08 57 PM

Any advice? I'm using Amplify version 9.2.1.

AlessioVallero avatar Sep 01 '22 01:09 AlessioVallero

The Amplify docs indicate that it must be installed globally, similar to how @aws-ampify/cli is also installed.

Try npm install -g graphql-ttl-transformer

joekiller avatar Sep 06 '22 17:09 joekiller

I will note here, that it seems you must have it both installed locally and globally.

npm install -g graphql-ttl-transformer
npm install graphql-ttl-transformer

Also, you cannot use it as a standard plugin because Amplify doesn't have a convention for transformers other than adding them to the transformers.conf.json.

joekiller avatar Sep 06 '22 18:09 joekiller

@joekiller thank you! I tried to follow your suggestion but I'm still encountering the same issues. One question I have is: in which folder are you installing "locally" using npm install graphql-ttl-transformer?

AlessioVallero avatar Sep 06 '22 20:09 AlessioVallero

By locally, I mean the folder which is the parent of the the amplify directory. Ie the one in which you ran amplify init from originally. Typically that is the root folder of a project. so given project-foo/ containing the amplify/ directory I'd run the command in the project-foo/ directory.

joekiller avatar Sep 06 '22 22:09 joekiller

Thank you! I did that and got the same error. I wonder if anyone else has the same issue.

AlessioVallero avatar Sep 06 '22 23:09 AlessioVallero

That is frustrating for sure. What type of project is it which you are trying to use this with? I was running a typescript/JavaScript project. Another thing I did, which I don't know if it matters is I had nodejs 16 installed.

What version of graphql transformation are you using? Ie is it the v2 type?

Does this error occur locally or on ci? Finally what platform are you running? Macos, windows, Linux, etc.

joekiller avatar Sep 06 '22 23:09 joekiller

Running on the latest macOS on a typescript webpack built project. Node version 14.15.3 on a v2 transformer.

AlessioVallero avatar Sep 07 '22 00:09 AlessioVallero

Good to know. I'm running on the Linux and my colleague complained the plugin didn't work. They were also running macos so I wonder if there's a kludge there.

I did successful get CI running with the "install it locally and globally" trick.

joekiller avatar Sep 07 '22 00:09 joekiller

Appreciate your insights! I'm confused at why it isn't noticed by more people at this point.

AlessioVallero avatar Sep 07 '22 00:09 AlessioVallero

@AlessioVallero My colleague and I were able to work through this issue today. The crux involved Amplify using a different node_module home than what their current npm was using. In their case, they had installed amplify cli at some point using the curl script which put the amplify cli in their /usr/local/bin while later on they adopted using nvm which made npm install -g graphql-ttl-transformer ineffective to get the plugin into the same context as the amplify cli. We were able to identify the location with which amplify and then remediate by uninstalling it via somewhat brute force.

Uninstall from local:

amplify uninstall
rm /usr/local/bin/amplify
rm -rf /usr/local/lib/node_modules/\@aws-amplify/

We could then reconcile the node_module location differences by reinstall everything npm install -g @aws-amplify/cli graphql-ttl-transformer.

Hope this helps.

joekiller avatar Sep 07 '22 15:09 joekiller

@AlessioVallero My colleague and I were able to work through this issue today. The crux involved Amplify using a different node_module home than what their current npm was using. In their case, they had installed amplify cli at some point using the curl script which put the amplify cli in their /usr/local/bin while later on they adopted using nvm which made npm install -g graphql-ttl-transformer ineffective to get the plugin into the same context as the amplify cli. We were able to identify the location with which amplify and then remediate by uninstalling it via somewhat brute force.

Uninstall from local:


amplify uninstall

rm /usr/local/bin/amplify

rm -rf /usr/local/lib/node_modules/\@aws-amplify/

We could then reconcile the node_module location differences by reinstall everything npm install -g @aws-amplify/cli graphql-ttl-transformer.

Hope this helps.

Thanks a lot! I will try it out in a couple of days and will keep you posted. 🙏

AlessioVallero avatar Sep 07 '22 16:09 AlessioVallero

Hello, I found that upgrading npm may fix most of these issues as well. If you npm --version is older than 8, you may want to try npm install -g npm@latest. Upgrading npm helped me avoid having to install the plugin globally.

joekiller avatar Sep 07 '22 23:09 joekiller

Hi Joe, I tried following all the steps you suggested above and, oddly enough, I still have the same issue. The only difference I can think of is that I'm using yarn instead of npm in my project.

AlessioVallero avatar Sep 09 '22 05:09 AlessioVallero

I searched around yarn amplify cli and it seems like npm is the package management of choice for Amplify, ie there are lots of unresolved or just closed due to no input issues regarding using yarn in the projects. Buyer beware I guess.

Funny enough though, the amplify cli development uses yarn. Go figure.

joekiller avatar Sep 09 '22 16:09 joekiller

I searched around yarn amplify cli and it seems like npm is the package management of choice for Amplify, ie there are lots of unresolved or just closed due to no input issues regarding using yarn in the projects. Buyer beware I guess.

Funny enough though, the amplify cli development uses yarn. Go figure.

Ah, yeah that'd make sense, although the location of the node_modules should be the same. Unfortunately I have to give up for now, I'm wasting way too much time in trying to fix this. Thanks @joekiller for all your support!!!

AlessioVallero avatar Sep 09 '22 16:09 AlessioVallero

I had success using this approach https://github.com/aws-amplify/amplify-category-api/issues/606#issuecomment-1240013390. At this point I'm fairly certain that combining yarn and npm for plugins is a source of problems.

AlessioVallero avatar Oct 06 '22 06:10 AlessioVallero

Closing as it seems to be fixable by using the approach explained in: https://github.com/flogy/graphql-ttl-transformer/issues/18#issuecomment-1269429457

flogy avatar Oct 02 '23 19:10 flogy