no-wildcard-with-specific-fields - ESLint plugin rules

This rule disallows combining the * wildcard with specific top-level fields in a query.graph or useQueryGraphStep field selection, because * silently drops those specific field selections.

Note: This rule is available since Medusa v2.18.0.

Severity#

warn. This rule is enabled in the recommended preset.

What it Targets#

This rule targets usages of query.graph and useQueryGraphStep anywhere in your project. It reports a fields array that contains both the * wildcard and one or more specific top-level fields.

The following code is reported by the rule:

src/workflows/example.ts
1const { data } = await query.graph({2  entity: "cart",3  fields: ["*", "total"],4})

Remove the specific top-level fields if you want all of the entity's own fields, since * already selects them:

Important: It's highly discouraged to use * in production code, as it can lead to performance issues with large data models. It's better to explicitly list the fields you need.
src/workflows/example.ts
1const { data } = await query.graph({2  entity: "cart",3  fields: ["*"],4})

Or remove * and list only the fields you need, including any computed fields:

src/workflows/example.ts
1const { data } = await query.graph({2  entity: "cart",3  fields: ["id", "total", "subtotal"],4})

Relation selections such as items.* or items.title are not affected by this rule. They are scoped to a relation and are kept even when * is present, so the following is valid:

src/workflows/example.ts
1const { data } = await query.graph({2  entity: "cart",3  fields: ["*", "items.*", "items.title"],4})

Why it's Important#

The * wildcard selects all of an entity's own scalar fields. It does not include computed fields such as total or subtotal. When you combine * with a specific top-level field like "total", the specific field is silently ignored and the response won't contain it.

Listing only the fields you need, without *, is the safest approach when you require computed or non-default fields.

Fixable#

This rule isn't auto-fixable.

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/no-wildcard-with-specific-fields": "off",9    },10  },11])

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

Code
1// eslint-disable-next-line @medusajs/no-wildcard-with-specific-fields2const { data } = await query.graph({ entity: "cart", fields: ["*", "total"] })
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
⇧↵