ITADN

String Interpolator serializes toString instead of the object

#9113Opentazsingh 创建于 2026-01-06
T
tazsinghcommented
### Issue workflow progress _Progress of the issue based on the [Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_ - [ ] 1. The issue provides a reproduction available on [Github](https://github.com/ardatan/graphql-mesh/tree/master/examples/hello-world), [Stackblitz](https://stackblitz.com/github/ardatan/graphql-mesh/tree/master/examples/hello-world) or [CodeSandbox](https://codesandbox.io/s/github/ardatan/graphql-mesh/tree/master/examples/hello-world) > Make sure to fork this template and run `yarn generate` in the terminal. > > Please make sure Mesh package versions under `package.json` matches yours. - [x] 2. A failing test has been provided - [x] 3. A local solution has been provided - [x] 4. A pull request is pending review --- **Describe the bug** When using `stringInterpolator.parse()` with an object or array value, the interpolation produces `[object Object]` instead of preserving the object or serializing it properly. For example: ```js const context = { user: { name: 'John', age: 30 } }; // When the entire string is a placeholder: stringInterpolator.parse('{user}', context); // Expected: { name: 'John', age: 30 } (the object itself) // Actual: "[object Object]" // When embedded in a larger string: stringInterpolator.parse('User: {user}', context); // Expected: 'User: {"name":"John","age":30}' // Actual: 'User: [object Object]' ``` **To Reproduce** Steps to reproduce the behavior: 1. Create a context object with a nested object or array property 2. Use `stringInterpolator.parse()` with a template containing that property 3. Observe that the result is `"[object Object]"` instead of the actual object or JSON string **Expected behavior** - When the entire template string is just a placeholder (e.g., `{user}`), the interpolator should return the object/array directly without converting to string - When the placeholder is embedded in a larger string (e.g., `User: {user}`), the object/array should be JSON stringified **Environment:** - OS: MacOS - `@graphql-mesh/compose-cli`: `1.5.6` - NodeJS: 22.14.0 **Additional context** <!-- Add any other context about the problem here. --> I'll submit an accompanying PR with a fix for this shortly!
0 条评论