@@ -12,14 +12,83 @@ import { TypeList, WorkflowDiagram } from "docs-ui"
1212
1313This documentation provides a reference to the ` useQueryGraphStep ` . It belongs to the ` @medusajs/medusa/core-flows ` package.
1414
15- ## Type Parameters
15+ This step fetches data across modules using the Query.
1616
17- < TypeList types = { [{ " name " : " TEntry " , " type " : " `string` " , " description " : " " , " optional " : true , " defaultValue " : " " , " expandable " : false , " children " :[]}] } expandUrl = " https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation " sectionTitle = " useQueryGraphStep " />
17+ Learn more in the [ Query documentation ] ( https://docs.medusajs.com/learn/fundamentals/module-links/query ) .
1818
19- ## Parameters
19+ ## Example
2020
21- <TypeList types={[{"name":"input","type":"[UseQueryGraphStepInput](../../../../types/core_flows.UseQueryGraphStepInput/page.mdx)<TEntry>","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"options","type":"[RemoteJoinerOptions](../../../../../types/interfaces/types.RemoteJoinerOptions/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"throwIfKeyNotFound","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"throwIfRelationNotFound","type":"`boolean` \\| `string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"initialData","type":"`object` \\| `object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"initialDataOnly","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="useQueryGraphStep"/>
21+ To retrieve a list of records of a data model:
2222
23- ## Returns
23+ ``` ts
24+ const { data : products } = useQueryGraphStep ({
25+ entity: " product" ,
26+ fields: [
27+ " *" ,
28+ " variants.*"
29+ ]
30+ })
31+ ```
2432
25- <TypeList types={[{"name":"ReturnType","type":"ReturnType<[StepFunction](../../../../../workflows/types/workflows.StepFunction/page.mdx)<[UseQueryGraphStepInput](../../../../types/core_flows.UseQueryGraphStepInput/page.mdx)<TEntry>, [GraphResultSet](../../../../../types/ModulesSdkTypes/types/types.ModulesSdkTypes.GraphResultSet/page.mdx)<TEntry>>>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"UseQueryGraphStepInput","type":"[UseQueryGraphStepInput](../../../../types/core_flows.UseQueryGraphStepInput/page.mdx)<TEntry>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]},{"name":"GraphResultSet","type":"[GraphResultSet](../../../../../types/ModulesSdkTypes/types/types.ModulesSdkTypes.GraphResultSet/page.mdx)<TEntry>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="useQueryGraphStep"/>
33+ To retrieve a single item instead of a an array:
34+
35+ ``` ts
36+ const { data : products } = useQueryGraphStep ({
37+ entity: " product" ,
38+ fields: [
39+ " *" ,
40+ " variants.*"
41+ ],
42+ filters: {
43+ id: " 123"
44+ }
45+ })
46+ ```
47+
48+ To throw an error if a record isn't found matching the specified ID:
49+
50+ ``` ts
51+ const { data : products } = useQueryGraphStep ({
52+ entity: " product" ,
53+ fields: [
54+ " *" ,
55+ " variants.*"
56+ ],
57+ filters: {
58+ id: " 123"
59+ },
60+ options: {
61+ throwIfKeyNotFound: true
62+ }
63+ })
64+ ```
65+
66+ To set pagination configurations:
67+
68+ ``` ts
69+ const { data : products } = useQueryGraphStep ({
70+ entity: " product" ,
71+ fields: [
72+ " *" ,
73+ " variants.*"
74+ ],
75+ filters: {
76+ id: " 123"
77+ },
78+ pagination: {
79+ take: 10 ,
80+ skip: 10 ,
81+ order: {
82+ created_at: " DESC"
83+ }
84+ }
85+ })
86+ ```
87+
88+ ## Input
89+
90+ <TypeList types = { [{" name" :" UseQueryGraphStepInput" ," type" :" [UseQueryGraphStepInput](../../../../types/core_flows.UseQueryGraphStepInput/page.mdx)<TEntry>" ," optional" :false ," defaultValue" :" " ," description" :" " ," expandable" :false ," children" :[]}]} expandUrl = " https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel = { 1 } sectionTitle = " useQueryGraphStep" />
91+
92+ ## Output
93+
94+ <TypeList types = { [{" name" :" GraphResultSet" ," type" :" [GraphResultSet](../../../../../types/ModulesSdkTypes/types/types.ModulesSdkTypes.GraphResultSet/page.mdx)<TEntry>" ," optional" :false ," defaultValue" :" " ," description" :" " ," expandable" :false ," children" :[]}]} expandUrl = " https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel = { 1 } sectionTitle = " useQueryGraphStep" />
0 commit comments