Help

Airtable Cobuilder is here! Learn more about our new no-code app creation feature, powered by AI on the Airtable Academy

`RecordQueryResultOpts` may be too lax

624 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Mike_Pennisi
7 - App Architect
7 - App Architect

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