I just started a trivial graphql schema:
type Product {
productID: ID!
name: String @search(by: [term])
reviews: [Review] @hasInverse(field: about)
}
type Review {
id: ID!
about: Product! @hasInverse(field: reviews)
by: Customer! @hasInverse(field: reviews)
comment: String @search(by: [fulltext])
rating: Int @search
}
type Customer {
custID: ID!
name: String @search(by: [hash, regexp])
reviews: [Review] @hasInverse(field: by)
}
Now I want to populate the DB with millions of json entries without calling the graphql mutation (too slow). For instance I have a folder full of several json files (customers and products) of the following shape.
Example of a json customer file:
{
id: "deadbeef",
name: "Bill Gates",
reviews: [
{
id:"1234",
comment: "nice product"
rating: 5,
productId: "5678"
}
]
}
Example of a json product file:
{
id: "5678",
name: "Bluetooth headset",
}
To what I understood, to defined edges between nodes, I first have to overload each object with an uid
The customer would become:
{
id: "deadbeef",
uid: "_:deadbeef",
...
reviews: [
{
id:"1234",
uid:"_:1234",
productId: {uid: "_:5678"}
}
]
}
And the product
{
id: "5678",
uid: "_:5678"
...
}
Then we could batch import them (this is pure speculation, I never tried this). While this should import the entries, I would like to know how the DB would associate those entries with a type, because there is no clue yet on the data we want to insert. Is there a property like __typename
I could add to each of my entries to type them?
[edit] I've found 2 possible properties class
and dgraph.type
still wondering which one and how I should use them