@graphql-mesh/string-interpolation 0.5.9 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -100,7 +100,17 @@ class Interpolator {
100
100
  applyRule(str, rule, data = {}) {
101
101
  const dataToReplace = this.applyData(rule.key, data);
102
102
  if (dataToReplace !== undefined) {
103
- return str.replace(rule.replace, this.applyModifiers(rule.modifiers, dataToReplace, data));
103
+ const modifiedData = this.applyModifiers(rule.modifiers, dataToReplace, data);
104
+ // If the entire string is just the placeholder and the replacement is an object,
105
+ // return the object directly instead of converting to "[object Object]"
106
+ if (str === rule.replace && typeof modifiedData === 'object' && modifiedData !== null) {
107
+ return modifiedData;
108
+ }
109
+ // For objects embedded in a larger string, JSON stringify them
110
+ if (typeof modifiedData === 'object' && modifiedData !== null) {
111
+ return str.replace(rule.replace, JSON.stringify(modifiedData));
112
+ }
113
+ return str.replace(rule.replace, modifiedData);
104
114
  }
105
115
  else if (rule.alternativeText) {
106
116
  return str.replace(rule.replace, this.applyModifiers(rule.modifiers, rule.alternativeText, data));
@@ -96,7 +96,17 @@ export class Interpolator {
96
96
  applyRule(str, rule, data = {}) {
97
97
  const dataToReplace = this.applyData(rule.key, data);
98
98
  if (dataToReplace !== undefined) {
99
- return str.replace(rule.replace, this.applyModifiers(rule.modifiers, dataToReplace, data));
99
+ const modifiedData = this.applyModifiers(rule.modifiers, dataToReplace, data);
100
+ // If the entire string is just the placeholder and the replacement is an object,
101
+ // return the object directly instead of converting to "[object Object]"
102
+ if (str === rule.replace && typeof modifiedData === 'object' && modifiedData !== null) {
103
+ return modifiedData;
104
+ }
105
+ // For objects embedded in a larger string, JSON stringify them
106
+ if (typeof modifiedData === 'object' && modifiedData !== null) {
107
+ return str.replace(rule.replace, JSON.stringify(modifiedData));
108
+ }
109
+ return str.replace(rule.replace, modifiedData);
100
110
  }
101
111
  else if (rule.alternativeText) {
102
112
  return str.replace(rule.replace, this.applyModifiers(rule.modifiers, rule.alternativeText, data));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphql-mesh/string-interpolation",
3
- "version": "0.5.9",
3
+ "version": "0.5.10",
4
4
  "description": "Dynamic string manipulation",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "*"
8
8
  },
9
9
  "dependencies": {
10
- "dayjs": "1.11.18",
10
+ "dayjs": "1.11.19",
11
11
  "json-pointer": "0.6.2",
12
12
  "lodash.get": "4.4.2",
13
13
  "tslib": "^2.4.0"