Path.php in GraphQL 8.3
File
modules/graphql_core/src/Plugin/GraphQL/Fields/Routing/Path.php
View source
<?php
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Routing;
use Drupal\Core\Url;
use Drupal\graphql\GraphQL\Cache\CacheableValue;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
use GraphQL\Type\Definition\ResolveInfo;
class Path extends FieldPluginBase {
public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
if ($value instanceof Url) {
$url = $value
->toString(TRUE);
(yield new CacheableValue($url
->getGeneratedUrl(), [
$url,
]));
}
}
}
Classes
Name |
Description |
Path |
Plugin annotation
@GraphQLField(
id = "url_path",
secure = true,
name = "path",
description = @Translation("The processed url path."),
type = "String",
response_cache_contexts = {"languages:language_url"},
parents = {"Url"}
) |