Are you able to de-reference relationship objects when querying them? As in, can I have a relationship field wherein I query that field directly and then de-reference the result to get the data from the "related" documents in the order they appear in the relationship field?
I'm essentially trying to create hard-linked, drag & drop ordering of specific documents, as opposed to sorting by an arbitrary field on said documents. Is there a better way to do this without creating another field on the related documents? (wow I said "documents" a lot, sorry if this was confusing I hope I got my point across)
a relationship field wherein I query that field directly and then de-reference the result to get the data from the "related" documents in the order they appear in the relationship field
Just trying to understand - wouldn't increasing the "depth" in your query do that?
Is that what the query depth does? I'm honestly not familiar with how that works. Is this a GraphQL thing or a Payload thing? I'd assume a Payload thing and I will look into that if you think that could accomplish what I want here. That may be what I'm looking for
Oh, yeah, I see this now:
https://payloadcms.com/docs/getting-started/concepts#depth. That's awesome
depth makes sure to populate the relationship's data instead of just displaying its ID - it's a payload thing. It's meant to be used in the Rest API and not GraphQL, though
depth makes sure to populate the relationship's data instead of just displaying its ID - it's a payload thing
Yeah, that's awesome!
It's meant to be used in the Rest API and not GraphQL, though
This, however, is unfortunate since I'm only using GraphQL and have a whole abstracted system based entirely on fetching my content via GraphQL. Is it possible to specify this in the field config object and then query with GraphQL? I know you can set
maxDepth
in some places, but can you just set
depth
on a field level and have that apply to every query?
but can you just set depth on a field level and have that apply to every query?
Oh correct me if I'm wrong but I don't think so. Not sure if it would make a lot of sense for GraphQL there. Why not just specify all fields for that relationship which you need, so GraphQL populates those?
Would it work to just specify those fields? Would GraphQL essentially de-reference the relationship then?
yup!
Oh sweet, that's the answer I needed then, thanks! Is that a GraphQL thing or is that behavior implemented by Payload?
good question actually! Prob a mix of both but I've never looked at the implementation
Thanks so much for your help, I verified this will work for my purposes!
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.