@nestjs/graphql
Version:
GraphQL for NestJS: code-first and schema-first APIs, resolvers as providers, subscriptions, federation and generated SDL, on Apollo or Mercurius.
13 lines (12 loc) • 370 B
JavaScript
export function stringifyWithoutQuotes(obj, includeSpaces) {
let result = includeSpaces
? JSON.stringify(obj, null, 2)
: JSON.stringify(obj);
result = result
.replace(/"([^"]+)":/g, '$1:')
.replace(/(?<char>({|,|:))/g, '$<char> ');
if (!includeSpaces) {
result = result.replace(/}/g, ' }');
}
return result;
}