Skip to content

Instantly share code, notes, and snippets.

.dhl-track-and-trace-component-app {
color: red;
}
@rybon
rybon / compressGraphqlDocument.js
Last active August 25, 2022 19:48
Remove unnecessary whitespace from a GraphQL query / mutation / subscription
const compressGraphqlDocument = graphqlDocument =>
graphqlDocument
.replace(/#.*\n/g, '')
.replace(/[\s|,]*\n+[\s|,]*/g, ' ')
.replace(/:\s/g, ':')
.replace(/,\s/g, ',')
.replace(/\)\s\{/g, '){')
.replace(/\}\s/g, '}')
.replace(/\{\s/g, '{')
.replace(/\s\}/g, '}')