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 import custom transformer module #4

Open
damo78 opened this issue Dec 11, 2020 · 6 comments
Open

Unable to import custom transformer module #4

damo78 opened this issue Dec 11, 2020 · 6 comments

Comments

@damo78
Copy link

damo78 commented Dec 11, 2020

@aws-amplify/cli@4.39.0

Plugin installed globally (although got lots of rollbackFailedOptional)

npm i -g graphql-default-value-transformer
⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-se+ graphql-default-value-transformer@2.0.1
added 27 packages from 40 contributors in 7.09s

transform.conf.json

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

Used one field to test: name: String @default(value: "")

$: amplify mock api
Initializing new Amplify CLI version...
Done initializing new version.
Scanning for plugins...
Plugin scan successful
Unable to import custom transformer module(graphql-default-value-transformer).
You may fix this error by editing transformers at /Users/damo/Documents/Development/gitlab/dcit-sandbox/enterprise/products/sls-nextjs/next-sls-amplified/amplify/backend/api/nextslsgraph/transform.conf.json
Failed to start API Mock endpoint Error: Cannot find module 'lodash'
Require stack:
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/graphql-default-value-transformer/node_modules/graphql-transformer-core/lib/util/sanity-check.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/graphql-default-value-transformer/node_modules/graphql-transformer-core/lib/util/index.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/graphql-default-value-transformer/node_modules/graphql-transformer-core/lib/GraphQLTransform.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/graphql-default-value-transformer/node_modules/graphql-transformer-core/lib/index.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/graphql-default-value-transformer/lib/DefaultValueTransformer.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/graphql-default-value-transformer/lib/index.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/node_modules/import-global/index.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/transform-graphql-schema.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/push-resources.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/amplify-service-migrate.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/initializer.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/index.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/execute-provider-utils.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/lib/domain/amplify-toolkit.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/lib/domain/context.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/lib/context-manager.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/lib/index.js
- /Users/damo/.nvm/versions/node/v14.5.0/lib/node_modules/@aws-amplify/cli/bin/amplify

If you need any more info please let me know

@mjza
Copy link

mjza commented Dec 29, 2020

@damo78 I found the solution.
Inside the AWS Amplify Console, edit your build settings, and change it like the following:

backend:
  phases:
    build:
      commands:
        - npm i -g graphql-default-value-transformer
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple

I mean before amplifyPush --simple you need to provide the npm i -g graphql-default-value-transformer to install the custom transformer before doing the amplifyPush.

@damo78
Copy link
Author

damo78 commented Dec 29, 2020

Thanks @mjza, I'll give that a try

@vitalbone
Copy link

Thanks @mjza. Your suggestion worked for me.

@mjza
Copy link

mjza commented Jan 29, 2021

@damo78 I think you can close this ticket, as resolved.

@mjza
Copy link

mjza commented Jan 29, 2021

@awarzon @shortjared Maybe not a bad idea to edit your readme file, and include this instruction inside.

@PeteDuncanson
Copy link

@mjza been trying to get this to work using you suggestion above but still getting a similar error to the original one :(

image

version: 3
backend:
  phases:
    build:
      commands:
        - '# Fix to get the tranformer working https://github.com/trek10inc/graphql-default-value-transformer/issues/3'
        - npm i -g graphql-default-value-transformer
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - '# Hack to get it running against node12 so it builds without errors - https://github.com/aws-amplify/amplify-cli/issues/3131'
        - nvm use 12
        - yarn install
    build:
      commands:
      - '# Make the commit ID available in the react app as REACT_APP_COMMIT_ID - https://codingblog.carterdan.net/2020/09/03/commit-hash-react-aws-amplify/'
      - REACT_APP_COMMIT_ID=$AWS_COMMIT_ID REACT_APP_BRANCH_NAME=$AWS_BRANCH yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants