> ## Documentation Index
> Fetch the complete documentation index at: https://docs.transmissions.wtf/llms.txt
> Use this file to discover all available pages before exploring further.

# customQuery

> Execute a custom query on the subgraph

<Tip>
  Check out the [sdk quickstart guide](/sdk/quickstart) for help setting up your client.
</Tip>

## Usage

<CodeGroup>
  ```typescript app.ts theme={null}
  import { downlinkClient } from './config'

  const data = await downlinkClient.customQuery({ ... })
  ```

  ```typescript config.ts theme={null}
  import { TransmissionsClient } from '@tx-kit/sdk'
  import { BASE_MAINNET_SUBGRAPH_URL } from '@tx-kit/sdk/constants'
  import { CreatePublicClient, CreateWalletClient } from 'viem'
  import { base } from 'viem/chains'


  const publicClient = createPublicClient({
      chain: base,
      transport: http()
  })

  const walletClient = createWalletClient({
      account, // from local private key or browser wallet
      chain: base,
      transport: http()
  })

  export const { downlinkClient } = new TransmissionsClient({
      publicClient,
      walletClient,
      chain: base,
      apiConfig: {
          serverUrl: BASE_MAINNET_SUBGRAPH_URL
      }
  })
  ```
</CodeGroup>

## Returns

`any`

## Parameters

### query

* **type**: `DocumentNode`

The query to execute.

```typescript theme={null}
import { TokenFragment } from "@tx-kit/sdk/subgraph"

const data = await downlinkClient.customQuery({
    gql`
        query {
            channels(limit: 10) {
                id
                tokens(first: 10) {
                    ...TokenFragment
                }
            }   
            ${TOKEN_FRAGMENT}
        }`,
    ...
})
```

### variables (optional)

* **type**: `GqlVariables`

Variables to pass to the query

```typescript theme={null}
type GqlVariables = {
    [key: string]: string | number | boolean | undefined | string[] | object
}
```

```typescript theme={null}
const data = await downlinkClient.customQuery(
    gql`
        query($timestamp: Int!) {
            channels(
                where: { tokens_: { blockTimestamp_gt: $timestamp } }
                limit: 10
            ) {
                id
                tokens(first: 10) {
                    ...TokenFragment
                }
            }   
            ${TOKEN_FRAGMENT}
        }`,
    { timestamp: Math.floor(Date.now() / 1000) - 60 * 60 * 24 * 7 } // 1 week
)
```
