This is follow up question on Querying wordpress with meta queries from Gatsby
After a bit debugging I've gathered, and please correct me if I'm wrong, that Gatsby on build downloads the entire data structure and caches it. So all the GraphQL queries are performed against the cache. This makes all adjustments I try to make to wordpress (for example https://www.wpgraphql.com/2020/04/14/query-posts-based-on-advanced-custom-field-values-by-registering-a-custom-where-argument/) useless. I'm confined to using the filter argument for my GraphQL queries in Gatsby.
Consider the following query:
query Test {
allWpPage(filter: {pagesGeo: {}}) {
edges {
node {
pagesGeo {
genericPage {
... on WpPage {
id
}
}
hreflangValue
}
}
}
}
}
In this case I want to filter on genericPage, but it's not in the list of available filters in the GraphiQL query tester.
In Wordpress the custom field generic_page is defined with the help of advanced custom fields and it's of the field type 'Post Object'. As you can see I'm able to query the field just fine, and it would be easy for me to create a meta query in Wordpress to filter on the field. It would looks something like:
$query_args['meta_query'] = [
"relation" => "OR",
[
'key' => 'generic_page',
'value' => $postObjectId,
'compare' => '='
],
[
'key' => 'generic_page',
'value' => $postObjectId2,
'compare' => '='
],
];
Is there a way to make it possible for me to filter on genericPage in Gatsby?
If not, are there any alternative solutions for me to extract the data I need?