useRemoteQueryStep - Helper Steps API Reference

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

Example#

To retrieve a list of records of a data model:

Code
1import {2  createWorkflow3} from "@medusajs/framework/workflows-sdk"4import {5  useRemoteQueryStep6} from "@medusajs/medusa/core-flows"7
8const helloWorldWorkflow = createWorkflow(9  "hello-world",10  () => {11    const products = useRemoteQueryStep({12      entry_point: "product",13      fields: [14        "*",15        "variants.*"16      ]17    })18  }19)

To retrieve a single item instead of a an array:

Code
1import {2  createWorkflow3} from "@medusajs/framework/workflows-sdk"4import {5  useRemoteQueryStep6} from "@medusajs/core-flows"7
8const helloWorldWorkflow = createWorkflow(9  "hello-world",10  () => {11    const product = useRemoteQueryStep({12      entry_point: "product",13      fields: [14        "*",15        "variants.*"16      ],17      variables: {18        filters: {19          id: "123"20        }21      },22      list: false23    })24  }25)

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

Code
1import {2  createWorkflow3} from "@medusajs/framework/workflows-sdk"4import {5  useRemoteQueryStep6} from "@medusajs/core-flows"7
8const helloWorldWorkflow = createWorkflow(9  "hello-world",10  () => {11    const product = useRemoteQueryStep({12      entry_point: "product",13      fields: [14        "*",15        "variants.*"16      ],17      variables: {18        filters: {19          id: "123"20        }21      },22      list: false,23      throw_if_key_not_found: true24    })25  }26)

Input#

EntryStepInput | ServiceStepInputEntryStepInput | ServiceStepInput
Was this page helpful?