-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support filter on expand #3904
Comments
@campoy It seems the syntax |
Given a type Person as follows: type Person {
name: string
age: int
best_friend: uid // points to a Person
lives_with: [uid] // holds an array of objects: some of type Person, some of type Pet
pets: [uid] // holds an array of objects of type Pet
} expand(Person)
{
q(func: eq(name, "Francesc")) {
expand(Person)
}
} Is the same as writing {
q(func: eq(name, "Francesc")) {
name
age
best_friend
lives_with
pets
}
} You can read more on expand(X) @filter(type(Person))This will expand whatever is requested in the So given a value of {
"uid": "0x1234",
"dgraph.type": "Person",
"name": "Frodo",
"age": 25,
"best_friend": {
"uid": "0x2345",
"dgraph.type": "Person",
"name": "Sam",
"age": 24
},
"lives_with": [
{
"uid": "0x2345",
"dgraph.type": "Person",
"name": "Sam",
"age": 24
},
{
"uid": "0x3456",
"dgraph.type": "Pet",
"name": "Milou"
}
],
"pets": [
{
"uid": "0x3456",
"dgraph.type": "Pet",
"name": "Milou"
}
]
} The following query: {
q(func: eq(name, "Frodo")) {
expand(_all_) @filter(type(Person)) {
expand(Person)
}
}
} would:
The result would be the following: {
"best_friend": {
"name": "Sam",
"age": 24
},
"lives_with": [
{
"name": "Sam",
"age": 24
}
]
} I wonder if this is clear enough. I think I need to spend some time writing more specs for these changes. |
Hey @martinmr , could you have a look at this issue? |
I have a PR for this already but there is a weird bug that I haven't had the chance to debug yet. |
Hey, @martinmr is there any status update about this issue? |
This issue is related to #4399, as |
It would be very useful to filter what fields are included in an
expand
operation.For instance, we could expand only the predicates pointing to values of type
Person
from aMovie
as such:This would expand the predicates of type
uid
or[uid]
and show only the nodes associated to the type Person.The text was updated successfully, but these errors were encountered: