"Unknown directive model" 在 WebStorm 中设置 AWS Amplify GraphQL API

"Unknown directive model" when setting up AWS Amplify GraphQL API in WebStorm

我正在为 Angular 使用以下 AWS Amplify 教程:

https://docs.amplify.aws/start/getting-started/data-model/q/integration/angular#model-the-data-with-graphql-transform

当我生成 GraphQL API 时,我收到 @model 指令的红色警告消息:

我正在使用 WebStorm。我怎样才能让我的编辑器不抛出这些红色警告错误?我需要安装一些@types 包还是安装一些插件?

首先,使用以下内容创建 .graphqlconfig 文件:

{
  "schemaPath": "schema.graphql",
  "includes": ["*"],
  "extensions": {
    "endpoints": {}
  }
}

然后,使用以下内容创建 graphql-directives.js 文件:

import gql from 'graphql-tag';

const clientSchemaExtensions = gql`
  directive @model on OBJECT
  scalar AWSDateTime
`;

之后,再也没有语法错误了!

此答案已改编 from this repo