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

fix(graphql): nested collection for mongo #6174

Merged
merged 2 commits into from Mar 15, 2024

Conversation

jotwea
Copy link
Contributor

@jotwea jotwea commented Feb 22, 2024

Q A
Branch? main
Tickets Closes #6107
License MIT
Doc PR api-platform/docs#...

#6038 was introduced but we had mongodb tests disabled. Though the new scenario has been disabled temporarily for mongo. I activated it again and updated the mongo test fixtures to represent the same case as the ORM ones do.

@jotwea jotwea force-pushed the 6038-mongodb branch 2 times, most recently from fcce827 to 206a83b Compare March 4, 2024 10:48
@jotwea
Copy link
Contributor Author

jotwea commented Mar 4, 2024

@soyuka I am done now with the changes you requested. The failing unit tests are not due to my changes (some deprecation notice). From my perspective this PR could be merged.

features/graphql/query.feature Show resolved Hide resolved
docs/public/index.php Outdated Show resolved Hide resolved
@@ -89,7 +89,7 @@ public function addOneToManyRelation(MultiRelationsRelatedDummy $relatedMultiUse

public function getNestedCollection(): Collection
{
return $this->nestedCollection;
return $this->nestedCollection->map(fn ($entry) => ['name' => $entry->name]);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not fond of this why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this mapping function was neccessary because mongo ODM behaves different like ORM does. The ORM Entity provides a Collection with each entry being an associative array. The ODM Document on the other hand provides a Collection with each entry being an instance of MultiRelationsNested / MultiRelationsNestedPaginated. So my intention here was to align the Testables here to get the same results.

Without this mapper the case for MultiRelationsNestedPaginated gets broken in test. If this is not acceptable for you, you may undo this mapping and find another way - I was not able to.

@soyuka soyuka merged commit bc96751 into api-platform:main Mar 15, 2024
76 of 78 checks passed
@soyuka
Copy link
Member

soyuka commented Mar 15, 2024

If you can add a documentation for that feature it'd be awesome, thanks!

@jotwea jotwea deleted the 6038-mongodb branch April 6, 2024 10:44
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.

GraphQL MongoDB: Nested Collections
2 participants