Loading consumer_base_url.module +16 −10 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Routing\RouteObjectInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Symfony\Component\HttpFoundation\Request; /** * Implements hook_entity_base_field_info(). Loading Loading @@ -87,10 +88,13 @@ function consumer_base_url_tokens_alter(array &$replacements, array $context, Bu /** * Helper function to detect GraphQL requests. * * @param \Symfony\Component\HttpFoundation\Request|null $request * The HttpRequest object representing the current request. * * @return bool * Return TRUE if request is a GraphQL query. */ function consumer_base_url_is_graphql_request():bool { function consumer_base_url_is_graphql_request(Request $request = NULL): bool { static $drupal_static_fast; if (!isset($drupal_static_fast)) { $drupal_static_fast['is_graphql_request'] = &drupal_static(__FUNCTION__); Loading @@ -98,17 +102,19 @@ function consumer_base_url_is_graphql_request():bool { $is_graphql_request = &$drupal_static_fast['is_graphql_request']; if (!isset($is_graphql_request)) { $graphql_routes = [ 'graphql.query.default:default', 'graphql.explorer.default:default', 'graphql.voyager.default:default', ]; $is_graphql_request = FALSE; if (is_null($request)) { $request = \Drupal::request(); $route_name = $request->attributes->get(RouteObjectInterface::ROUTE_NAME); $is_apollo = $request->query->get('extensions'); if (in_array($route_name, $graphql_routes) || $is_apollo) { } if ($request && ( $request->attributes->has('_graphql_subrequest') || $request->attributes->has('_graphql') ) ) { $is_graphql_request = TRUE; } } Loading src/HttpKernel/ConsumerPathProcessor.php +1 −4 Original line number Diff line number Diff line Loading @@ -70,10 +70,7 @@ class ConsumerPathProcessor implements OutboundPathProcessorInterface { } // Do not change Base URL in GraphQL 4.x and 3.x requests. if ($request && ($request->attributes->has('_graphql_subrequest') || $request->attributes->has('_graphql')) ) { if (consumer_base_url_is_graphql_request($request)) { return $path; } Loading Loading
consumer_base_url.module +16 −10 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Routing\RouteObjectInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Symfony\Component\HttpFoundation\Request; /** * Implements hook_entity_base_field_info(). Loading Loading @@ -87,10 +88,13 @@ function consumer_base_url_tokens_alter(array &$replacements, array $context, Bu /** * Helper function to detect GraphQL requests. * * @param \Symfony\Component\HttpFoundation\Request|null $request * The HttpRequest object representing the current request. * * @return bool * Return TRUE if request is a GraphQL query. */ function consumer_base_url_is_graphql_request():bool { function consumer_base_url_is_graphql_request(Request $request = NULL): bool { static $drupal_static_fast; if (!isset($drupal_static_fast)) { $drupal_static_fast['is_graphql_request'] = &drupal_static(__FUNCTION__); Loading @@ -98,17 +102,19 @@ function consumer_base_url_is_graphql_request():bool { $is_graphql_request = &$drupal_static_fast['is_graphql_request']; if (!isset($is_graphql_request)) { $graphql_routes = [ 'graphql.query.default:default', 'graphql.explorer.default:default', 'graphql.voyager.default:default', ]; $is_graphql_request = FALSE; if (is_null($request)) { $request = \Drupal::request(); $route_name = $request->attributes->get(RouteObjectInterface::ROUTE_NAME); $is_apollo = $request->query->get('extensions'); if (in_array($route_name, $graphql_routes) || $is_apollo) { } if ($request && ( $request->attributes->has('_graphql_subrequest') || $request->attributes->has('_graphql') ) ) { $is_graphql_request = TRUE; } } Loading
src/HttpKernel/ConsumerPathProcessor.php +1 −4 Original line number Diff line number Diff line Loading @@ -70,10 +70,7 @@ class ConsumerPathProcessor implements OutboundPathProcessorInterface { } // Do not change Base URL in GraphQL 4.x and 3.x requests. if ($request && ($request->attributes->has('_graphql_subrequest') || $request->attributes->has('_graphql')) ) { if (consumer_base_url_is_graphql_request($request)) { return $path; } Loading