我正在开发 GraphQL 节点教程,并且已完成第 7 步。
https://www.howtographql.com/graphql-js/7-subscriptions/
我从我的datamodel.prisma文件中的这段代码中得到了一些语法错误:
directive @id on FIELD_DEFINITION
directive @unique on FIELD_DEFINITION
directive @createdAt on FIELD_DEFINITION
scalar DateTime
type Link {
id: ID! @id
createdAt: DateTime! @createdAt
description: String!
url: String!
postedBy: User
votes: [Vote!]!
}
type User {
id: ID! @id
name: String!
email: String! @unique
password: String!
links: [Link!]!
votes: [Vote!]!
}
type Vote {
id: ID! @id
link: Link!
user: User!
}
但我仍然得到'User' type [@6:1] tried to redefine existing 'User' type [@15:5]和'Link' type [@24:1] tried to redefine existing 'Link' type [@6:5]。
我也不确定我是否声明directives或scalars正确,因为官方教程中缺少这一点。
任何人都可以就如何对这些问题进行排序提供任何建议吗?
Schema.graphql:
type Query {
info: String!
feed(filter: String, skip: Int, first: Int, orderBy: LinkOrderByInput): Feed!
}
type Feed {
links: [Link!]!
count: Int!
}
type AuthPayload {
token: String
user: User
}
type User {
id: ID!
name: String!
email: String!
links: [Link!]!
}
type Vote {
id: ID!
link: Link!
user: User!
}
type Link {
id: ID!
description: String!
url: String!
postedBy: User
votes: [Vote!]!
}
type Subscription {
newLink: Link
newVote: Vote
}
type Mutation {
post(url: String!, description: String!): Link!
signup(email: String!, password: String!, name: String!): AuthPayload
login(email: String!, password: String!): AuthPayload
vote(linkId: ID!): Vote
}
enum LinkOrderByInput {
description_ASC
description_DESC
url_ASC
url_DESC
createdAt_ASC
createdAt_DESC
}
繁星coding
函数式编程
相关分类