saleor-app-sdk-REDIS_APL/src/gql-ast-to-string.ts
Krzysztof Wolski e439438d8f
Add functions to process the Saleor webhooks (#100)
* Add functions to process the saleor webhooks

Co-authored-by: Lukasz Ostrowski <lukasz.ostrowski@saleor.io>
2022-11-03 13:05:28 +01:00

7 lines
304 B
TypeScript

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