Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Oct 16, 2023
1 parent 209fafa commit 3c41b9d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions docs/guides/n+1.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ type Post {
@http(
path: "/users"
# highlight-start
query: [{key: "id", value: "{{parent.value.userId}}"}]
query: [{key: "id", value: "{{value.userId}}"}]
)
@batch(key: "userId", path: ["id"])
@groupBy(key: "userId", path: ["id"])
# highlight-end
}
```

### Understanding the Update

The described changes introduce significant tweaks to the `@http` directive and incorporate the `@batch` operator:
The described changes introduce significant tweaks to the `@http` directive and incorporate the `@groupBy` operator:

- `query: [{key: "id", value: "{{parent.value.userId}}"}]`: Here, TailCall CLI is instructed to generate a URL where the user id aligns with the `userId` from the parent `Post`. For a batch of posts, the CLI compiles a single URL, such as `/users?id=1&id=2&id=3...id=10`, consolidating multiple requests into one.
- `query: [{key: "id", value: "{{value.userId}}"}]`: Here, TailCall CLI is instructed to generate a URL where the user id aligns with the `userId` from the parent `Post`. For a batch of posts, the CLI compiles a single URL, such as `/users?id=1&id=2&id=3...id=10`, consolidating multiple requests into one.

- `@batch` operator:
- `@groupBy` operator:

- `path: ["id"]`: This parameter instructs the system to convert the list of responses into a map internally, using the user's `id` as the unique key. In essence, it allows the system to differentiate each user value in the response list.

Expand Down
4 changes: 2 additions & 2 deletions docs/intro/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ type Post {
title: String!
body: String!
user: User
@http(path: "/users", query: [{key: "id", value: "{{parent.value.userId}}"}], matchPath: ["id"], matchKey: "userId")
@http(path: "/users", query: [{key: "id", value: "{{value.userId}}"}], matchPath: ["id"], matchKey: "userId")
}
```

In this case, `parent.value.userId` is a way to get the `userId` information from the "parent" context of the `Post` type. Essentially, it's extracting a list or "array" of `userId` fields from multiple `Post` types. Think of `parent.value` as a container that holds the results of a post query, with `userId` being the specific key you want to fetch from that container.
In this case, `value.userId` is a way to get the `userId` information from the "parent" context of the `Post` type. Essentially, it's extracting a list or "array" of `userId` fields from multiple `Post` types. Think of `value` as a container that holds the results of a post query, with `userId` being the specific key you want to fetch from that container.

### env

Expand Down
10 changes: 5 additions & 5 deletions docs/intro/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ type Mutation {

In this scenario, the `User-Name` header's value will dynamically adjust according to the `name` argument passed in the request.

## @batch
## @groupBy

The `@batch` operator in Tailcall groups multiple data requests into a single call. It works together with the `@http` operator. For more details please refer out [n + 1 guide].
The `@groupBy` operator in Tailcall groups multiple data requests into a single call. It works together with the `@http` operator. For more details please refer out [n + 1 guide].

[n + 1 guide]: /docs/guides/n+1#solving-using-batching

Expand All @@ -367,12 +367,12 @@ type Post {
id: Int!
name: String!
user: User
@http(path: "/users", query: {key: "id", value: "{{parent.value.userId}}"}])
@batch(key: "userId", path: ["id"])
@http(path: "/users", query: {key: "id", value: "{{value.userId}}"}])
@groupBy(key: "userId", path: ["id"])
}
```

- `query: {key: "id", value: "{{parent.value.userId}}"}]`: Here, TailCall CLI is instructed to generate a URL where the user id aligns with the `userId` from the parent `Post`. For a batch of posts, the CLI compiles a single URL, such as `/users?id=1&id=2&id=3...id=10`, consolidating multiple requests into one.
- `query: {key: "id", value: "{{value.userId}}"}]`: Here, TailCall CLI is instructed to generate a URL where the user id aligns with the `userId` from the parent `Post`. For a batch of posts, the CLI compiles a single URL, such as `/users?id=1&id=2&id=3...id=10`, consolidating multiple requests into one.

#### path

Expand Down

0 comments on commit 3c41b9d

Please sign in to comment.