-
Notifications
You must be signed in to change notification settings - Fork 6
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
Ensure API returns empty attributes to maintain typing contract integrity #67
Conversation
@Zamfi99 Thank you for this PR! I think I understand your reasoning, but I'm not sure if we can add this feature to the Block Data API. There are a couple of reasons:
In summary, I think that we don't want to start providing our own default sourced values. Gutenberg has a mechanism for providing defaults via For your problem on the GraphQL side, I think it may be best to keep contract integrity by using a nullable type or some equivalent in your consumer code. There may be an alternative solution we can do that only affects the GraphQL API, or maybe a filter of some sort. Let us know if there's something else that would be helpful here or something we've missed. Thank you! |
Hello @alecgeatches, |
@Zamfi99 My apologies for not getting back to you sooner here.
I'd appreciate that! If you can provide a filter to turn on empty attribute returns I think we'd be fine with adding that as a non-default behavior. Thank you! |
I'm closing off this PR, feel free to put up a new PR with the proposed change by @alecgeatches. |
Description
The current implementation of the content parser doesn't return empty attributes, which is a deviation from the expected behavior. This inconsistency can potentially break the typing contract, causing downstream issues for applications relying on this API.
Proposed Solution
This pull request addresses the issue by modifying the content parser logic to ensure that empty attributes are included in the response.
Steps to Test
composer run test
.