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

Sparse fields that are not included with being explicitly requested #79

Open
tobyzerner opened this issue Aug 24, 2023 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@tobyzerner
Copy link
Owner

tobyzerner commented Aug 24, 2023

The JSON:API spec on Sparse Fieldsets states:

If a client does not specify the set of fields for a given resource type, the server MAY send all fields, a subset of fields, or no fields for that resource type.

Currently, this implementation sends all fields. There should be the ability to mark a field as being excluded from this default response, such that it must be explicitly requested in order to be included.

I'm unsure of what a good method name for this would be though - open to suggestions...

Maybe:

Attribute::make('expensive')->onlyIfRequested();
@tobyzerner tobyzerner added the enhancement New feature or request label Aug 24, 2023
@bertramakers
Copy link
Contributor

I think onlyIfRequested() makes sense. It also matches the terminology used one paragraph higher in the spec:

If a client requests a restricted set of fields for a given resource type [...]

(Emphasis mine)

Alternatively maybe onlyIfSpecified() could also match with "If a client does not specify the set of fields [...]" but I think it will be less clear.

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

No branches or pull requests

2 participants