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

# runQuery()

> Imperatively run an asynchronous GraphQL query

```js theme={"system"}
import {runQuery} from "attio/client"
```

## Parameters

<ParamField path="query" type="string" required>
  A GraphQL query string.

  <Tip>
    If you're using TypeScript and \[default] `import` this value from a `.graphql` or `.gql` file,
    the variables and return value will be strongly typed.

    [Read more](./graphql#typescript-code-generation).
  </Tip>
</ParamField>

<ParamField path="variables" type="Record<string, any>">
  The named variables your query accepts. If your query has no variables, you needn't pass any.
</ParamField>

## Returns

<ResponseField name=" " type="Promise<Record<string, any>>">
  A `Promise` to the structured JSON as defined by your query.
</ResponseField>

## Example

To run multiple GraphQL queries in parallel, use `runQuery()` together with [`useAsyncCache()`](../data-fetching/use-async-cache). Each call to `runQuery()` in the cache definition runs in parallel, and the component suspends until all have completed:

<CodeGroup>
  ```tsx meet-person.tsx theme={"system"}
  import React from "react"
  import {runQuery, TextBlock, useAsyncCache} from "attio/client"
  import getPersonName from "./get-person-name.graphql"
  import getCurrentUser from "./get-current-user.graphql"

  export function MeetPerson({recordId}: {recordId: string}) {
    // Will run in parallel and suspend until both queries have returned
    const {values} = useAsyncCache({
      currentUserResult: async () => await runQuery(getCurrentUser),
      personResult: async () => await runQuery(getPersonName, {recordId}),
    })
    const currentUserName: string = values.currentUserResult.currentUser.name
    const personName: string | null | undefined = values.personResult.person?.name?.full_name

    return (
      <TextBlock>
        {personName ?? "Unknown"} would like to meet with {currentUserName}.
      </TextBlock>
    )
  }
  ```

  ```graphql get-current-user.graphql theme={"system"}
  query getCurrentUser {
    currentUser {
      name
    }
  }
  ```

  ```graphql get-person-name.graphql theme={"system"}
  query getPersonName($recordId: String!) {
    person(id: $recordId) {
      name {
        full_name
      }
    }
  }
  ```
</CodeGroup>
