Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

`RecordQueryResultOpts` may be too lax

378 0
cancel
Showing results for 
Search instead for 
Did you mean: 

The RecordQueryResultOpts object supports a property named fields which is an array of fields that should be retrieved. If any of the array’s elements are falsey values, they are silently ignored. While this behavior is explicitly documented, I’m not sure it’s desirable.

I recently refactored a block to allow all fields to be configured by the end
user.
This involved generalizing a call to selectRecords:

-const queryResult = consumersTable.selectRecords({fields: ['Chapter']});
+const queryResult = consumersTable.selectRecords({
+  fields: [consumerFields.region]
+});

Code like this is prone to error because the value of the fields elements is abstracted away. Because the API silently tolerates mistakes (e.g. a typo like consumerFields.ragion), the effect isn’t perceptable until some subsequent area of the application logic.

It’s not clear when block authors would benefit from the ability to specify values like undefined, so it may be better for the API to produce a synchronous error for such input.

0 Replies 0