When deploying by using amplify console, an error has occurred, "Unknown directive key"
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
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
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!
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.
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.
Oh oh, I also have the same issue -- look forward to hear back!
I found the way of resolving this error by oneself. Please wait a moument.
I wrote a solution.
In summary, I added the following to the build configuration file:npm install -g @aws-amplify/cli
The latest CLI version is available by default in the Amplify build container.
I confirmed that I could deploy it. Thank you for your quick response!
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.