Skip to content
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

Fix graphql tutorial: api uses path instead of key #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
40 changes: 20 additions & 20 deletions data/tutorial/07_graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To start off we will create a query to retrieve the value stored at the path
query {
main {
tree {
get(key: "abc")
get(path: "abc")
}
}
}
Expand All @@ -60,33 +60,33 @@ The following would accomplish the same thing in `my-branch`:
query {
branch(name: "my-branch") {
tree {
get(key: "a/b/c")
get(path: "a/b/c")
}
}
}
```

It's also possible to set or update multiple keys using the `set_tree` and
It's also possible to set or update multiple paths using the `set_tree` and
`update_tree` mutations. The following will set `/a` to "foo" and `/b` to "bar":

```graphql
mutation {
set_tree(
key: "/"
tree: [{ key: "a", value: "foo" }, { key: "b", value: "bar" }]
path: "/"
tree: [{ path: "a", value: "foo" }, { path: "b", value: "bar" }]
) {
hash
}
}
```

And updating multiple keys is similar:
And updating multiple paths is similar:

```graphql
mutation {
update_tree(
key: "/"
tree: [{ key: "a", value: "testing" }, { key: "b", value: null }]
path: "/"
tree: [{ path: "a", value: "testing" }, { path: "b", value: null }]
) {
hash
}
Expand Down Expand Up @@ -118,7 +118,7 @@ Due to difficulties representing infinitely recursive datatypes in GraphQL, an
Irmin tree is represented using the `[TreeItem!]` type. `TreeItem` has the
following keys:

- `key`
- `path`
- `value`
- `metadata`

Expand All @@ -130,7 +130,7 @@ query {
head {
tree {
list_contents_recursively {
key
path
value
}
}
Expand All @@ -146,9 +146,9 @@ query {
main {
head {
tree {
get_tree(key: "a") {
get_tree(path: "a") {
list_contents_recursively {
key
path
value
}
}
Expand All @@ -165,11 +165,11 @@ side-effects.

### Set

For example, setting a key is easy:
For example, setting a path is easy:

```graphql
mutation {
set(key: "a/b/c", value: "123") {
set(path: "a/b/c", value: "123") {
hash
}
}
Expand Down Expand Up @@ -203,8 +203,8 @@ provided. For example:
```graphql
mutation {
set_tree(
key: "/"
tree: [{ key: "a/b/c", value: "123" }, { key: "d/e/f", value: "456" }]
path: "/"
tree: [{ path: "a/b/c", value: "123" }, { path: "d/e/f", value: "456" }]
) {
hash
}
Expand All @@ -218,11 +218,11 @@ used:
```graphql
mutation {
update_tree(
key: "/"
path: "/"
tree: [
{ key: "a/b/c", value: "123" }
{ key: "d/e/f", value: "456" }
{ key: "testing", value: null }
{ path: "a/b/c", value: "123" }
{ path: "d/e/f", value: "456" }
{ path: "testing", value: null }
]
) {
hash
Expand Down