AWS Amplify GraphQL 代码生成错误:“架构无效或不完整,类型未知:AWSModelQueryMap”

问题描述 投票:0回答:1

我正在使用 AWS Amplify Gen 1 开发一个 React 项目,并尝试设置 GraphQL API。我已经初始化了 Amplify 项目,并使用默认的待办事项列表架构添加了 GraphQL API。但是,当尝试推送架构并生成所需的代码时,我遇到了错误。

[adonys@DESKTOP-LO73D5J react-aws-amplify]$ amplify push
⠇ Fetching updates to backend environment: dev from the cloud.⠋ Building resource api/reactawsamplify
⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review: https://docs.amplify.aws/cli/graphql/authorization-rules

⠸ Building resource api/reactawsamplify✅ GraphQL schema compiled successfully.

Edit your schema at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema.graphql or place .graphql files in a directory at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema
✔ Successfully pulled backend environment dev from the cloud.
⠋ Building resource api/reactawsamplify
⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review: https://docs.amplify.aws/cli/graphql/authorization-rules

⠸ Building resource api/reactawsamplify✅ GraphQL schema compiled successfully.

Edit your schema at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema.graphql or place .graphql files in a directory at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema

    Current Environment: dev
    
┌──────────┬─────────────────┬───────────┬───────────────────┐
│ Category │ Resource name   │ Operation │ Provider plugin   │
├──────────┼─────────────────┼───────────┼───────────────────┤
│ Api      │ reactawsamplify │ Create    │ awscloudformation │
└──────────┴─────────────────┴───────────┴───────────────────┘
✔ Are you sure you want to continue? (Y/n) · yes

⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review: https://docs.amplify.aws/cli/graphql/authorization-rules

✅ GraphQL schema compiled successfully.

Edit your schema at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema.graphql or place .graphql files in a directory at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema
⠋ Building resource api/reactawsamplify
⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review: https://docs.amplify.aws/cli/graphql/authorization-rules

⠹ Building resource api/reactawsamplify✅ GraphQL schema compiled successfully.

Edit your schema at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema.graphql or place .graphql files in a directory at /home/adonys/react-aws-amplify/amplify/backend/api/reactawsamplify/schema
? Do you want to generate code for your newly created GraphQL API Yes
? Choose the code generation language target typescript
? Enter the file name pattern of graphql queries, mutations and subscriptions src/graphql/**/*.ts
? Do you want to generate/update all possible GraphQL operations - queries, mutations and subscriptions Yes
? Enter maximum statement depth [increase from default if your schema is deeply nested] 2
? Enter the file name for the generated code src/API.ts

Deployment completed.
Deploying root stack reactawsamplify [ ---------------------------------------- ] 0/2
        amplify-reactawsamplify-dev-5… AWS::CloudFormation::Stack     UPDATE_IN_PROGRESS             Sun Nov 10 2024 20:36
        apireactawsamplify             AWS::CloudFormation::Stack     CREATE_IN_PROGRESS             Sun Nov 10 2024 20:36
Deployed api reactawsamplify [ ======================================== ] 6/6
        GraphQLAPI                     AWS::AppSync::GraphQLApi       CREATE_COMPLETE                Sun Nov 10 2024 20:36
        GraphQLAPIDefaultApiKey215A6D… AWS::AppSync::ApiKey           CREATE_COMPLETE                Sun Nov 10 2024 20:36
        GraphQLAPITransformerSchema3C… AWS::AppSync::GraphQLSchema    CREATE_COMPLETE                Sun Nov 10 2024 20:37
        GraphQLAPINONEDS95A13CF0       AWS::AppSync::DataSource       CREATE_COMPLETE                Sun Nov 10 2024 20:36
        Todo                           AWS::CloudFormation::Stack     CREATE_COMPLETE                Sun Nov 10 2024 20:37
        CustomResourcesjson            AWS::CloudFormation::Stack     CREATE_COMPLETE                Sun Nov 10 2024 20:37

Code generation failed with the following error 
Invalid or incomplete schema, unknown type: AWSModelQueryMap. Ensure that a full introspection query is used in order to build a client schema..
Deployment state saved successfully.

其他背景:

  • AWS Amplify CLI 版本:12.13.0
  • Node.js 版本:v20.15.0
  • 使用 TypeScript 的 React 项目
  • 使用 Amplify 中的默认“待办事项列表”模板

我不确定为什么会发生与

AWSModelQueryMap
相关的错误,特别是因为我使用的是 Amplify 提供的默认架构。是否与过时的配置有关,或者我还缺少什么?

任何有关如何解决此问题的见解或建议将不胜感激!

graphql aws-amplify
1个回答
0
投票

从今天开始我收到了同样的错误。有人已经找到解决方案或询问过 AWS 了吗?

© www.soinside.com 2019 - 2024. All rights reserved.