【问题标题】:Prisma generate: Field configuration to merge has duplicate field namesPrisma generate:要合并的字段配置具有重复的字段名称
【发布时间】: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
}

【问题讨论】:

    标签: graphql prisma generate prisma-graphql


    【解决方案1】:

    Prisma 会根据您的数据模型生成 GraphQL 架构。这样做,它会根据您的类型生成复数类型

    但是,由于Species 的复数形式是Species,Prisma 现在有两种同名类型,因此会引发错误。 (参见issueNews

    您目前无法为类型或字段选择复数名称(请参阅issue)。

    一般来说,最好为您的类型使用单数名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-15
      • 2016-01-06
      • 2021-07-31
      • 1970-01-01
      • 2020-01-10
      • 2015-01-02
      相关资源
      最近更新 更多