Cannot return null for non-nullable field #2465
Unanswered
theprantadutta
asked this question in
Q&A
Replies: 1 comment 5 replies
-
This is not comming from MikroORM, if you want to report bugs in here, please don't use GQL for reproductions so it is easier to understand. Looking at your code, I found one issue in the entity definition. If you do not use ts-morph metadata provider, you need to adjust this one: @Field(() => Category)
@ManyToOne(() => Category, { wrappedReference: true }) // added wrappedReference
category!: IdentifiedReference<Category> As with the default metadata provider this information needs to be passed explicitly. Other ideas:
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
I am trying to make a Graphql server with Mikro-ORM. Basically, I have a one-to-many relationship with category and product. Each product should belong to a category and a category can have multiple products. Now I am trying to fetch all the products with their categories and I am having the following error.
Stack trace
To Reproduce
Steps to reproduce the behavior:
This works perfectly fine. No errors.
But when I try to get all products with their categories like the following:
Or with left join
I got the error described above.
Here's the generated query.
I also tried to run this query in the database and I got the actual result that I wanted. But in GraphQL Server, I got the above error. What am I doing wrong here?
Expected behavior
I want it return my products like the following:
Additional context
You can check out my code for getting all categories too. That's working fine. But I can't get my products.
Versions
Beta Was this translation helpful? Give feedback.
All reactions