mui / toolpad

Toolpad: Full stack components and low-code builder for dashboards and internal apps.
https://mui.com/toolpad/
MIT License
964 stars 243 forks source link

Not init QueryNode and MutationNode's attributes value correctly #1079

Closed WangLarry closed 1 year ago

WangLarry commented 1 year ago

Duplicates

Latest version

Current behavior 😯

fix:

ToolpadApp.tsx

function resolveBindables(
  bindings: Partial<Record<string, BindingEvaluationResult>>,
  bindingId: string,
  params?: NestedBindableAttrs,
): Record<string, unknown> {
  const result: any = _.cloneDeep(params) || {};
  const resultKey = 'value';
  const flattened = flattenNestedBindables(params);
  for (const [path] of flattened) {
    let resolvedValue = bindings[`${bindingId}${path}`]?.value;
    if (resolvedValue === undefined) {
      const initialValue = _.get(result, path.slice(1) /* trim first letter '.' */);
      if (initialValue && (initialValue as ConstantAttrValue<any>).type === 'const') {
        resolvedValue = (initialValue as ConstantAttrValue<any>).value;
      }
    }
    _.set(result, `${resultKey}${path}`, resolvedValue);
  }

  return result[resultKey] || {};
}

Expected behavior 🤔

No response

Steps to reproduce 🕹

Steps:

1. 2. 3. 4.

Context 🔦

No response

Your environment 🌎

No response

Janpot commented 1 year ago

@WangLarry please describe the issue in terms of reproduction steps, expected behavior and actual behavior. It's really hard to figure out the problem you're running into from just a proposed fix.

WangLarry commented 1 year ago

refer issue: https://github.com/mui/mui-toolpad/issues/1001

Janpot commented 1 year ago

I think we can close this, given that https://github.com/mui/mui-toolpad/issues/1001 has been closed