However, if $data is inspected, it appears the fields have already been fetched. So while the fields don't show up at the REST endpoint, the db queries and php functions to get and format them are still occurring.
So if a post has a certain gallery custom field with a 1000 images, every time that post is accessed via REST, get_field still runs on each image, producing thousands of db calls and php functions to run to get the image objects, even though these are not displayed at the endpoint. That means this filter is not a solution for meaningfully 'excluding a field from REST', because the performance impact still occurs.
Am I misunderstanding something? Is there another filter/mechanism to use to prevent the field from being fetched at all during a rest request? Can the fields be intercepted before the fields are actually fetched or does the plugin just use the blanket get_fields function, so there is no option to meaningfully exclude certain fields and use the plugin? It seems that this would be a major issue if this plugin were to be used to create a data API for medium/large scale applications.
Can someone point me in the right direction? Thanks
We are able to prevent certain fields from showing up in rest using the get_fields filter
add_filter( 'acf/rest_api/user/get_fields', function( $data ) {}
However, if $data is inspected, it appears the fields have already been fetched. So while the fields don't show up at the REST endpoint, the db queries and php functions to get and format them are still occurring.
So if a post has a certain gallery custom field with a 1000 images, every time that post is accessed via REST, get_field still runs on each image, producing thousands of db calls and php functions to run to get the image objects, even though these are not displayed at the endpoint. That means this filter is not a solution for meaningfully 'excluding a field from REST', because the performance impact still occurs.
Am I misunderstanding something? Is there another filter/mechanism to use to prevent the field from being fetched at all during a rest request? Can the fields be intercepted before the fields are actually fetched or does the plugin just use the blanket get_fields function, so there is no option to meaningfully exclude certain fields and use the plugin? It seems that this would be a major issue if this plugin were to be used to create a data API for medium/large scale applications.
Can someone point me in the right direction? Thanks