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

Reject queries with incompatible "filter.fields" and "filter.include" #3455

Closed
bajtos opened this issue Jul 26, 2019 · 4 comments
Closed

Reject queries with incompatible "filter.fields" and "filter.include" #3455

bajtos opened this issue Jul 26, 2019 · 4 comments
Labels
feature Relations Model relations (has many, etc.) Repository Issues related to @loopback/repository package stale

Comments

@bajtos
Copy link
Member

bajtos commented Jul 26, 2019

The filter property fields allows callers to limit which model properties are returned by the database. This creates a problem when the primary or the foreign key is excluded from the data, because then we cannot resolve included models.

categoryRepo.find({
  fields: ['name'],
  include: [{relation: 'products'}],
});

In LB3, I think we were silently ignoring include filter in such case.

I am proposing to be more explicit in LB4 and reject such queries with a 4xx (Bad Request) error.

Later, we can improve our implementation to automatically add PK/FK properties to the fields configuration and remove PK/FK properties from the data returned back to the user, so that inclusions are resolved as expected and yet the data contains only the specified properties.

See also #3387

Acceptance criteria

TBD - will be filled by the team.

@InvictusMB
Copy link
Contributor

@bajtos Do you think #5592 is a viable solution for this?

@bajtos
Copy link
Member Author

bajtos commented Jun 8, 2020

Do you think #5592 is a viable solution for this?

Yes, if we can fix resolvers to transparently add the necessary fields, then there is no need reject queries excluding PK/FK fields.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

@stale stale bot added the stale label Dec 25, 2020
@stale
Copy link

stale bot commented Jul 14, 2021

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Relations Model relations (has many, etc.) Repository Issues related to @loopback/repository package stale
Projects
None yet
Development

No branches or pull requests

2 participants