Skip to content
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
103 changes: 51 additions & 52 deletions content/guides/04.connect/3.query-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,66 +54,65 @@ As Many to Any (M2A) fields have nested data from multiple collections, you are
::callout{icon="material-symbols:info-outline"}
**Example**
In an `posts` collection there is a Many to Any field called `sections` that points to `headings`, `paragraphs`, and `videos`. Different fields should be fetched from each related collection.
::

::code-group
```http [REST]
::code-group

```http [REST]
GET /items/posts
?fields[]=title
&fields[]=sections.item:headings.title
&fields[]=sections.item:headings.level
&fields[]=sections.item:paragraphs.body
&fields[]=sections.item:videos.source
```

`````

````graphql [GraphQL]
# Use can use native GraphQL Union types.

query {
posts {
sections {
item {
... on headings {
title
level
}
... on paragraphs {
body
}
... on videos {
source
}
}
}
}
}
```

```js [SDK]
import { createDirectus, rest, readItems } from '@directus/sdk';
const directus = createDirectus('https://directus.example.com').with(rest());

const result = await directus.request(
readItems('posts', {
fields: [
'title',
{
sections: [
{
item: {
headings: ['title', 'level'],
paragraphs: ['body'],
videos: ['source'],
}
}
]
}
],
})
);
```
::
```graphql [GraphQL]
# Use can use native GraphQL Union types.

query {
posts {
sections {
item {
... on headings {
title
level
}
... on paragraphs {
body
}
... on videos {
source
}
}
}
}
}
```

```js [SDK]
import { createDirectus, rest, readItems } from "@directus/sdk";
const directus = createDirectus("https://directus.example.com").with(rest());

const result = await directus.request(
readItems("posts", {
fields: [
"title",
{
sections: [
{
item: {
headings: ["title", "level"],
paragraphs: ["body"],
videos: ["source"],
},
},
],
},
],
}),
);
```

::

Expand All @@ -131,7 +130,7 @@ GET /items/posts

GET /items/posts
?filter={ "title": { "_eq": "Hello" }}
`````
```

```graphql [GraphQL]
query {
Expand Down
Loading