Skip to content

Commit

Permalink
use stripIgnoredCharacters
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Apr 11, 2024
1 parent 7c88078 commit 8cf8c11
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type { DocumentNode } from "@apollo/client/index.js";
import { print } from "@apollo/client/utilities/index.js";
import { stripIgnoredCharacters } from "graphql";

export function printMinified(query: DocumentNode): string {
return (
print(query)
// replace multi-spaces with single space
.replace(/\s{2,}/g, " ")
// remove spaces that are preceeded by braces
.replace(/(?<=[{}])\s+/g, "")
// remove spaces that are preceeding braces
.replace(/\s+(?=[{}])/g, "")
.trim()
);
return stripIgnoredCharacters(print(query));
}

0 comments on commit 8cf8c11

Please sign in to comment.