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

revert: "chore: update docs for dedupe" #523

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 3 additions & 7 deletions docs/N+1.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,23 @@ If you run the query, at first you will observe a lot of duplicate requests are

![Duplicate Upstream Calls](../static/images/docs/n+1-duplicate.png)

This happens because of the 100 posts, a lot them are authored by the same user and by default Tailcall will make a request for every user when requested.
You can fix this by setting [dedupe](/docs/directives.md#dedupe) to `true` in [`@http`](/docs/directives.md#http-directive).
This happens because of the 100 posts, a lot them are authored by the same user and by default Tailcall will make a request for every user when requested. You can fix this by setting [dedupe](/docs/directives.md#dedupe) to `true` in [server](/docs/directives.md#server-directive).

```graphql {3}
schema
@server(
dedupe: true
port: 8000)
@upstream(baseURL: "http://jsonplaceholder.typicode.com") {
query: Query
}

type Query {
posts: [Post] @http(path: "/posts")
# ...
}

type Post {
# ...
user: User @call(
dedupe: true,
steps: [{query: "user", args: {id: "{{.value.userId}}"}}]
)
}

type User {
Expand Down
51 changes: 11 additions & 40 deletions docs/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,6 @@ The server returns the response that we expected:

This way you can compose combine multiple operations can compose them together using the `@call` directive.

### dedupe

This flag when set to `true` prevents duplicate calls from being executed concurrently, reducing resource load. If not specified, this feature defaults to `false`.

```graphql showLineNumbers
schema @call(
dedupe: true
)
```

:::note
We use `JSON` scalar here because we don't care about the type safety of this option. In a real world example you might want to use proper input and output types.
:::
Expand Down Expand Up @@ -698,16 +688,6 @@ type Query {

Make sure you have also specified batch settings to the `@upstream` and to the `@graphQL` directive.

### dedupe

This flag when set to `true` prevents duplicate GraphQL requests from being executed concurrently, reducing resource load. If not specified, this feature defaults to `false`.

```graphql showLineNumbers
schema @graphQL(
dedupe: true
)
```

## @grpc Directive

The `@grpc` directive enables the resolution of GraphQL fields via gRPC services. Below is an illustrative example of how to apply this directive within a GraphQL schema:
Expand Down Expand Up @@ -792,16 +772,6 @@ type Query {
}
```

### dedupe

This flag when set to `true` prevents duplicate gRPC requests from being executed concurrently, reducing resource load. If not specified, this feature defaults to `false`.

```graphql showLineNumbers
schema @grpc(
dedupe: true
)
```

### body

This parameter outlines the arguments for the gRPC call, allowing for both static and dynamic inputs:
Expand Down Expand Up @@ -895,16 +865,6 @@ type Query {
}
```

### dedupe

This flag when set to `true` prevents duplicate HTTP requests from being executed concurrently, reducing resource load. If not specified, this feature defaults to `false`.

```graphql showLineNumbers
schema @http(
dedupe: true
)
```

### path

Refers to the API endpoint, for example, `https://jsonplaceholder.typicode.com/users`.
Expand Down Expand Up @@ -1732,6 +1692,17 @@ schema @server(
Batching can improve performance but may introduce latency if one request in the batch takes longer. It also makes network traffic debugging harder.
:::

### dedupe

A boolean flag, if set to `true`, will enable deduplication of IO operations to enhance performance. This flag prevents duplicate IO requests from being executed concurrently, reducing resource load. If not specified, this feature defaults to `false`.

```graphql showLineNumbers
schema @server(
port: 8000
dedupe: true
)
```

### routes

This optional field allows you to customize the server's endpoint paths, enabling you to override the default values for the GraphQL and status endpoints. If not specified, the following default paths will be used:
Expand Down
Loading