Hi, I have a simple graph of pets. Pets have a type (cat, dog) etc. The thing is dogs have a ‘Name’ but cats have ‘Nickname’. I can use aliases and normalize to query for both types using multiple queries and return an array of the results. i.e. the following query works really well:
{
myPets(func: eq(type, "dog")) @normalize {
Body {
Name : Name
Age: Age
}
}
myPets(func: eq(type, "cat")) @normalize {
Body {
Name : Nickname
Age : Age
}
}
}
and gives me this result
"data": {
"myPets": [
{
"Age": 10,
"Name": "foo",
"uid": "0x7d4a"
},
{
"Age": 20,
"Name": "bar",
"uid": "0x7d4c"
}
]
}
Now if I decide to look for other types that don’t exist yet - lets say a lizard I get an error.
{
myPets(func: eq(type, "dog")) @normalize {
Body {
Name : Name
Age: Age
}
}
myPets(func: eq(type, "cat")) @normalize {
Body {
Name : Nickname
Age : Age
}
}
myPets(func: eq(type, "lizard")) @normalize {
Body {
Name : Nickname
Age : Age
}
}
}
Unable to marshal response
I noticed that if I give it a unique query name it succeeds, but then I get a seperate array i.e.
If I add this to my above query
{
myPets(func: eq(type, "dog")) @normalize {
Body {
Name : Name
Age: Age
}
}
myPets(func: eq(type, "cat")) @normalize {
Body {
Name : Nickname
Age : Age
}
}
other(func: eq(type, "lizard")) @normalize {
Body {
Name : Anyname
Age : Age
}
}
}
I get this response
"data": {
"myPets": [
{
"Age": 10,
"Name": "foo",
"uid": "0x7d4a"
},
{
"Age": 20,
"Name": "bar",
"uid": "0x7d4c"
}
],
"other": []
},
Is there any way to normalize with multiple queries, and merge the result ?