I have the following query:
const getPage = gql`
query Page($path: String!) {
page(path: $path) @rest(type: "Page", path: "{args.path}") {
blocks @type(name: Block) {
name
posts @type(name: Post) {
body
author
}
}
authors @type(name: Author) {
name
}
}
}
In blocks.posts.author
there's only an AuthorId
. The authors object is containing all the available authors.
I'd like to replace/match the AuthorId
with it's corresponding object. Is it possible to do this within one query?
I also wouldn't mind to have a separate query for Author only (fetch will be cached, no new request would be made), but I still don't know how would I match it through 2 queries.
Example API response
{
blocks: [
{
posts: [
{
id: 1,
title: 'My post',
author: 12,
}
]
}
],
authors: [
{
id: 12,
name: 'John Doe'
}
]
}
What I want with 1 query that author
inside a post
becomes the full author object.