-
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
fix(Layout): convert boolean true/false for omits to the required "tr… #12
Conversation
…ue" or "false" strings
@DASPRiD it looks like FM is expecting a string for some reason. since it really should be a string should we change the type to omit ?: 'true' | 'false'; so we don't need to do the extra mapping? |
I think passing a boolean value makes sense from a JS perspective. It's much easier to think about it like that, rather than dealing with weird fm parameter requirements. My preference would be to use booleans, personally. |
I'd say, keep the parameter typing unchanged, but run query: (Array.isArray(query) ? query : [query]).map(query => ({
...query,
omit: query.omit?.toString(),
})), |
Sounds good. I've pushed those changes. |
src/Layout.ts
Outdated
@@ -236,8 +236,12 @@ export default class Layout<T extends FieldData = FieldData, U extends GenericPo | |||
params : ListParams<T, U> = {}, | |||
ignoreEmptyResult = false | |||
) : Promise<GetResponse<T, U>> { | |||
// convert any boolean "omit" values in the query in the query to "true" or "false" strings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment is quite redundant I'd say, think you can get rid of it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I think it was explaining why before, but got trimmed out at some point
## [1.3.1](v1.3.0...v1.3.1) (2024-05-03) ### Bug Fixes * **Layout:** convert boolean true/false for omits to string ([#12](#12)) ([89c9f3f](89c9f3f))
🎉 This PR is included in version 1.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Query is typed with
but it must actually be a string of
"true"
or"false"
. This updates the typing to allow those values, as well as to properly convert boolean values to the string format required for the query to the Data API.