use-query-context-utility - ESLint plugin rules

Warning: This rule has been removed as of Medusa v2.18.0 since QueryContext can be applied to nested objects, making it difficult to determine its usage in a linting rule.

This rule requires wrapping context arguments to query.graph or query.index with QueryContext(...) from @medusajs/framework/utils.

Severity#

warn. This rule is enabled in the recommended preset.

What it Targets#

This rule targets all files in your project. It reports a context property passed to query.graph or query.index whose value is a plain object literal instead of a QueryContext(...) call.

The following code is reported by the rule:

src/api/example.ts
1// non-compliant2query.graph({3  entity: "product",4  fields: ["*"],5  context: { region_id: "us" },6})

Instead, wrap the value with QueryContext:

src/api/example.ts
1// compliant2import { QueryContext } from "@medusajs/framework/utils"3
4query.graph({5  entity: "product",6  fields: ["*"],7  context: QueryContext({ region_id: "us" }),8})

Why it's Important#

QueryContext marks values as context passed to relation resolvers, ensuring Query interprets them correctly. Passing a plain object can lead to context values being treated as regular filters.

Learn more in the Query Context documentation.

Fixable#

This rule is auto-fixable. Run the linter with the --fix option to apply the fix automatically.

Turn it Off#

To turn off this rule, set it to off in your ESLint configuration:

eslint.config.ts
1import { defineConfig } from "eslint/config"2import medusa from "@medusajs/eslint-plugin"3
4export default defineConfig([5  ...medusa.configs.recommended,6  {7    rules: {8      "@medusajs/use-query-context-utility": "off",9    },10  },11])

Or disable it for a single line using an inline comment:

Code
1// eslint-disable-next-line @medusajs/use-query-context-utility2  context: { region_id: "us" },
Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵