useQueryGraphStep - Medusa Core Workflows Reference

This documentation provides a reference to the useQueryGraphStep. It belongs to the @medusajs/medusa/core-flows package.

This step fetches data across modules using the Query.

Learn more in the Query documentation.

Example#

To retrieve a list of records of a data model:

Code
1const { data: products } = useQueryGraphStep({2  entity: "product",3  fields: [4    "*",5    "variants.*"6  ]7})

To retrieve a single item instead of a an array:

Code
1const { data: products } = useQueryGraphStep({2  entity: "product",3  fields: [4    "*",5    "variants.*"6  ],7  filters: {8    id: "123"9  }10})

To throw an error if a record isn't found matching the specified ID:

Code
1const { data: products } = useQueryGraphStep({2  entity: "product",3  fields: [4    "*",5    "variants.*"6  ],7  filters: {8    id: "123"9  },10  options: {11    throwIfKeyNotFound: true12  }13})

To set pagination configurations:

Code
1const { data: products } = useQueryGraphStep({2  entity: "product",3  fields: [4    "*",5    "variants.*"6  ],7  filters: {8    id: "123"9  },10  pagination: {11    take: 10,12    skip: 10,13    order: {14      created_at: "DESC"15    }16  }17})

Input#

UseQueryGraphStepInputUseQueryGraphStepInput<TEntry>
TEntryTEntry

Output#

GraphResultSetGraphResultSet<TEntry>
TEntryTEntry
Was this page helpful?