-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add an option to not auto-populate associations on source endpoints #124
Comments
@sdebionne that sounds reasonable. |
Wouldn't this do it? #122 |
@AddoSolutions sorry I seem to have missed that PR, that does pretty much look like what he's asking for here. I prefer the term |
I have just tested #122 and that sounds like a good start, e.g same kind of modifications should be applied to I wonder if we should have two distincts options for singular and plural endpoints: resources.sites = epilogue.resource({
model: models.User,
endpoints: ['/users', '/users/:uid'],
associations: {
autoPopulate: [false, true]
}
}); It may be handy to auto-populate the associations for singular endpoint while not fetching everything for the plural one. |
@sdebionne sounds reasonable, although I'd prefer if we kept it semantically related to the controllers (rather than the endpoints which can be arbitrary): associations: {
autoPopulate: { read: true, list: false }
} |
OK. And how should this new option play with the include option? AFAIU include is used to do manual associations, right? Is this option still valid (as I cannot see it documented anywhere)? |
@sdebionne |
@mbroadst Then We could have this use case, say to include only project's tasks: include: [{
model: Task,
where: { state: Sequelize.col('project.state') }
}],
associations: {
autoInclude: { read: false, list: false }
} Shall we trigger a warning if both |
@sdebionne no autoPopulate and autoInclude are separate concepts here. Here's a breakdown of the current state:
|
Thanks for the clarification.
@mbroadst Sorry but I don't get why the word |
@sdebionne Most importantly, your desire to use |
I'm considering a PR to add an option (or change the behavior) of resources with associations. I don't think it is correct to return a resource and its associations when the source resource endpoints are called without specifying an association. In a typical use case where we have users and projects,
/users
or/users/:id
should not return associated projects.This has already been discussed before in #34 and #85 but without a consensus on what the expect behavior should be. So what about an option?
autoPopulate: true
would be the default to keep backward compatibility.The text was updated successfully, but these errors were encountered: