You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have applied filter for this "graphql_require_authentication_allowed_fields". It's from the official documentation for allowing login field from the authentication. But it's not working.
`add_action( 'do_graphql_request', 'force_graphql_api_authentication', 10, 1 );
function force_graphql_api_authentication( $query ) {
if ( ! defined( 'GRAPHQL_HTTP_REQUEST' ) || true !== GRAPHQL_HTTP_REQUEST ) {
return;
}
$introspection_query = \GraphQL\Type\Introspection::getIntrospectionQuery();
$is_introspection_query = trim($query) === trim($introspection_query);
if ( $is_introspection_query ) {
return;
}
if ( ! get_current_user_id() ) {
throw new \GraphQL\Error\UserError( __( 'You do not have permission to access the API', 'preachitgwl' ) );
}
}
add_filter(
'graphql_require_authentication_allowed_fields',
function( $allowed ) {
$allowed[] = 'login';
return $allowed;
}, 10, 1 );`
The text was updated successfully, but these errors were encountered:
I have applied filter for this "graphql_require_authentication_allowed_fields". It's from the official documentation for allowing login field from the authentication. But it's not working.
The text was updated successfully, but these errors were encountered: