# @medusajs/query

> Medusa remote query and joiner

Latest version **2.22.0** (published 2026-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @medusajs/query
pnpm add @medusajs/query
yarn add @medusajs/query
bun add @medusajs/query
```

## Health

**Score 80/100 (A)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.22.0 |
| Published | 2026-10-21 |
| First published | 2026-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.22.0 |
| Dependencies | 2 |
| Unpacked size | 344.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 36431 |
| Author | Medusa |
| Maintainers | sebrindom, oliverjuhl, nicolas-gorga, sradevski, olijuhl, shahednasser |

## Links

- npm: https://www.npmjs.com/package/@medusajs/query
- Repository: https://github.com/medusajs/medusa
- Homepage: https://github.com/medusajs/medusa#readme
- Issues: https://github.com/medusajs/medusa/issues
- npm.io page: https://npm.io/package/@medusajs/query

## Dependencies (2)

- [@medusajs/deps](https://npm.io/package/@medusajs/deps.md) 2.22.0
- [@medusajs/utils](https://npm.io/package/@medusajs/utils.md) 2.22.0

## Recent versions

- 2.22.0 (latest) — 2026-10-21
- 2.22.0-snapshot-20261021091347 (snapshot) — 2026-10-21
- 2.22.0-preview-20261020134424 (preview) — 2026-10-20
- 2.22.0-snapshot-20261020204851 — 2026-10-20
- 2.22.0-snapshot-20261020140411 — 2026-10-20
- 2.22.0-snapshot-20261020130711 — 2026-10-20
- 2.22.0-snapshot-20261019210621 — 2026-10-19
- 2.22.0-snapshot-20261019163142 — 2026-10-19
- 2.22.0-snapshot-20261019151241 — 2026-10-19
- 2.22.0-snapshot-20261016081036 — 2026-10-16
- 2.22.0-snapshot-20261008225942 — 2026-10-08
- 2.22.0-snapshot-20261008220405 — 2026-10-08
- 2.22.0-snapshot-20261008144129 — 2026-10-08
- 2.22.0-snapshot-20261006025321 — 2026-10-06
- 2.22.0-preview-20261002101246 — 2026-10-02
- … 89 more at https://npm.io/package/@medusajs/query/versions

## README

<p align="center">
  <a href="https://www.medusajs.com">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/59018053/229103275-b5e482bb-4601-46e6-8142-244f531cebdb.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
    <img alt="Medusa logo" src="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
    </picture>
  </a>
</p>
<h1 align="center">
  @medusajs/query
</h1>

<h4 align="center">
  <a href="https://docs.medusajs.com">Documentation</a> |
  <a href="https://www.medusajs.com">Website</a>
</h4>

<p align="center">
  Building blocks for digital commerce
</p>
<p align="center">
  <a href="https://github.com/medusajs/medusa/blob/develop/LICENSE">
    <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Medusa is released under the MIT license." />
  </a>
  <a href="https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md">
    <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs welcome!" />
  </a>
  <a href="https://discord.gg/xpCwq3Kfn8">
    <img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Discord Chat" />
  </a>
  <a href="https://twitter.com/intent/follow?screen_name=medusajs">
    <img src="https://img.shields.io/twitter/follow/medusajs.svg?label=Follow%20@medusajs" alt="Follow @medusajs" />
  </a>
</p>

Query and Remote Joiner for Medusa: the engine behind Query, which retrieves data across modules and their links in a single call. You don't import this package directly in a Medusa application; resolve Query from the Medusa container with `ContainerRegistrationKeys.QUERY` (`"query"`), or use `useQueryGraphStep` from `@medusajs/medusa/core-flows` inside workflows.

## At a glance

| | |
| --- | --- |
| Package | `@medusajs/query` |
| Type | Core library |
| Import from | Resolved from the container as `ContainerRegistrationKeys.QUERY` (`"query"`) |

## Features

- `query.graph()` to retrieve records of a data model and their linked records from other modules.
- `query.index()` to filter across linked modules using the Index Module.
- `query.search()` to run search queries through the Search Module.
- `RemoteJoiner`, which resolves and joins data across module services.

## Installation

No separate installation is needed in a Medusa application. It's installed with `@medusajs/framework` through `@medusajs/modules-sdk`.

## Usage

```ts
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"

export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
  const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)

  const { data: products } = await query.graph({
    entity: "product",
    fields: ["id", "title", "variants.*"],
  })

  res.json({ products })
}
```

## Resources

- [Query](https://docs.medusajs.com/learn/fundamentals/query)
- [Query with the Index Module](https://docs.medusajs.com/learn/fundamentals/query/index-module)
- [Query search](https://docs.medusajs.com/learn/fundamentals/query/search)

---
_Source: https://npm.io/package/@medusajs/query · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
