Skip to content

GraphQL mapping for custom collections #2687

@Maxell92

Description

@Maxell92

We have several Doctrine entities linked like this: Order contains N boxes, each box contains several tracking numbers. I want to add a getTrackingNumbers method to Order Entity:

/**
 * @ApiResource
 *
 * @ORM\Entity
 */
class Order {
...
	/**
	 * @return TrackingNumber[]
	 */
	public function getTrackingNumbers()
	{
		$numbers = [];
		// some logic here

		return $numbers;
	}

Generated schema contains trackingNumbers: Iterable! instead of specific type. How can I fix annotation? It is working fine if I query boxes collection and then trackingNumbers collection, but I do not want to expose my DB schema and force the client to loop through properties he do not need. I tried to use Subresource annotation, but it did not helped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions