diff --git a/docs/guides/n+1.md b/docs/guides/n+1.md index 697c1cadd9..174cab22ec 100644 --- a/docs/guides/n+1.md +++ b/docs/guides/n+1.md @@ -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. diff --git a/docs/intro/context.md b/docs/intro/context.md index e788a6cb89..c7d0b6a7b7 100644 --- a/docs/intro/context.md +++ b/docs/intro/context.md @@ -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 diff --git a/docs/intro/operators.md b/docs/intro/operators.md index d995a8f33c..926daa6e1a 100644 --- a/docs/intro/operators.md +++ b/docs/intro/operators.md @@ -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 @@ -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