Prisma generate:要合并的字段配置具有重复的字段名称
Posted
技术标签:
【中文标题】Prisma generate:要合并的字段配置具有重复的字段名称【英文标题】:Prisma generate: Field configuration to merge has duplicate field names 【发布时间】:2019-05-10 02:11:27 【问题描述】:正在运行 prisma generate 我在这个输出中发生了并且没有生成任何代码。
prisma generate
Generating schema...
[ species: type: [Object], args: [Object] ,
species: type: [Object], args: [Object] ,
Generating schema !
! Field configuration to merge has duplicate field names.
我的架构有什么问题?
type User
id: ID! @unique
email: String! @unique
name: String!
password: String!
entries: [Entry!]!
createdAt: DateTime!
updatedAt: DateTime!
type Language
id: ID! @unique
language: String! @unique
createdAt: DateTime!
updatedAt: DateTime!
type EntryScientificName
id: ID! @unique
entry: Entry!
isMain: Boolean!
scientificName: String! @unique
language: Language!
createdAt: DateTime!
updatedAt: DateTime!
type EntryName
id: ID! @unique
entry: Entry!
isMain: Boolean!
name: String! @unique
Language: Language!
createdAt: DateTime!
updatedAt: DateTime!
type Species
id: ID! @unique
species: String! @unique
description: String
createdAt: DateTime!
updatedAt: DateTime!
type Genus
id: ID! @unique
genus: String! @unique
description: String
createdAt: DateTime!
updatedAt: DateTime!
type Family
id: ID! @unique
family: String! @unique
description: String
createdAt: DateTime!
updatedAt: DateTime!
type Order
id: ID! @unique
order: String! @unique
description: String
createdAt: DateTime!
updatedAt: DateTime!
type Habitat
id: ID! @unique
habitat: String! @unique
description: String
createdAt: DateTime!
updatedAt: DateTime!
type Month
id: ID! @unique
month: String! @unique
type Anthesis
id: ID! @unique
entry: Entry
fromMonth: Month! @relation(name: "FromMonth")
toMonth: Month! @relation(name: "ToMonth")
note: String
createdAt: DateTime!
updatedAt: DateTime!
type Nation
id: ID! @unique
nation: String! @unique
createdAt: DateTime!
updatedAt: DateTime!
type Region
id: ID! @unique
nation: Nation!
region: String! @unique
createdAt: DateTime!
updatedAt: DateTime!
type DistributionDetail
id: ID! @unique
detail: String!
createdAt: DateTime!
updatedAt: DateTime!
type GeographicDistribution
id: ID! @unique
entry: Entry!
region: Region!
detail: DistributionDetail
createdAt: DateTime!
updatedAt: DateTime!
type Altitude
id: ID! @unique
entry: Entry! @unique
altitudeFrom: Int! @unique @constraint(min: -10894, max: 408000)
altitudeTo: Int! @unique @constraint(min: -10894, max: 408000)
type Entry
id: ID! @unique
name: [EntryName!]!
scientificName: [EntryScientificName!]!
species: Species
genus: Genus
family: Family
order: Order
biologicalForm: String
plantDescription: String
leafDescription: String
flowerDescription: String
fruitDescriptio: String
chorologicalType: String
habitat: [Habitat!]!
geographicDistribution: [GeographicDistribution!]!
altitude: [Altitude!]!
etymology: String
propertiesUses: String
curiosities: String
notes: String
links: [Link!]!
entryPicture: String
draft: Boolean @default(value: "true")
published: Boolean @default(value: "false")
toBeReviewed: Boolean @default(value: "false")
createdAt: DateTime!
updatedAt: DateTime!
author: User
type Link
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
url: String!
description: String!
postedby: User
【问题讨论】:
【参考方案1】:Prisma 会根据您的数据模型生成 GraphQL 架构。这样做,它会根据您的类型生成复数类型。
但是,由于Species
的复数形式是Species
,Prisma 现在有两种同名类型,因此会引发错误。 (参见issue 和News
)
您目前无法为类型或字段选择复数名称(请参阅issue)。
一般来说,最好为您的类型使用单数名称。
【讨论】:
以上是关于Prisma generate:要合并的字段配置具有重复的字段名称的主要内容,如果未能解决你的问题,请参考以下文章
@prisma/client 尚未初始化。请运行“prisma generate”并尝试再次导入
生成 Prisma Graphql Schema 时使用 generate 和 post deploy 钩子之间的区别?
graphql-code-generator 依据graphql schema自动生成客户端类型定义