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

How to use "to Many" Relationships in Schema #163

Closed
sebtoombs opened this issue Nov 16, 2016 · 3 comments
Closed

How to use "to Many" Relationships in Schema #163

sebtoombs opened this issue Nov 16, 2016 · 3 comments
Assignees
Labels

Comments

@sebtoombs
Copy link

sebtoombs commented Nov 16, 2016

When attempting to encode a resource that has a relationship to a single other resource (i.e. what is often referred to as a "toOne" resource) the Parser throws the following error:

Schema is not registered for a resource at path "toOneResource"

Note that the error only occurs when the relationship is not empty. If the relationship is empty, the data is generated correctly. (e.g. below)

data: {}

instead of

data: []

Is this a bug, or are "toMany" relationships not supported?

@neomerx neomerx self-assigned this Nov 16, 2016
@neomerx neomerx changed the title Schema only seems to support "to Many" Relationships How to use "to Many" Relationships in Schema Nov 16, 2016
@neomerx
Copy link
Owner

neomerx commented Nov 16, 2016

It supports both types of relationships to single resource and collections. Encoder understands that array, Iterator or Traversable are toMany relationships and acts accordingly. You just provide your data in Schema and encoder does the rest. That's an example for both types of relationships and how encoding result looks like.
Apart from numerous encoding samples there is a wiki as well.

@sebtoombs
Copy link
Author

Thanks, I had already reviewed all of that information.

Turned out the issue was with types, Doctrine returning a proxy but the Schema expecting an entity.

Thanks for the reply.

@neomerx
Copy link
Owner

neomerx commented Nov 17, 2016

Long long time ago issue with doctrine proxies was solved in #40

I'm closing the issue. If you have any further questions please don't hesitate to ask.

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

No branches or pull requests

2 participants