-
-
Notifications
You must be signed in to change notification settings - Fork 900
fix(graphql): use right nested operation #5102
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ public function getNodeInterface(): InterfaceType | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getResourcePaginatedCollectionType(GraphQLType $resourceType, string $resourceClass, Operation $operation): GraphQLType | ||
public function getResourcePaginatedCollectionType(GraphQLType $resourceType, Operation $operation): GraphQLType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BC layer is broken |
||
{ | ||
$shortName = $resourceType->name; | ||
$paginationType = $this->pagination->getGraphQlPaginationType($operation); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ public function getNodeInterface(): InterfaceType; | |
/** | ||
* Gets the type of a paginated collection of the given resource type. | ||
*/ | ||
public function getResourcePaginatedCollectionType(GraphQLType $resourceType, string $resourceClass, Operation $operation): GraphQLType; | ||
public function getResourcePaginatedCollectionType(GraphQLType $resourceType, Operation $operation): GraphQLType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't change an interface like this right? |
||
|
||
/** | ||
* Returns true if a type is a collection. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Metadata\Extractor; | ||
|
||
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; | ||
|
||
/** | ||
* Extracts a dynamic resource (used by GraphQL for nested resources). | ||
* | ||
* @author Alan Poulain <[email protected]> | ||
*/ | ||
final class DynamicResourceExtractor implements DynamicResourceExtractorInterface | ||
{ | ||
private array $dynamicResources = []; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getResources(): array | ||
{ | ||
return $this->dynamicResources; | ||
} | ||
|
||
public function addResource(string $resourceClass, array $config = []): string | ||
{ | ||
$dynamicResourceName = $this->getDynamicResourceName($resourceClass); | ||
|
||
$this->dynamicResources[$dynamicResourceName] = [ | ||
array_merge(['class' => $resourceClass], $config), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. array_merge is quite slow for this we could just add the class to the config right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it doesn't impact performance but we can. |
||
]; | ||
|
||
return $dynamicResourceName; | ||
} | ||
|
||
private function getDynamicResourceName(string $resourceClass): string | ||
{ | ||
return ResourceMetadataCollection::DYNAMIC_RESOURCE_CLASS_PREFIX.$resourceClass; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Metadata\Extractor; | ||
|
||
/** | ||
* Extracts a dynamic resource (used by GraphQL for nested resources). | ||
* | ||
* @author Alan Poulain <[email protected]> | ||
*/ | ||
interface DynamicResourceExtractorInterface extends ResourceExtractorInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need to add a new interface? its wanted that a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need an interface since this method needs to be called from the fields builder. |
||
{ | ||
public function addResource(string $resourceClass, array $config = []): string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
breaks BC layer