I am trying to pass a product object to an invoice table so in my case I guess it is a one-to-many where one invoice has multiple products. I tried to do something like this:
the schema:
type Product @model @key(name: "productIDIndex", fields: ["productID"]) {
id: String!
name: String!
handle: String
description: String
categories: [String]
tags: [String]
images: [Image]
price: Float
sellingPrice: Float
profit: Float
priceTaxExcl: Int
priceTaxIncl: Int
taxRate: Int
comparedPrice: Int
quantity: Int
sku: String
width: String
height: String
depth: String
weight: String
extraShippingFee: Int
active: Boolean
boughtDate: String
soldDate: String
deliveryPrice: Float
deliveryMwstPrice: Float
ebayInvoiceNo: Int
ebayArticleNo: String
differencePrice: Float
differenceMwstPrice: Float
total: Float
totalMwst: Float
productID: ID!
}
type Image {
default: Boolean
id: String
url: String
type: String
}
type Invoice @model {
id: ID!
products: [Product] @connection(keyName: "productIDIndex", fields:["id"])
date: String
}
where the generated schema for the Invoice I have only the id and date as inputs but I need to write the product object as well.
generated schema for CreateInvoiceInput:
input CreateInvoiceInput {
id: ID
date: String
}
I tried to pass the product as an object in the request but I got an error on the browser that product is not defined in the input of invoice.
any idea of how can this be solved?