Skip to content

Commit 555f3f9

Browse files
committed
GraphQL: Additional relational field usage
1 parent 7f28168 commit 555f3f9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/5.x/development/graphql.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,37 @@ The following examples include server-rendered Twig “equivalents,” which are
390390
}
391391
```
392392

393+
- Scope selection of related elements:
394+
395+
::: code
396+
```graphql{6} GraphQL
397+
query PostsWithBroadTopics {
398+
entries(section: "blog") {
399+
title
400+
url
401+
402+
... on post_Entry {
403+
topics(level: 1) {
404+
title
405+
}
406+
}
407+
}
408+
}
409+
```
410+
```twig{8} Twig
411+
{% set posts = craft.entries()
412+
.section('blog')
413+
.all() %}
414+
415+
{% for post in posts %}
416+
{{ post.title }}
417+
418+
Filed in {{ post.topics.level(1).eagerly().collect().join(', ') }}
419+
{% endfor %}
420+
```
421+
:::
422+
423+
393424
- Find elements using abstract relational criteria:
394425

395426
::: code

0 commit comments

Comments
 (0)