saleor-app-sdk-REDIS_APL/src/gql-ast-to-string.ts

8 lines
304 B
TypeScript
Raw Normal View History

import { ASTNode, print } from "graphql";
export const gqlAstToString = (ast: ASTNode) =>
print(ast) // convert AST to string
.replaceAll(/\n*/g, "") // remove new lines
.replaceAll(/\s{2,}/g, " ") // remove unnecessary multiple spaces
.trim(); // remove whitespace from beginning and end