graphql_data_is_private
not getting called
#2518
-
The code block below has been added to my theme's Everything works as expected when the a Post is published as "public". But if I publish a post as "private" the functions.php error_log('>>>>>>>>>>>>> call graphql_data_is_private >>>>>>>>>>>>>>>>');
add_filter(
'graphql_data_is_private',
function( $is_private, $model_name, $data, $visibility, $owner, $current_user ) {
error_log('>>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>');
return false;
},
10,
6
); error.log
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@lance-anderson what's an example of a query that you're executing and expecting to see that log? |
Beta Was this translation helpful? Give feedback.
-
@lance-anderson if I add your code like so: add_action( 'init', function() {
error_log('>>>>>>>>>>>>> call graphql_data_is_private >>>>>>>>>>>>>>>>');
add_filter(
'graphql_data_is_private',
function( $is_private, $model_name, $data, $visibility, $owner, $current_user ) {
error_log('>>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>');
return false;
},
10,
6
);
}); Then execute the following query: {
posts {
nodes {
id
title
}
}
} I see the following output in my error log: [21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> call graphql_data_is_private >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>>
[21-Sep-2022 20:57:35 UTC] >>>>>>>>>>>>> graphql_data_is_private callback >>>>>>>>>>>>>>>> The first error log is called on If you're querying something that doesn't load a Model, then that filter wouldn't be executed. An introspection query, for example, wouldn't try to load a model. Currently queries for settings, such as: {
generalSettings {
url
}
} also do not load a model and would not execute this filter. |
Beta Was this translation helpful? Give feedback.
@lance-anderson if I add your code like so:
Then execute the following query:
I see the following output in my error log: