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

Requested fields using super resource type are not taken into account #852

Open
lgringo opened this issue Sep 7, 2022 · 0 comments · May be fixed by #853
Open

Requested fields using super resource type are not taken into account #852

lgringo opened this issue Sep 7, 2022 · 0 comments · May be fixed by #853

Comments

@lgringo
Copy link

lgringo commented Sep 7, 2022

When using request parameter field, if specifying a super type of the resource requested, the parameter is not taken into account.

Let's define two resources, SuperTask and SpecialTask, the latter inheriting the former, using a single repository per type hierarchy (as stated here : https://www.crnk.io/releases/stable/documentation/#_inheritance) :

`
@JsonApiResource(type = "superTasks", subTypes = SpecialTask.class)
public abstract class SuperTask {

@JsonApiId
private Long id;

private String name;

private String category;

}

@JsonApiResource(type = "specialTask", resourcePath = "superTasks")
public class SpecialTask extends SuperTask {

private boolean recurring;

private String end;

}
`
Getters and setters have been omitted for brevity.

Requesting path superTasks with request parameter, we get :

  • ✔️ fields[specialTask]=name returns json including only attribute name.
  • ✔️ fields[specialTask]=end returns json including only attribute end.
  • ✔️ fields[specialTask]=name,end returns json including only attributes name and end.
  • fields[superTasks]=namereturns json including all attributes (from SpecialTask and SuperTask).
  • fields[superTasks]=name and fields[specialTask]=end returns json including only attribute end.

Expected responses :

  • ✔️ fields[specialTask]=name returns json including only attribute name.
  • ✔️ fields[specialTask]=end returns json including only attribute end.
  • ✔️ fields[specialTask]=name,end returns json including only attributes name and end.
  • ✔️ fields[superTasks]=name returns json including only attribute name.
  • ✔️ fields[superTasks]=name and fields[specialTask]=end returns json including only attributes name and end.

At the moment, introducing a new type in the hierarchy (a sibling for SpecialTask) creates a breaking change for our customers, because we need them to specifiy fields for all sub-types.

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

Successfully merging a pull request may close this issue.

1 participant