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

[GraphQl] OneToMany without Doctrine #3542

Closed
MartkCz opened this issue May 4, 2020 · 2 comments
Closed

[GraphQl] OneToMany without Doctrine #3542

MartkCz opened this issue May 4, 2020 · 2 comments

Comments

@MartkCz
Copy link
Contributor

MartkCz commented May 4, 2020

API Platform version(s) affected: current dev-master

/**
 * @ApiResource()
 */
final class Timeline
{

	/**
	 * @var PostUnion[]|PaginatorInterface
	 */
	public iterable $posts;

}
/**
 * @ApiResource()
 */
final class PostUnion
{

	public string $type;

	public ?string $subject;

	public string $content;

}

I'm getting IterableConnection instead of PostUnionConnection.

The goal is:

$timeline = new Timeline();
$timeline->posts = new ApiPlatform\Core\Bridge\Doctrine\Orm\Paginator($postPaginator);

return $timeline;

Any suggestion or it's bug?

@mxmp210
Copy link

mxmp210 commented Jun 1, 2020

Use PostUnion[] | Collection as variable type.

You will also need to hydrate collectionand return it with ArrayPaginator instance from your data provider in order to work with GraphQL as simple arrays are not supported with graphql for pagination purposes.

@alanpoulain
Copy link
Member

Fixed by #3591.

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

No branches or pull requests

3 participants