Closed csabaxyz closed 4 years ago
As a quick fix, something like this can be used:
// TODO: Write our own "pick" that can work with an array of strings or an array of objects for nested objects
const pickFields = pick(fields)
// If the resultSet is a flamelink object
if (resultSet.hasOwnProperty('_fl_meta_')) {
return pickFields(resultSet)
}
// If resultSet is an array of objects, we just pluck the given fields from each object
if (isArray(resultSet)) {
Hi @csabaxyz
Thanks for the detailed explanation, we will have a look at it soonest and report progress here 👍
Hey @dewetvdm,
Can confirm, 1.0.0-alpha.31
fixes the issue for us.
Hey, Yesterday I commented on this issue with the problem: https://github.com/flamelink/flamelink/issues/90 But I just realized that that repo is for the older version of the plugin.
Anyway, the problem seems to be that I have a relational field that is set to single (
multiple:false
), and I'm trying to populate only certain fields with this code:And this is the result that I get with this:
As you can see every key has an empty object as their value. I tried to find the source of this problem, and I think it is related to this code: https://github.com/flamelink/flamelink-js-sdk/blob/a637c0b26fa8e63fa0e20ec3d7986e9519147381/packages/utils/src/index.ts#L437-L444
It looks like this part gets the data in a format like this:
And when the reduce runs, it will get the
val
andkey
values like this:And as the
pickFields
will return an empty object, every key will end up like that. Possible fix would be to determine if the given object is a single piece of content or part of a result query, and then run thepluckResultFields
according to that logic.