Skip to content

Commit 167c30f

Browse files
committed
JSON encode nested object parameters
1 parent 08adce2 commit 167c30f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

templates/web/src/services/template.ts.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ export class {{ service.name | caseUcfirst }} extends Service {
5959

6060
{% for parameter in method.parameters.query %}
6161
if (typeof {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
62-
payload['{{ parameter.name }}'] = {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }};
63-
}
62+
payload['{{ parameter.name }}'] = {% if method.type == 'graphql' %}JSON.stringify({% endif %}{% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }}{% if method.type == 'graphql' %}){% endif %};
63+
%}
6464

6565
{% endfor %}
6666
{% for parameter in method.parameters.body %}
6767
if (typeof {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
68-
payload['{{ parameter.name }}'] = {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }};
68+
payload['{{ parameter.name }}'] = {% if method.type == 'graphql' %}JSON.stringify({% endif %}{% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }}{% if method.type == 'graphql' %}){% endif %};
6969
}
7070

7171
{% endfor %}

0 commit comments

Comments
 (0)