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

AWS Amplify Build - Cannot Find graphql-ttl-transformer

Open LoukasGP opened this issue 3 years ago • 2 comments

Hello,

  1. I have read this article offering a build solution.
  2. I have added this to my transform.conf.json file "transformers": ["graphql-ttl-transformer"]
  3. I have installed this package on my project "graphql-ttl-transformer": "^2.0.0",
  4. The localhost ttl fields via graphql schema work and show in DynamoDB
  5. I am using Next.js and AWS Amplify
  6. I am using "transformerversion": 2 in the cli.json file.

Error: 🛑 Unable to import custom transformer module(graphql-ttl-transformer). 🛑 You may fix this error by editing transformers at graphql-ttl-transformer/transform.conf.json ✖ An error occurred when pushing the resources to the cloud ✖ There was an error initializing your environment. Cannot find module '/root/.amplify/lib/node_modules/graphql-ttl-transformer'

Build File for AWS Amplify Hosting:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm install 
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

LoukasGP avatar Sep 01 '22 06:09 LoukasGP

~~Regarding your question, the spec presented is confusing as these errors typically present themselves during the backend phase of the build. Are you sure this is the build taking place?~~

~~Regardless, the solution, which I have mentioned in https://github.com/aws-amplify/amplify-category-api/issues/606#issuecomment-1238488189, seems to be to both install the plugin locally and globally.~~

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

joekiller avatar Sep 06 '22 18:09 joekiller

Just to be clear, the best solution is updating npm to a version greater than 8. See my comment here: https://github.com/flogy/graphql-ttl-transformer/issues/3#issuecomment-1240023750

joekiller avatar Sep 07 '22 23:09 joekiller

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

flogy avatar Oct 02 '23 19:10 flogy