> For the complete documentation index, see [llms.txt](https://superd001.gitbook.io/autorelay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://superd001.gitbook.io/autorelay/pagination-1/relayd-query.md).

# Relay'd Query

Similarly we might need to paginate a `Query` field using AutoRelay but have complete control over the business logic and fetching. AutoRelay offers `@RelayedQuery` for that.

```typescript
@Resolver(of => User)
export class UserResolver {

  constructor(
    protected readonly userRepository: Repository<User>
  )

  @RelayedQuery(() => User)
  async users(
    @RelayLimitOffset() {limit, offset}: RelayLimitOffsetArgs
  ): Promise<[number, User[]]> {
    return this.userRepository.findAndCount({ 
      where: { 
        // any business logic you might have
      },
      skip: offset,
      take: limit
    })
  }

}
```

Notice the API is exactly the same as `@RelayedFieldResolver`. Just like in vanilla type-graphql `@RelayedQuery` is nothing more than an alias for calling `@RelayedFieldResolver` on a field of the `Query` Object.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://superd001.gitbook.io/autorelay/pagination-1/relayd-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
