Prisma1: Type xxxPreviousValues must define one or more fields.

Created on 29 Jun 2018  Â·  8Comments  Â·  Source: prisma/prisma1

Describe the bug
When a database type is defined with only relation fields, an associated PreviousValues helper type is created with no fields. This causes an error during the graphql get-schema --project database command.

To Reproduce
The following schema generates the error Type MyRelationTypePreviousValues must define one or more fields

type MyDataType {
  """ fields... """

  oneRelations: [MyRelationType !]! @relation(name: "RelationOne")
  twoRelations: [MyRelationType !]! @relation(name: "RelationTwo")
}

type MyRelationType {
  one: Item! @relation(name: "RelationOne")
  two: Item! @relation(name: "RelationTwo")
}

Expected behavior
Either the PreviousValues type should not be created, or a warning/error should be created on deploy. Since the deploy otherwise worked out okay, I was very confused and lost for a while trying to figure this one out.

Versions (please complete the following information):

  • Windows 10
  • prisma/1.10.2 (windows-x64) node-v8.9.4
  • Prisma Server: 1.11-beta (Heroku)
  • graphql-cli 2.16.3
bu2-confirmed bu1-repro-available

All 8 comments

+1

Thanks a lot for this report, this looks related to #1981.

Can you share when exactly you ran into this specific error message?
This is a duplicate of https://github.com/prismagraphql/prisma/issues/2623, but there the error message is "Syntax Error: Expected Name, found }".

Thanks for response!

I was getting the error 5 days ago when the issue was posted. I had just installed latest CLI tools.

I still have the problem.

GraphQL endpoint generated invalid schema: Type MyTypePreviousValues must define one or more fields.
Running graphql get-schema -p prisma ✖
$ prisma -v
prisma/1.11.1 (darwin-x64) node-v10.4.1
$ graphql -v
2.16.4

@bardak-dev can you share your data model?

@marktani
short version

# Currency codes
enum CurrencyCode {
  # United States Dollars (USD)
  USD

  # Euro (EUR)
  EUR
}

# A monetary value with currency.
type Money {
  # Decimal money amount.
  amount: Float!

  # Currency of the money.
  currencyCode: CurrencyCode!
}
# Breakdown of the total fees and gross of each of the different types of transactions associated
# with the payout.
#
type PaymentsPayoutSummary {
  # blankField: String @deprecated(reason: "get-schema bug")
  # Total fees for all adjustments including disputes.
  adjustmentsFee: Money! @relation(name: "PayoutSummaryAF")

  # Total gross amount for all adjustments including disputes.
  adjustmentsGross: Money! @relation(name: "PaymentsPayoutSummaryAG")
}

I had this same issue and adding a unique field of type ID or String solved the problem for me. In the future a better solution might come out, but for now this fix seems to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

notrab picture notrab  Â·  3Comments

hoodsy picture hoodsy  Â·  3Comments

nikolasburk picture nikolasburk  Â·  3Comments

marktani picture marktani  Â·  3Comments

dohomi picture dohomi  Â·  3Comments