Michael
11/23/2018, 8:26 PMtype Bill @pgTable(name: "bill") {
bill: String!
id: Int! @unique
bill_products: [Bill_product]
}
type Bill_product @pgTable(name: "bill_product") {
bill: Bill @pgRelation(column: "bill_id")
product: Product @pgRelation(column: "product_id")
some_other_column: String!
}
type Product @pgTable(name: "product") {
id: Int! @unique
product: String!
bill_products: [Bill_product]
}
I am trying to access some_other_column data when I query
query {
bill(where: { id: 1 }){
id
bill_products {
product {
id
product
}
some_other_column
}
}
}
When I run the SQL from the docs, add the types to my app.prisma file then run prisma deploy I get 3 errors
Bill_product ✖ The required field 'id' is missing and has to have the format: id: ID! @unique or id: UUID! @unique or id: Int! @unique.
Bill ✖ The relation field ‘bill_products’ has the wrong format: ‘[Bill_product]’ Possible Formats
: ‘Bill_Product’, ‘Bill_product!‘, ‘[Bill_product!]\!’
Products ✖ The relation field ‘bill_products’ has the wrong format: ‘[Bill_product]’ Possible Formats
: ‘Bill_Product’, ‘Bill_product!‘, ‘[Bill_product!]\!’
When I resolve these 3 errors and run prisma deploy all is well
When I try to query
query {
bill(where: { id: 1 }){
id
bill_products {
product {
id
product
}
some_other_column
}
}
}
I get errors in PostgreSQL
ERROR: column Alias.id does not exist at character 217
STATEMENT: select
"Alias"."id",
"RelationTable"."id" as "__RelatedModel__",
"RelationTable"."bill_id" as "__ParentModel__"
from "public"."bill_product" as "Alias"
join "public"."bill_product" as "RelationTable"
on "Alias"."id" = "RelationTable"."id"
where "RelationTable"."bill_id" in ($1)
order by "RelationTable"."id" asc