[Components] Fix function columns by composing wire object set#2955
[Components] Fix function columns by composing wire object set#2955
Conversation
size-limit report 📦
|
| const baseResult = shouldUseObjectSet ? objectSetResult : osdkObjectsResult; | ||
|
|
||
| // Omitting withProperties as it causes an error when present in the function param | ||
| const wireObjectSet = useMemo(() => { |
There was a problem hiding this comment.
@KuberSethi An option is to compose the wireObjectSet here and remove the wireObjectSet from the hooks return values.
I will need to do this anyway because the function query fails when there are derived properties in the object set param.
There was a problem hiding this comment.
because the function query fails when there are derived properties in the object set param.
Why is this failing / could you share more details?
There was a problem hiding this comment.
I believe it's a function api issue. I raised this with the functions team
KuberSethi
left a comment
There was a problem hiding this comment.
initial comments - lots of minor things (typing can be tightened in a lot of places) but I want to index on directionality first. I think it's possible to do this internally without changing our contracts but let me know if you disagree.
took an initial (very LLM driven) approach to illustrate, again ignore any specific errors lets just lock down directionality rn #2957
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| const stableObjectSet = useMemo(() => objectSet, [JSON.stringify(objectSet)]); | ||
| const stableObjectSet = useMemo(() => wireObjectSet, [ | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Here and above why do we have this eslint disable? Maybe I'm missing something but there's nothing about this usecase that would require this imo, surely we can get rid of it and rearchitect things to where its not necessary?
There was a problem hiding this comment.
It's just a nit where I suppress the warning for the wireObjectSet dependency that I intentionally leave out to return a stable object set based on their stringified value.
| const baseResult = shouldUseObjectSet ? objectSetResult : osdkObjectsResult; | ||
|
|
||
| // Omitting withProperties as it causes an error when present in the function param | ||
| const wireObjectSet = useMemo(() => { |
There was a problem hiding this comment.
because the function query fails when there are derived properties in the object set param.
Why is this failing / could you share more details?
packages/react/src/new/hookUtils.ts
Outdated
| * Composes a base ObjectSet with hook options and returns the wire | ||
| * representation. Available immediately — does not depend on loading state. | ||
| */ | ||
| export function composeWireObjectSet( |
There was a problem hiding this comment.
I think this is identical to ObjectSetQuery.composeObjectSet()? Any chance of reuse or nah?
There was a problem hiding this comment.
We we will need to make #composeObjectSet a static function and use it here. I can do that if you have no problem making it a static method of ObjectSetQuery class
There was a problem hiding this comment.
Hmm.. ObjectSetQuery is in @osdk/client and to do this we will need to export ObjectSetQuery from client. I'd prefer to duplicate the logic than to export that class in @osdk/client. What do u think?
| * The wire representation of the final ObjectSet after all transformations. | ||
| * Available immediately without waiting for loading to complete. | ||
| */ | ||
| wireObjectSet: ReturnType<typeof getWireObjectSet> | undefined; |
There was a problem hiding this comment.
hmm I think this is really confusing to users, especially to LLMs, do we need to expose this or is there a way to make this internal?
There was a problem hiding this comment.
Yeah so I was considering to only export composeWireObjectSet function, and compose it within the useObjectTableData hook
| queryDefinition: config.queryDefinition, | ||
| options: { | ||
| params: config.getParams(stableObjectSet), | ||
| params: config.getParams(composedObjectSet!), |
There was a problem hiding this comment.
can we drop ! by dropping the intermediate stableObjectSet?
| * limitations under the License. | ||
| */ | ||
|
|
||
| export { composeObjectSet } from "../new/composeObjectSet.js"; |
| * | ||
| * This is a copy of ObjectSetQuery.#composeObjectSet in @osdk/client | ||
| */ | ||
| export function composeObjectSet< |
There was a problem hiding this comment.
suggestion (not-blocking): could we add a TODO to reuse the one from @osdk/client?
| RDPs | ||
| >; | ||
| } | ||
| if (options.where) { |
There was a problem hiding this comment.
question (blocking): how are we using the filter passed through the objectsTableApi?
| let result: ObjectSet<Q, RDPs> = baseObjectSet; | ||
|
|
||
| if (options.withProperties) { | ||
| result = result.withProperties(options.withProperties) as ObjectSet< |
There was a problem hiding this comment.
I may be missing something but I thought we wanted to drop this?
|
Closing this PR with fixes in the new PR: #2967 |
Fixing regression on function columns after useObjectSet and useOsdkObjects is fixed to return the rich object set only when loading is false. The function query expects wire object set and not the rich object set.
Error:

Expected param: