Skip to content

Improving expand function documentation #4795

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

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions wiki/content/query-language/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1796,19 +1796,31 @@ Query Example: Actors from Tim Burton movies and how many roles they have played
}
{{< /runnable >}}



## Expand Predicates

The `expand()` function can be used to expand the predicates out of a node. To
use `expand()`, the [type system]({{< relref "#type-system" >}}) is required.
use `expand()`, the [type system]({{< relref "#type-system" >}}) is required.
Refer to the section on the type system to check how to set the types
nodes. The rest of this section assumes familiarity with that section.

There are four ways to use the `expand` function.
There are two ways to use the `expand` function.

* Types can be passed to `expand()` to expand all the predicates in the type.

Query example: List the movies from the Harry Potter series:

{{< runnable >}}
{
all(func: eq(name@en, "Harry Potter")) @filter(type(Series)) {
name@en
expand(Series) {
name@en
expand(Film)
}
}
}
{{< /runnable >}}

* Predicates can be stored in a variable and passed to `expand()` to expand all
the predicates in the variable.
* If `_all_` is passed as an argument to `expand()`, the predicates to be
expanded will be the union of fields in the types assigned to a given node.

Expand Down Expand Up @@ -1844,9 +1856,11 @@ owner
veterinarian
```

{{% notice "note" %}}
For `string` predicates, `expand` only returns values not tagged with a language
(see [language preference]({{< relref "#language-support" >}})). So it's often
required to add `name@fr` or `name@.` as well to an expand query.
{{% /notice %}}

### Filtering during expand.

Expand Down