带有 AWS AppSync 注释的 GraphQL Codegen

发布于 2025-01-21 02:08:50 字数 1458 浏览 4 评论 0原文

我有一个添加了 AppSync 注释的 graphql 架构,例如:

@aws_oidc @aws_api_key 

一种类型看起来像这样,例如:

type Response @aws_oidc @aws_api_key {
  id: ID!
  body: AWSJSON!
  status: Int!
  header: AWSJSON!
  url: String!
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime!
}

我正在使用 codegen 用于从架构中生成 TypeScript 类型。在我添加注释之前它运行良好。

现在我收到错误消息:


  ✖ ../app/types/graphql.ts
    Failed to load schema from ./stacks/schema.graphql,./appsync.graphql:

        Syntax Error: Unexpected character: U+00D8.
        GraphQLError: Syntax Error: Unexpected character: U+00D8.

您知道如何跳过它们吗?

Codegen.yml

overwrite: true
schema:
  - './stacks/schema.graphql'
  - './appsync.graphql'
documents: null
generates:
  graphql.ts:
    plugins:
      - 'typescript'
  ../app/types/graphql.ts:
    plugins:
      - 'typescript'
config:
  scalars:
    AWSJSON: string
    AWSDate: string
    AWSTime: string
    AWSDateTime: string
    AWSTimestamp: number
    AWSEmail: string
    AWSURL: string
    AWSPhone: string
    AWSIPAddress: string
    Queue: string

appsync.graphql

scalar AWSDate
scalar AWSTime
scalar AWSDateTime
scalar AWSTimestamp
scalar AWSEmail
scalar AWSJSON
scalar AWSURL
scalar AWSPhone
scalar AWSIPAddress

I've got a graphql schema with added AppSync annotations like:

@aws_oidc @aws_api_key 

One type looks like that for example:

type Response @aws_oidc @aws_api_key {
  id: ID!
  body: AWSJSON!
  status: Int!
  header: AWSJSON!
  url: String!
  createdAt: AWSDateTime!
  updatedAt: AWSDateTime!
}

I am using codegen for generating TypeScript types out of the schema. It worked well till I've added the annotations.

Now I get the error message:


  ✖ ../app/types/graphql.ts
    Failed to load schema from ./stacks/schema.graphql,./appsync.graphql:

        Syntax Error: Unexpected character: U+00D8.
        GraphQLError: Syntax Error: Unexpected character: U+00D8.

Do you have any idea on how to skip them?

Codegen.yml

overwrite: true
schema:
  - './stacks/schema.graphql'
  - './appsync.graphql'
documents: null
generates:
  graphql.ts:
    plugins:
      - 'typescript'
  ../app/types/graphql.ts:
    plugins:
      - 'typescript'
config:
  scalars:
    AWSJSON: string
    AWSDate: string
    AWSTime: string
    AWSDateTime: string
    AWSTimestamp: number
    AWSEmail: string
    AWSURL: string
    AWSPhone: string
    AWSIPAddress: string
    Queue: string

appsync.graphql

scalar AWSDate
scalar AWSTime
scalar AWSDateTime
scalar AWSTimestamp
scalar AWSEmail
scalar AWSJSON
scalar AWSURL
scalar AWSPhone
scalar AWSIPAddress

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一笑百媚生 2025-01-28 02:08:50

问题是随机尾随 Ø

The issue was a random trailing Ø

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文