Error: Expression produces a union type that is too complex to represent

If you get the following error while using query.graph or useQueryGraphStep:

Terminal
Expression produces a union type that is too complex to represent. ts(2590)

Why this Error Occurred#

This type error may occur when you use Query, but it's only a type error that doesn't affect the functionality of your code. It occurs because the models you're retrieving may be too complicated for the TypeScript compiler to infer the types correctly.


How to Fix it#

You can ignore this error by using the // @ts-ignore directive before the line of code that produces the error. For example:

Was this page helpful?
Ask Anything
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