Hello everyone, i tried out the latest https://graphql.dgraph.io/. Then, i encounter a problem when tried to remove from list.
the schema is:-
type User {
id: ID!
name: String!
hobbies: [Hobby] @hasInverse(field: user)
}
type Hobby {
id: ID!
name: String!
user: User! @hasInverse(field: hobbies)
}
add user:-
mutation {
addUser(input: { name: "user1" }) {
user {
id
name
hobbies {
id
name
}
}
}
}
result:-
{
"data": {
"addUser": {
"user": {
"id": "0x20",
"name": "user1",
"hobbies": []
}
}
},
"extensions": {
"requestID": "a9170e7b-ffc3-4b3a-941c-01c059bdecb2"
}
}
add hobby to user:-
mutation {
addHobby(input: { name: "hobby1", user: { id: "0x20" } }) {
hobby {
id
name
user {
id
name
}
}
}
}
result:-
{
"data": {
"addHobby": {
"hobby": {
"id": "0x23",
"name": "hobby1",
"user": {
"id": "0x20",
"name": "user1"
}
}
}
},
"extensions": {
"requestID": "e169ce99-75ec-425f-a0ad-5f7450cd88a0"
}
}
then, delete back hobby:-
mutation {
deleteHobby(filter: { ids: ["0x23"] }) {
msg
}
}
result:-
{
"data": {
"deleteHobby": {
"msg": "Deleted"
}
},
"extensions": {
"requestID": "fb3dda46-da25-46ec-96c9-2c49e06eec7b"
}
}
get back user data:-
{
"data": {
"getUser": {
"id": "0x20",
"name": "user1",
"hobbies": [
{
"id": "0x23",
"name": null
}
]
}
},
"extensions": {
"requestID": "4af226a7-5b1c-47b7-b6ee-216ebf990a3a"
}
}
as we can see, the hobby object remain in the user’s hobbies list. is this intended behaviour?
im actually expecting the result to be like this:-
"data": {
"getUser": {
"id": "0x20",
"name": "user1",
"hobbies": []
}
}
so, is this possible to be done using dgraph graphql or not?
hope you guys can give me input on this matter. thank you