Skip to content

fix(graphql): always allow to query nested resources#5112

Merged
soyuka merged 2 commits into
api-platform:3.0from
soyuka:fix/graphql-nested-resource-operation
Nov 4, 2022
Merged

fix(graphql): always allow to query nested resources#5112
soyuka merged 2 commits into
api-platform:3.0from
soyuka:fix/graphql-nested-resource-operation

Conversation

@soyuka

@soyuka soyuka commented Nov 3, 2022

Copy link
Copy Markdown
Member

Rework of #5102

Comment thread src/GraphQl/Metadata/Factory/GraphQlNestedOperationResourceMetadataFactory.php Outdated
Comment thread src/GraphQl/Type/FieldsBuilder.php Outdated
Comment thread src/GraphQl/Type/TypeBuilderInterface.php
Comment thread src/Metadata/Resource/Factory/OperationDefaultsTrait.php
Comment thread src/Metadata/Resource/Factory/OperationDefaultsTrait.php Outdated
Comment thread src/Metadata/Resource/Factory/OperationDefaultsTrait.php
Comment thread src/Symfony/Bundle/Resources/config/metadata/resource.xml Outdated
<argument type="service" id="api_platform.pagination" />
<argument type="service" id="api_platform.name_converter" on-invalid="ignore" />
<argument>%api_platform.graphql.nesting_separator%</argument>
<argument type="service" id="api_platform.graphql_metadata.resource.metadata_collection_factory" on-invalid="ignore"></argument>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<argument type="service" id="api_platform.graphql_metadata.resource.metadata_collection_factory" on-invalid="ignore"></argument>
<argument type="service" id="api_platform.graphql_metadata.resource.metadata_collection_factory" on-invalid="ignore" />

Comment thread tests/GraphQl/Type/FieldsBuilderTest.php Outdated
@soyuka
soyuka force-pushed the fix/graphql-nested-resource-operation branch 3 times, most recently from 432ff12 to e38414d Compare November 4, 2022 15:28
<argument type="service" id="api_platform.pagination" />
<argument type="service" id="api_platform.name_converter" on-invalid="ignore" />
<argument>%api_platform.graphql.nesting_separator%</argument>
<argument type="service" id="api_platform.graphql_metadata.resource.metadata_collection_factory" on-invalid="ignore" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the on-invalid is necessary.

@soyuka
soyuka force-pushed the fix/graphql-nested-resource-operation branch from e38414d to 2a75c00 Compare November 4, 2022 15:49
@soyuka
soyuka merged commit bbeaf70 into api-platform:3.0 Nov 4, 2022
@soyuka
soyuka deleted the fix/graphql-nested-resource-operation branch November 4, 2022 15:58
soyuka added a commit that referenced this pull request Nov 4, 2022
* fix: update yaml extractor test file coding standard (#5068)

* fix(graphql): add clearer error message when TwigBundle is disabled but graphQL clients are enabled (#5064)

* fix(metadata): add class key in payload argument resolver (#5067)

* fix: add class key in payload argument resolver

* add null if everything else goes wrong

* fix: upgrade command remove ApiSubresource attribute  (#5049)

Fixes #5038

* fix(doctrine): use abitrary index instead of value (#5079)

* fix: uri template should respect rfc 6570 (#5080)

* fix: remove @internal annotation for Operations (#5089)

See #5084

* fix(metadata): define a name on a single operation (#5090)

fixes #5082

* fix(metadata): deprecate when user decorates in legacy mode (#5091)

fixes #5078

* fix(graphql): use right nested operation (#5102)

* Revert "fix(graphql): use right nested operation (#5102)" (#5111)

This reverts commit 44337dd.

* fix(graphql): always allow to query nested resources (#5112)

* fix(graphql): always allow to query nested resources

* review

Co-authored-by: Alan Poulain <contact@alanpoulain.eu>

* chore: php-cs-fixer update

* fix: only alias if exists for opcache preload

Fixes api-platform/api-platform#2284 (#5110)

Co-authored-by: Liviu Mirea <liviu.mirea@wecodepixels.com>

* chore: php-cs-fixer update (#5118)

* chore: php-cs-fixer update

* chore: php-cs-fixer update

* fix(metadata): upgrade script keep operation name (#5109)

origin: #5105

Co-authored-by: WilliamPeralta <william.peralta18@gmail.com>

* chore: v2.7.3 changelog

* chore: v3.0.3 changelog

Co-authored-by: helyakin <CourcierMarvin@gmail.com>
Co-authored-by: ArnoudThibaut <thibaut.arnoud@gmail.com>
Co-authored-by: davy-beauzil <38990335+davy-beauzil@users.noreply.github.com>
Co-authored-by: Baptiste Leduc <baptiste.leduc@gmail.com>
Co-authored-by: Xavier Laviron <norival@users.noreply.github.com>
Co-authored-by: Alan Poulain <contact@alanpoulain.eu>
Co-authored-by: Liviu Cristian Mirea-Ghiban <contact@liviucmg.com>
Co-authored-by: Liviu Mirea <liviu.mirea@wecodepixels.com>
Co-authored-by: WilliamPeralta <william.peralta18@gmail.com>
Comment on lines +54 to +61
if (class_exists($resourceClass)) {
$refl = new \ReflectionClass($resourceClass);
$attribute = $refl->getAttributes(ApiResource::class)[0] ?? null;
$attributeInstance = $attribute?->newInstance();
if ($filters = $attributeInstance?->getFilters()) {
$apiResource = $apiResource->withFilters($filters);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This should work with XML/YAML too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants