Skip to content

Conversation

nduitz
Copy link
Contributor

@nduitz nduitz commented Sep 4, 2025

Hey it's me again :)

Maybe this is just a special use case for us but might help others as well.

We use this package in combination with open api.
Open api allows you to configure keys in responses as required meaning they might be missing in your response.

In our case this is especially useful because we need to do partial updates.
We could of course send the whole data structure again only updating the relevant keys but that is not very efficient in terms of data usage :)

@nduitz nduitz requested a review from a team as a code owner September 4, 2025 08:58
@nduitz nduitz force-pushed the configure-missing-keys-behaviour branch from 9644523 to b8730b5 Compare September 4, 2025 09:39
@nduitz nduitz changed the title allow users to configure to skip missing keys [feat] allow users to configure to skip missing keys Sep 4, 2025
@nduitz nduitz changed the title [feat] allow users to configure to skip missing keys feat: allow users to configure to skip missing keys Sep 4, 2025
@mattpolzin
Copy link
Member

I think I understand your use-case, but want to be sure. The client is sending the server a partial update and you'd like the server to respond with only the fields that the client request specified as well? The other possibility that occurred to me is that you are using the JSONAPI.View to serialize a request payload rather than a response payload in this scenario.

@nduitz
Copy link
Contributor Author

nduitz commented Sep 18, 2025

Hey,
actually the other way around. I want to control on the server which fields to send.

If I use a struct or a schema of course all fields would be there, and the skip option would make no sense.

But I have a view with ~50 fields (statistics) and I only want to send certain fields that would be updated on the client.

If I used a map to be serialized which contains only two or three keys the serializer would currently default all other fields to nil. With the skip option only the two fields with their values would be send.

@mattpolzin
Copy link
Member

I think your requirements could also be met with a View implementing the hidden/1 function. Not sure if we should add a setting that is a shortcut for that existing way of accomplishing what you're after.

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 this pull request may close these issues.

2 participants