Gorodov Maksim
11/23/2018, 11:12 AMvalue
)
type RuleExampleOption {
id: ID! @unique
name: String!
value: RuleExampleOptionValue! or Boolean!
example: RuleExample!
}
UsulPro
11/23/2018, 11:16 AMtaikn
11/23/2018, 11:20 AMkris
11/23/2018, 2:07 PMRamin B
11/23/2018, 2:11 PMervindraganovic
11/23/2018, 2:25 PMEmil Forsmann
11/23/2018, 2:26 PMk0ff33
11/23/2018, 2:26 PMk0ff33
11/23/2018, 2:26 PMAlex
11/23/2018, 2:36 PMtylim
11/23/2018, 5:36 PMgeabenitez
11/23/2018, 8:01 PMgeabenitez
11/23/2018, 8:01 PMgeabenitez
11/23/2018, 8:11 PMMichael
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
Luke
11/23/2018, 9:52 PMLuke
11/23/2018, 9:53 PMyolen
11/23/2018, 10:00 PMKen
11/23/2018, 10:23 PMGillinghammer
11/23/2018, 11:16 PMqirex
11/24/2018, 11:24 AMGorodov Maksim
11/24/2018, 11:37 AMGorodov Maksim
11/24/2018, 11:39 AMtype Rule {
id: ID! @unique
name: String! @unique
examples: [RuleExample!]! @relation(name: "RuleOnRuleExample" onDelete: CASCADE)
}
type RuleExample {
id: ID! @unique
correct: String!
incorrect: String!
rule: Rule @relation(name: "RuleOnRuleExample")
}
I created a rule with field examples - http://prntscr.com/lmdo4b
And now when I'm trying to get it like this:
query {
rule(name: "getter-return") {
examples {
correct
incorrect
}
}
}
I get null
inside examples
field. Why? Here is the code of this query:
const rule = (_, args, context, info) => {
return context.prisma.rule(
args.id ? { id: args.id } : { name: args.name.toLowerCase() },
);
};
Gorodov Maksim
11/24/2018, 11:47 AMconst updateRule = async(_, args, context, info) => {
return context.prisma.updateRule(
{
where: args.id ? { id: args.id } : { name: args.name.toLowerCase() },
data: {
examples: args.examples ? {
create: {
options: args.examples.options ? {
create: args.examples.options.map((exampleOption) => ({
name: exampleOption.name,
value: exampleOption.value,
})),
} : null,
correct: args.examples.correct,
incorrect: args.examples.incorrect,
},
} : null,
},
},
);
};
And I'm interested in this - if the Rule
has field examples
but I passed null
to it, will field examples
become null
or not?tylim
11/24/2018, 12:34 PMtylim
11/24/2018, 12:34 PMtylim
11/24/2018, 12:36 PMfgreinus
11/24/2018, 5:37 PMLobo
11/24/2018, 10:19 PMLobo
11/24/2018, 10:19 PM