AWS Amplify GraphQL Schema 导致错误
Posted
技术标签:
【中文标题】AWS Amplify GraphQL Schema 导致错误【英文标题】:AWS Amplify GraphQL Schema is causing an error 【发布时间】:2022-01-02 12:12:09 【问题描述】:我是 Amplify 的新手,我正在尝试建立一个相当复杂的架构。当我运行放大推送时,我得到的唯一响应是......
An error occurred when pushing the resources to the cloud
这发生在通知它将创建资源并询问我是否要继续之后。我删除了大部分架构并仅使用一个模型再次尝试并且它有效,所以我的架构中某处存在问题......我猜?我没有看到任何地方可以检查它。
这是架构
type Article
@model
@key(name: "bySource", fields: ["sourceId", "dateWritten"])
id: ID!
link: AWSURL!
title: String!
dateWritten: String!
createdAt: String!
data: AWSJSON!
approved: Boolean!
admin: Boolean!
creatorId: ID!
creator: User @connection(fields: ["creatorId"])
sourceId: ID!
source: Source @connection(fields: ["sourceId"])
tagArtCons: [TagArtCon]
@connection(keyName: "byArticle", fields: ["articleId"])
type Tag @model @key(name: "byFrontPage", fields: ["frontpage"])
id: ID!
name: String!
createdAt: String!
creatorId: ID!
data: AWSJSON!
frontpage: String
official: Boolean!
tagArtConns: [TagArtCon] @connection(keyName: "byTag", fields: ["tagId"])
type TagArtCon
@model
@key(name: "byTag", fields: ["tagId"])
@key(name: "byArticle", fields: ["articleId"])
id: ID!
tagId: ID!
articleId: ID!
creatorId: ID!
createdAt: String!
article: Article @connection(fields: ["articleId"])
tag: Tag @connection(fields: ["tagId"])
parentRelations: [TagRelation]
@connection(keyName: "byParent", fields: ["tagId"])
childRelations: [TagRelation]
@connection(keyName: "byChild", fields: ["tagId"])
type TagRelation
@model
@key(name: "byParent", fields: ["parentId"])
@key(name: "byChild", fields: ["childId"])
id: ID!
parentId: ID!
childId: ID!
creatorId: ID!
createdAt: String!
parentTag: Tag @connection(fields: ["parentId"])
childTag: Tag @connection(fields: ["childId"])
type Source @model
id: ID!
sourceName: String!
sourceUrl: String!
sourceImage: String!
creatorId: ID!
articles: [Article] @connection(keyName: "bySource", fields: ["id"])
type User @model
id: ID!
userName: String!
userImage: String!
admin: Boolean!
createdAt: String!
data: AWSJSON
我想要做的是拥有一堆文章和一堆标签。标签代表类别,人等。我有以下表格
文章, 标签, 一个表,其中每个条目将一篇文章与一个标签联系起来 持有父/子关系的标签之间的关系表 仅包含文章来源数据的源表 一个用户表
我在某个地方犯了一个错误,架构不起作用,它没有告诉我原因。我会继续简化这个,直到我希望能解决这个问题,但我真的很感激任何帮助,因为我是新手。谢谢。
【问题讨论】:
【参考方案1】:终于找到问题了。有一个地方我尝试使用“articleId”,一个地方我尝试使用“tagId”,两者都应该是“id”。
【讨论】:
以上是关于AWS Amplify GraphQL Schema 导致错误的主要内容,如果未能解决你的问题,请参考以下文章
如何在 aws amplify 中使用 graphQL 限制
@connection 上的 AWS Amplify Graphql 查询
通过 GraphQL 键检索 AWS Amplify DataStore 记录