I've gut a virtual field, that get's it's data in the afterRead hook
{
name: 'events',
type: 'relationship',
relationTo: 'events',
admin: {
readOnly: true,
},
virtual: true,
hooks: {
afterRead: [
async ({ value, req }) => {
// Format date for display
const events = await req.payload.find({
collection: 'events',
})
return events.docs
},
],
},
},
This is in a block, which will be used in a Blocks field.
In the rest api, I do get the desired output. In the graphql Playground, I get the correct type completion, but the result is null
Am I using the wrong hook? Is this even possible at all with graphql?
Thanks!