amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

When deploying by using amplify console, an error has occurred, "Unknown directive key"

Open yukitaka13-1110 opened this issue 7 years ago • 10 comments

I'm using vue(spa) + amplify framework. When I executed 'amplify api push', graphql schema was compiled successfully. But when I tried to deploy by using Amplify console, an error has occurred.

2019-06-03T07:30:39.635Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud 2019-06-03T07:30:39.637Z [WARNING]: ✖ There was an error initializing your environment. 2019-06-03T07:30:39.638Z [INFO]: init failed 2019-06-03T07:30:39.691Z [INFO]: { SchemaValidationError: Schema Errors: Unknown directive "key". GraphQL request (1:21) 1: type PanInfo @model @key(fields: ["panName", "objectID"]) { ^ 2: panName: String! at GraphQLTransform.transform (/home/circleci/repo/packages/graphql-transformer-core/src/GraphQLTransform.ts:220:19) at Object. (/home/circleci/repo/packages/graphql-transformer-core/src/util/amplifyUtils.ts:27:37) at step (/root/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/lib/util/amplifyUtils.js:40:23) at Object.next (/root/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/lib/util/amplifyUtils.js:21:53) at fulfilled (/root/.nvm/versions/node/v8.12.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/lib/util/amplifyUtils.js:12:58) at name: 'SchemaValidationError' } 2019-06-03T07:30:39.697Z [ERROR]: !!! Build failed 2019-06-03T07:30:39.697Z [ERROR]: !!! Non-Zero Exit Code detected

What is the cause of this error?

info

amplify framework => 1.7.0 vue => 3.8.2

yukitaka13-1110 avatar Jun 03 '19 08:06 yukitaka13-1110

I am facing the same error on react + amplify, amplify push command

✖ An error occurred when pushing the resources to the cloud

Schema Errors: Unknown directive "key". GraphQL request (120:3) 119: ) 120: @key(fields: ["email"]) ^ 121: {

type User
  @model(
    queries: { get: "getUser" },
    mutations: { create: "registeredUser", update: "updateUser" },
    subscriptions: null
  )
  @key(fields: ["email"])
{
  id: ID!,
  account: Account! @connection(name: "AccountUsers"),

amplify 1.6.8

ravishwetha avatar Jun 03 '19 12:06 ravishwetha

I am also facing same error but on amplify api gql-compile

Schema Errors: Unknown directive "key". GraphQL request (1:19) 1: type Trade @model @key(fields: ["closeDate"]) { ^ 2: id: ID!

apoorvmote avatar Jun 03 '19 13:06 apoorvmote

The Amplify Console isn’t using the latest CLI build which has support for @key directive. I’ve requested them to upgrade their CLI build to the latest. Once that’s rolled out on the console, I’ll circle back on this thread and let you’ll know.

kaustavghosh06 avatar Jun 03 '19 15:06 kaustavghosh06

The Amplify Console isn’t using the latest CLI build which has support for @key directive. I’ve requested them to upgrade their CLI build to the latest. Once that’s rolled out on the console, I’ll circle back on this thread and let you’ll know.

Updating input structures for key: {"fields":["closeDate"]}

GraphQL schema compiled successfully.

apoorvmote avatar Jun 03 '19 15:06 apoorvmote

Oh oh, I also have the same issue -- look forward to hear back!

heauton avatar Jun 04 '19 02:06 heauton

I found the way of resolving this error by oneself. Please wait a moument.

yukitaka13-1110 avatar Jun 04 '19 02:06 yukitaka13-1110

I wrote a solution.

In summary, I added the following to the build configuration file:npm install -g @aws-amplify/cli

yukitaka13-1110 avatar Jun 04 '19 03:06 yukitaka13-1110

The latest CLI version is available by default in the Amplify build container.

swaminator avatar Jun 05 '19 01:06 swaminator

I confirmed that I could deploy it. Thank you for your quick response!

yukitaka13-1110 avatar Jun 05 '19 01:06 yukitaka13-1110

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[bot] avatar May 27 '21 07:05 github-actions[bot]