Skip to content

Commit

Permalink
feat: input string can have \n in gql query
Browse files Browse the repository at this point in the history
  • Loading branch information
linchen1987 committed Sep 25, 2023
1 parent ab88486 commit 226aca1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/sdk-util/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ const formatArgs = (values, specs = {}) => {

// escape slash(\) and double quotes (")
if ('String' === type) {
return isNull(value) ? null : `"${value
const container = value.includes('\n') ? '"""' : '"';

return isNull(value) ? null : `${container}${value
.toString()
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')}"`;
.replace(/"/g, '\\"')}${container}`;
}

if (['DateTime', 'ID', 'HexString'].includes(type)) {
Expand Down

0 comments on commit 226aca1

Please sign in to comment.