-
-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(graphql): use right nested operation (#5102)
- Loading branch information
1 parent
a4cd12b
commit 44337dd
Showing
25 changed files
with
446 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
]; | ||
|
||
return $dynamicResourceName; | ||
} | ||
|
||
private function getDynamicResourceName(string $resourceClass): string | ||
{ | ||
return ResourceMetadataCollection::DYNAMIC_RESOURCE_CLASS_PREFIX.$resourceClass; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Metadata/Extractor/DynamicResourceExtractorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
public function addResource(string $resourceClass, array $config = []): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.