Replies: 4 comments
-
Hey @chladog — unfortunately I still can't replicate. I noticed that you are probably automatically filling the I just added a test suite to reflect your exact scenario in the Payload source code, including autofilling the https://github.com/payloadcms/payload/blob/master/test/dataloader/config.ts The new test passes. And here's a screenshot of the query I am making in the test suite: I have a sneaking suspicion that maybe however you're trying to autofill the Can you help me figure out how to take this test and replicate your scenario? To run it, you can:
And then you'll get a dev environment spun up with this exact scenario, which will allow you to play around in GraphQL Playground. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Hi @jmikrut, ofc I wanted to share the repo - my bad. The hook that fills the I also checked the Mongo directly to see that really just the "ID" is stored and it is. |
Beta Was this translation helpful? Give feedback.
-
Ah ok. I see exactly why this is happening now and I fully understand why. So, when your custom resolver is fetching the results, you need to specify I don't think that we should change anything in Payload's source code for this for a few reasons:
Internally, Payload TL;DR: it's going to be more performant for you to specify Is there a reason why you can't specify I'm gonna bump this back to a discussion for now as I don't think there's anything that should be changed at this point internally within Payload. What do you think? |
Beta Was this translation helpful? Give feedback.
-
Yes I see that when I set depth: 0 then everything is working fine, however I'm still confused about the process as I would expect that the depth 0 means no fields except the base document itself get populated.
For my use case now depth:0 is fine, the whole point is that it goes against my mental model and I was mainly afraid that sometimes this gets fixed (by the principle depth:0 = not other fields get populated) and it's gonna break my app. If the current behavior is here to stay then it's fine. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report
This is bug report for issue discussed in #911.
I managed to replicate the error in minimal project. I believe that the problem is that query/dataloader expands relationship fields when it shouldn't at depth 0 and then it tries to expand already expanded fields at proper level causing the type cast error.
Test query:
See comment at
payload.config.ts::75
Expected Behavior
Relationship field objects should get expanded only at their respective depth.
Current Behavior
Relationship field objects get expanded one level sooner.
Steps to Reproduce
Detailed Description
[email protected]
HERE IS THE REPO: https://github.com/chladog/payload-chladog-bug-replicator
Beta Was this translation helpful? Give feedback.
All reactions