Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drupal-graphql/graphql#1324: Make sure that plugin doesn't process non entity routes #1325

Open
wants to merge 3 commits into
base: 8.x-4.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Plugin/GraphQL/DataProducer/Routing/RouteEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ public function __construct(
* The GraphQL field context.
*/
public function resolve($url, ?string $language, FieldContext $context): ?Deferred {
if ($url instanceof Url) {
[, $type] = explode('.', $url->getRouteName());
if ($url instanceof Url && $url->isRouted()) {
[$route_type, $type] = explode('.', $url->getRouteName());
// Check that this route is actually an entity route and make sure that
// entity type is not empty.
if ($route_type !== 'entity' || empty($type)) {
return NULL;
}
$parameters = $url->getRouteParameters();
$id = $parameters[$type];
$resolver = $this->entityBuffer->add($type, $id);
Expand Down