@apollo/utils.printwithreducedwhitespace
Advanced tools
+20
| # printWithReducedWhitespace | ||
| Prints a GraphQL AST with a minimal amount of whitespace. Consider using the | ||
| [`stripIgnoredCharacters`](https://github.com/graphql/graphql-js/blob/e9a81f2ba9020ec5fd0f67f5553ccabe392e95e8/src/utilities/stripIgnoredCharacters.ts) function from `graphql` instead of this function. | ||
| ## Usage | ||
| ```ts | ||
| import { printWithReducedWhitespace } from "@apollo/utils.operationregistrysignature"; | ||
| const signature = operationRegistrySignature( | ||
| parse(`#graphql | ||
| query Foo { | ||
| bar | ||
| } | ||
| `), | ||
| "Foo", | ||
| { preserveStringAndNumericLiterals: true }, | ||
| ); | ||
| ``` |
+3
-6
| { | ||
| "name": "@apollo/utils.printwithreducedwhitespace", | ||
| "version": "1.1.0", | ||
| "version": "2.0.0", | ||
| "description": "Print an AST with as little whitespace as possible", | ||
@@ -10,3 +10,3 @@ "main": "dist/index.js", | ||
| "url": "git+https://github.com/apollographql/apollo-utils.git", | ||
| "directory": "printWithReducedWhitespace/" | ||
| "directory": "packages/printWithReducedWhitespace/" | ||
| }, | ||
@@ -22,7 +22,4 @@ "keywords": [ | ||
| "engines": { | ||
| "node": ">=12.13.0" | ||
| "node": ">=14" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "peerDependencies": { | ||
@@ -29,0 +26,0 @@ "graphql": "14.x || 15.x || 16.x" |
@@ -5,31 +5,25 @@ import gql from "graphql-tag"; | ||
| describe("printWithReducedWhitespace", () => { | ||
| const cases = [ | ||
| { | ||
| name: "lots of whitespace", | ||
| // Note: there's a tab after "tab->", which prettier wants to keep as a | ||
| // literal tab rather than \t. In the output, there should be a literal | ||
| // backslash-t. | ||
| input: gql` | ||
| query Foo($a: Int) { | ||
| user( | ||
| name: " tab-> yay" | ||
| other: """ | ||
| apple | ||
| bag | ||
| cat | ||
| """ | ||
| ) { | ||
| name | ||
| } | ||
| it("removes whitespace", () => { | ||
| // Note: there's a tab after "tab->", which prettier wants to keep as a | ||
| // literal tab rather than \t. In the output, there should be a literal | ||
| // backslash-t. | ||
| const document = gql` | ||
| query Foo($a: Int) { | ||
| user( | ||
| name: " tab-> yay" | ||
| other: """ | ||
| apple | ||
| bag | ||
| cat | ||
| """ | ||
| ) { | ||
| name | ||
| } | ||
| `, | ||
| output: | ||
| 'query Foo($a:Int){user(name:" tab->\\tyay"other:"apple\\n bag\\ncat"){name}}', | ||
| }, | ||
| ]; | ||
| cases.forEach(({ name, input, output }) => { | ||
| test(name, () => { | ||
| expect(printWithReducedWhitespace(input)).toEqual(output); | ||
| }); | ||
| } | ||
| `; | ||
| expect(printWithReducedWhitespace(document)).toBe( | ||
| `query Foo($a:Int){user(name:" tab->\\tyay"other:"apple\\n bag\\ncat"){name}}`, | ||
| ); | ||
| }); | ||
| }); |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
6810
5.88%10
11.11%0
-100%21
Infinity%87
-7.45%