Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(graphql): nested collection for mongo#6174

Merged
soyuka merged 2 commits into
api-platform:mainfrom
jotwea:6038-mongodb
Mar 15, 2024
Merged

fix(graphql): nested collection for mongo#6174
soyuka merged 2 commits into
api-platform:mainfrom
jotwea:6038-mongodb

Conversation

@jotwea
Copy link
Copy Markdown
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.

Comment thread src/GraphQl/Resolver/Factory/ResolverFactory.php Outdated
Comment thread tests/Fixtures/TestBundle/Document/MultiRelationsNestedPaginated.php Outdated
@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
Copy Markdown
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.

Comment thread features/graphql/query.feature
Comment thread docs/public/index.php
public function getNestedCollection(): Collection
{
return $this->nestedCollection;
return $this->nestedCollection->map(fn ($entry) => ['name' => $entry->name]);
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 fond of this why is this necessary?

Copy link
Copy Markdown
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
@soyuka
Copy link
Copy Markdown
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