@Lucas Carvalho de Sousa ,
Ok, I get your point 😀.
Given the following model and using Movie as the example:
type PersonType @view(space: "imdb", version: "1") {
typename: String!
people: [Person] @relation(type:{space:"imdb", externalId: "Person.people"}, direction: INWARDS)
}
interface Person @view(space: "imdb", version: "1") {
personType: PersonType
name: String!
age: Int
}
type Actor implements Person @view(space: "imdb", version: "1") {
personType: PersonType
name: String!
age: Int
wonOscar: Boolean
hasDirected: Boolean
movies: [Movie] @relation(type:{space:"imdb", externalId: "Movie.actors"}, direction: INWARDS)
}
type Director implements Person @view(space: "imdb", version: "1") {
personType: PersonType
name: String!
age: Int
wonOscar: Boolean
directed: [Movie] @relation(type:{space:"imdb", externalId: "Movie.director"}, direction: INWARDS)
}
type Movie @view(space: "imdb", version: "1") {
name: String!
description: String
watchedIt: Boolean
imdbRating: Float
releasedYear: Int
gross: Int
runTime: Int
director: Director
actors: [Actor] @relation(edgeSource: "ActedIn" type: {space: "imdb", externalId: "Movie.actors"}, direction: OUTWARDS)
}
type ActedIn @edge @view(space: "imdb", version: "1"){
roleCode: String
salary: Float
}
I can create a Movie node instance per the following:
{{baseUrl}}/models/instances
{
"items": [
{
"instanceType": "node",
"space": "imdb",
"externalId": "movie-Oppenheimer",
"existingVersion": "1",
"sources": [
{
"source": {
"type": "view",
"space": "imdb",
"externalId": "Movie",
"version": "1"
},
"properties": {
"name": "Oppenheimer",
"watchedIt": false,
"director": {
"space": "imdb",
"externalId": "Christopher Nolan"
}
}
}
]
}
],
"autoCreateDirectRelations": false,
"autoCreateStartNodes": false,
"autoCreateEndNodes": false,
"skipOnVersionConflict": false,
"replace": false
}
I can create Actor edges via the following (you can create many per request (1000 is the limit). I just have 1 item in this example. Create other items for actors in the same movie or another item for another movie.actors edge. Each edge will have a unique externalId.
{
"items": [
{
"instanceType": "edge",
"space": "imdb",
"externalId": "movie-actors-Oppenheimer-Emily Blunt",
"existingVersion": "1",
"type": {
"space": "imdb",
"externalId": "Movie.actors"
},
"startNode": {
"space": "imdb",
"externalId": "movie-Oppenheimer"
},
"endNode": {
"space": "imdb",
"externalId": "Emily Blunt"
}
}
],
"autoCreateDirectRelations": true,
"autoCreateStartNodes": false,
"autoCreateEndNodes": false,
"skipOnVersionConflict": false,
"replace": false
}
Hope this helps,
Jason