Skip to content

Commit

Permalink
Merge pull request #24 from fredrik-sogaard/(docs)matrix-field-example
Browse files Browse the repository at this point in the history
Added usage with Matrix Fields in docs
  • Loading branch information
markhuot authored Oct 27, 2017
2 parents 54ab827 + 1359b03 commit bfe085f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,31 @@ The above would be passed with variables such as,
"body": "<p>Here's the body of my first mutation</p>",
}
```
## Matrix Fields
Working with Matrix Fields are similar to working with Entry Types: if you have a Matrix Field named `pagebuilder`, the containing Block Types are named `PageBuilder` + the block name. For instance `PageBuilderText` or `PageBuilderImage`. You can use the key `__typename` from the resulting response to map over the blocks and display the appropriate component.

```graphql
{
entries(section: [news]) {
... on News {
id
title
body { # Your Matrix Field
... on BodyText { # Block Type
blockHeading # Fields on Block Type, uses field handle
blockContent # Fields on Block Type, uses field handle
}
... on BodyImage { # Block Type
blockDescription # Fields on Block Type, uses field handle
image { # Fields on Block Type, uses field handle
id # Fields on image field on Block Type, uses field handles
}
}
}
}
}
}
```

## Dates

Expand Down

0 comments on commit bfe085f

Please sign in to comment.