Replace format-graphql with pretty_graphql for comment-preserving GraphQL formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-03-05 15:53:13 -08:00
parent cfab62707e
commit a0cb7f813f
9 changed files with 113 additions and 344 deletions

116
Cargo.lock generated
View File

@@ -173,6 +173,17 @@ version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
[[package]]
name = "apollo-parser"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "947e21ff51879f8a40d7519dfe619268de2afba4042a8a43878276de3cb910f0"
dependencies = [
"memchr",
"rowan",
"thiserror 2.0.17",
]
[[package]] [[package]]
name = "append-only-vec" name = "append-only-vec"
version = "0.1.8" version = "0.1.8"
@@ -1347,6 +1358,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "countme"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
[[package]] [[package]]
name = "cow-utils" name = "cow-utils"
version = "0.1.3" version = "0.1.3"
@@ -4556,7 +4573,7 @@ checksum = "75b1853bc34cadaa90aa09f95713d8b77ec0c0d3e2d90ccf7a74216f40d20850"
dependencies = [ dependencies = [
"flate2", "flate2",
"postcard", "postcard",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
"thiserror 2.0.17", "thiserror 2.0.17",
@@ -4599,7 +4616,7 @@ dependencies = [
"hashbrown 0.16.1", "hashbrown 0.16.1",
"oxc_data_structures", "oxc_data_structures",
"oxc_estree", "oxc_estree",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
] ]
@@ -4655,7 +4672,7 @@ dependencies = [
"oxc_index", "oxc_index",
"oxc_syntax", "oxc_syntax",
"petgraph 0.8.3", "petgraph 0.8.3",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -4676,7 +4693,7 @@ dependencies = [
"oxc_sourcemap", "oxc_sourcemap",
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -4688,7 +4705,7 @@ dependencies = [
"cow-utils", "cow-utils",
"oxc-browserslist", "oxc-browserslist",
"oxc_syntax", "oxc_syntax",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
] ]
@@ -4763,7 +4780,7 @@ dependencies = [
"oxc_ecmascript", "oxc_ecmascript",
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -4780,7 +4797,7 @@ dependencies = [
"oxc_semantic", "oxc_semantic",
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -4805,7 +4822,7 @@ dependencies = [
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"oxc_traverse", "oxc_traverse",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -4827,7 +4844,7 @@ dependencies = [
"oxc_regular_expression", "oxc_regular_expression",
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"rustc-hash", "rustc-hash 2.1.1",
"seq-macro", "seq-macro",
] ]
@@ -4843,7 +4860,7 @@ dependencies = [
"oxc_diagnostics", "oxc_diagnostics",
"oxc_span", "oxc_span",
"phf 0.13.1", "phf 0.13.1",
"rustc-hash", "rustc-hash 2.1.1",
"unicode-id-start", "unicode-id-start",
] ]
@@ -4860,7 +4877,7 @@ dependencies = [
"once_cell", "once_cell",
"papaya", "papaya",
"pnp", "pnp",
"rustc-hash", "rustc-hash 2.1.1",
"self_cell", "self_cell",
"serde", "serde",
"serde_json", "serde_json",
@@ -4890,7 +4907,7 @@ dependencies = [
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"phf 0.13.1", "phf 0.13.1",
"rustc-hash", "rustc-hash 2.1.1",
"self_cell", "self_cell",
] ]
@@ -4902,7 +4919,7 @@ checksum = "c7f89482522f3cd820817d48ee4ade5b10822060d6e5e4d419f05f6d8bd29d70"
dependencies = [ dependencies = [
"base64-simd", "base64-simd",
"json-escape-simd", "json-escape-simd",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
] ]
@@ -4966,7 +4983,7 @@ dependencies = [
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"oxc_traverse", "oxc_traverse",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
"sha1", "sha1",
@@ -4991,7 +5008,7 @@ dependencies = [
"oxc_syntax", "oxc_syntax",
"oxc_transformer", "oxc_transformer",
"oxc_traverse", "oxc_traverse",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -5009,7 +5026,7 @@ dependencies = [
"oxc_semantic", "oxc_semantic",
"oxc_span", "oxc_span",
"oxc_syntax", "oxc_syntax",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -5414,7 +5431,7 @@ dependencies = [
"nodejs-built-in-modules", "nodejs-built-in-modules",
"pathdiff", "pathdiff",
"radix_trie", "radix_trie",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
"thiserror 2.0.17", "thiserror 2.0.17",
@@ -5533,6 +5550,18 @@ dependencies = [
"termtree", "termtree",
] ]
[[package]]
name = "pretty_graphql"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea8c38ecedb3d28a998ea783469a78587f5f984d61226cf071f6979861e9e6a9"
dependencies = [
"apollo-parser",
"memchr",
"rowan",
"tiny_pretty",
]
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.3.1" version = "1.3.1"
@@ -5713,7 +5742,7 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"quinn-proto", "quinn-proto",
"quinn-udp", "quinn-udp",
"rustc-hash", "rustc-hash 2.1.1",
"rustls", "rustls",
"socket2 0.5.10", "socket2 0.5.10",
"thiserror 2.0.17", "thiserror 2.0.17",
@@ -5733,7 +5762,7 @@ dependencies = [
"lru-slab", "lru-slab",
"rand 0.9.1", "rand 0.9.1",
"ring", "ring",
"rustc-hash", "rustc-hash 2.1.1",
"rustls", "rustls",
"rustls-pki-types", "rustls-pki-types",
"slab", "slab",
@@ -6227,7 +6256,7 @@ dependencies = [
"rolldown_tracing", "rolldown_tracing",
"rolldown_utils", "rolldown_utils",
"rolldown_watcher", "rolldown_watcher",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
"string_wizard", "string_wizard",
@@ -6317,7 +6346,7 @@ dependencies = [
"rolldown_sourcemap", "rolldown_sourcemap",
"rolldown_std_utils", "rolldown_std_utils",
"rolldown_utils", "rolldown_utils",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
"simdutf8", "simdutf8",
@@ -6335,7 +6364,7 @@ dependencies = [
"blake3", "blake3",
"dashmap", "dashmap",
"rolldown_debug_action", "rolldown_debug_action",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
"tracing", "tracing",
@@ -6392,7 +6421,7 @@ dependencies = [
"rolldown-ariadne", "rolldown-ariadne",
"rolldown_utils", "rolldown_utils",
"ropey", "ropey",
"rustc-hash", "rustc-hash 2.1.1",
"sugar_path", "sugar_path",
] ]
@@ -6426,7 +6455,7 @@ dependencies = [
"rolldown_resolver", "rolldown_resolver",
"rolldown_sourcemap", "rolldown_sourcemap",
"rolldown_utils", "rolldown_utils",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
"serde_json", "serde_json",
"string_wizard", "string_wizard",
@@ -6446,7 +6475,7 @@ dependencies = [
"rolldown_common", "rolldown_common",
"rolldown_plugin", "rolldown_plugin",
"rolldown_utils", "rolldown_utils",
"rustc-hash", "rustc-hash 2.1.1",
"serde_json", "serde_json",
"xxhash-rust", "xxhash-rust",
] ]
@@ -6517,7 +6546,7 @@ dependencies = [
"oxc", "oxc",
"oxc_sourcemap", "oxc_sourcemap",
"rolldown_utils", "rolldown_utils",
"rustc-hash", "rustc-hash 2.1.1",
] ]
[[package]] [[package]]
@@ -6569,7 +6598,7 @@ dependencies = [
"regex 1.11.1", "regex 1.11.1",
"regress", "regress",
"rolldown_std_utils", "rolldown_std_utils",
"rustc-hash", "rustc-hash 2.1.1",
"serde_json", "serde_json",
"simdutf8", "simdutf8",
"sugar_path", "sugar_path",
@@ -6599,6 +6628,18 @@ dependencies = [
"str_indices", "str_indices",
] ]
[[package]]
name = "rowan"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "417a3a9f582e349834051b8a10c8d71ca88da4211e4093528e36b9845f6b5f21"
dependencies = [
"countme",
"hashbrown 0.14.5",
"rustc-hash 1.1.0",
"text-size",
]
[[package]] [[package]]
name = "rusqlite" name = "rusqlite"
version = "0.32.1" version = "0.32.1"
@@ -6641,6 +6682,12 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustc-hash" name = "rustc-hash"
version = "2.1.1" version = "2.1.1"
@@ -7453,7 +7500,7 @@ dependencies = [
"memchr", "memchr",
"oxc_index", "oxc_index",
"oxc_sourcemap", "oxc_sourcemap",
"rustc-hash", "rustc-hash 2.1.1",
"serde", "serde",
] ]
@@ -8154,6 +8201,12 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
[[package]]
name = "text-size"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.16.2" version = "0.16.2"
@@ -8276,6 +8329,12 @@ dependencies = [
"crunchy", "crunchy",
] ]
[[package]]
name = "tiny_pretty"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650d82e943da333637be9f1567d33d605e76810a26464edfd7ae74f7ef181e95"
[[package]] [[package]]
name = "tinystr" name = "tinystr"
version = "0.8.1" version = "0.8.1"
@@ -10198,6 +10257,7 @@ dependencies = [
"md5 0.8.0", "md5 0.8.0",
"mime_guess", "mime_guess",
"openssl-sys", "openssl-sys",
"pretty_graphql",
"r2d2", "r2d2",
"r2d2_sqlite", "r2d2_sqlite",
"rand 0.9.1", "rand 0.9.1",

View File

@@ -30,6 +30,7 @@ eventsource-client = { git = "https://github.com/yaakapp/rust-eventsource-client
http = { version = "1.2.0", default-features = false } http = { version = "1.2.0", default-features = false }
log = { workspace = true } log = { workspace = true }
md5 = "0.8.0" md5 = "0.8.0"
pretty_graphql = "0.2"
r2d2 = "0.8.10" r2d2 = "0.8.10"
r2d2_sqlite = "0.25.0" r2d2_sqlite = "0.25.0"
mime_guess = "2.0.5" mime_guess = "2.0.5"

View File

@@ -872,6 +872,14 @@ async fn cmd_format_json(text: &str) -> YaakResult<String> {
Ok(format_json(text, " ")) Ok(format_json(text, " "))
} }
#[tauri::command]
async fn cmd_format_graphql(text: &str) -> YaakResult<String> {
match pretty_graphql::format_text(text, &Default::default()) {
Ok(formatted) => Ok(formatted),
Err(_) => Ok(text.to_string()),
}
}
#[tauri::command] #[tauri::command]
async fn cmd_http_response_body<R: Runtime>( async fn cmd_http_response_body<R: Runtime>(
window: WebviewWindow<R>, window: WebviewWindow<R>,
@@ -1641,6 +1649,7 @@ pub fn run() {
cmd_http_request_body, cmd_http_request_body,
cmd_http_response_body, cmd_http_response_body,
cmd_format_json, cmd_format_json,
cmd_format_graphql,
cmd_get_http_authentication_summaries, cmd_get_http_authentication_summaries,
cmd_get_http_authentication_config, cmd_get_http_authentication_config,
cmd_get_sse_events, cmd_get_sse_events,

312
package-lock.json generated
View File

@@ -5340,105 +5340,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/cliui/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/cliui/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/cliui/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/cliui/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT"
},
"node_modules/cliui/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/cliui/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/cliui/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/cliui/node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/clone-regexp": { "node_modules/clone-regexp": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/clone-regexp/-/clone-regexp-3.0.0.tgz", "resolved": "https://registry.npmjs.org/clone-regexp/-/clone-regexp-3.0.0.tgz",
@@ -6057,15 +5958,6 @@
} }
} }
}, },
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/decode-named-character-reference": { "node_modules/decode-named-character-reference": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.2.0.tgz", "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.2.0.tgz",
@@ -7210,19 +7102,6 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"license": "MIT",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/focus-trap": { "node_modules/focus-trap": {
"version": "7.7.1", "version": "7.7.1",
"resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.7.1.tgz", "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.7.1.tgz",
@@ -7315,30 +7194,6 @@
"node": ">=0.4.x" "node": ">=0.4.x"
} }
}, },
"node_modules/format-graphql": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/format-graphql/-/format-graphql-1.5.0.tgz",
"integrity": "sha512-ZZWcjwJ1IMdnW9l3CeYccC/J7skqOB18tY3autO5OUQuGVZpQu6Es3SThRm25SfiMeZO1+UbzIqnGbjAURu/UA==",
"dependencies": {
"graphql": "^15.1.0",
"yargs": "^15.3.1"
},
"bin": {
"format-graphql": "dist/bin/index.js"
},
"engines": {
"node": ">=10.0"
}
},
"node_modules/format-graphql/node_modules/graphql": {
"version": "15.10.1",
"resolved": "https://registry.npmjs.org/graphql/-/graphql-15.10.1.tgz",
"integrity": "sha512-BL/Xd/T9baO6NFzoMpiMD7YUZ62R6viR5tp/MULVEnbYJXZA//kRNW7J0j1w/wXArgL0sCxhDfK5dczSKn3+cg==",
"license": "MIT",
"engines": {
"node": ">= 10.x"
}
},
"node_modules/forwarded": { "node_modules/forwarded": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
@@ -9281,18 +9136,6 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"license": "MIT",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/lodash": { "node_modules/lodash": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
@@ -11615,33 +11458,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"license": "MIT",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"license": "MIT",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-map": { "node_modules/p-map": {
"version": "7.0.4", "version": "7.0.4",
"resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.4.tgz", "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.4.tgz",
@@ -11668,15 +11484,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/package-json-from-dist": { "node_modules/package-json-from-dist": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
@@ -11770,15 +11577,6 @@
"integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/path-key": { "node_modules/path-key": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
@@ -12893,12 +12691,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"license": "ISC"
},
"node_modules/resize-observer-polyfill": { "node_modules/resize-observer-polyfill": {
"version": "1.5.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
@@ -13366,12 +13158,6 @@
"url": "https://opencollective.com/express" "url": "https://opencollective.com/express"
} }
}, },
"node_modules/set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
"license": "ISC"
},
"node_modules/set-function-length": { "node_modules/set-function-length": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
@@ -15611,12 +15397,6 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/which-module": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
"integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",
"license": "ISC"
},
"node_modules/which-typed-array": { "node_modules/which-typed-array": {
"version": "1.1.19", "version": "1.1.19",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz",
@@ -15832,12 +15612,6 @@
"node": ">=0.4" "node": ">=0.4"
} }
}, },
"node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"license": "ISC"
},
"node_modules/yallist": { "node_modules/yallist": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
@@ -15860,91 +15634,6 @@
"url": "https://github.com/sponsors/eemeli" "url": "https://github.com/sponsors/eemeli"
} }
}, },
"node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"license": "MIT",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"license": "ISC",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/yargs-parser/node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/yargs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/yargs/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"license": "MIT"
},
"node_modules/yargs/node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yargs/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/yauzl": { "node_modules/yauzl": {
"version": "2.10.0", "version": "2.10.0",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
@@ -16353,7 +16042,6 @@
"deep-equal": "^2.2.3", "deep-equal": "^2.2.3",
"eventemitter3": "^5.0.1", "eventemitter3": "^5.0.1",
"focus-trap-react": "^11.0.4", "focus-trap-react": "^11.0.4",
"format-graphql": "^1.5.0",
"fuzzbunny": "^1.0.1", "fuzzbunny": "^1.0.1",
"hexy": "^0.3.5", "hexy": "^0.3.5",
"history": "^5.3.0", "history": "^5.3.0",

View File

@@ -1,6 +1,5 @@
import type { HttpRequest } from '@yaakapp-internal/models'; import type { HttpRequest } from '@yaakapp-internal/models';
import { formatSdl } from 'format-graphql';
import { useAtom } from 'jotai'; import { useAtom } from 'jotai';
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
import { useLocalStorage } from 'react-use'; import { useLocalStorage } from 'react-use';
@@ -16,6 +15,7 @@ import { Editor } from '../core/Editor/LazyEditor';
import { FormattedError } from '../core/FormattedError'; import { FormattedError } from '../core/FormattedError';
import { Icon } from '../core/Icon'; import { Icon } from '../core/Icon';
import { Separator } from '../core/Separator'; import { Separator } from '../core/Separator';
import { tryFormatGraphql } from '../../lib/formatters';
import { showGraphQLDocExplorerAtom } from './graphqlAtoms'; import { showGraphQLDocExplorerAtom } from './graphqlAtoms';
type Props = Pick<EditorProps, 'heightMode' | 'className' | 'forceUpdateKey'> & { type Props = Pick<EditorProps, 'heightMode' | 'className' | 'forceUpdateKey'> & {
@@ -211,7 +211,7 @@ function GraphQLEditorInner({ request, onChange, baseRequest, ...extraEditorProp
language="graphql" language="graphql"
heightMode="auto" heightMode="auto"
graphQLSchema={schema} graphQLSchema={schema}
format={formatSdl} format={tryFormatGraphql}
defaultValue={currentBody.query} defaultValue={currentBody.query}
onChange={handleChangeQuery} onChange={handleChangeQuery}
placeholder="..." placeholder="..."

View File

@@ -20,6 +20,18 @@ export async function tryFormatJson(text: string): Promise<string> {
return text; return text;
} }
export async function tryFormatGraphql(text: string): Promise<string> {
if (text === '') return text;
try {
return await invokeCmd<string>('cmd_format_graphql', { text });
} catch (err) {
console.warn('Failed to format GraphQL', err);
}
return text;
}
export async function tryFormatXml(text: string): Promise<string> { export async function tryFormatXml(text: string): Promise<string> {
if (text === '') return text; if (text === '') return text;

View File

@@ -17,6 +17,7 @@ type TauriCmd =
| 'cmd_delete_send_history' | 'cmd_delete_send_history'
| 'cmd_dismiss_notification' | 'cmd_dismiss_notification'
| 'cmd_export_data' | 'cmd_export_data'
| 'cmd_format_graphql'
| 'cmd_format_json' | 'cmd_format_json'
| 'cmd_get_http_authentication_config' | 'cmd_get_http_authentication_config'
| 'cmd_get_http_authentication_summaries' | 'cmd_get_http_authentication_summaries'

View File

@@ -1,2 +1 @@
declare module 'format-graphql';
declare module 'vkbeautify'; declare module 'vkbeautify';

View File

@@ -47,7 +47,6 @@
"deep-equal": "^2.2.3", "deep-equal": "^2.2.3",
"eventemitter3": "^5.0.1", "eventemitter3": "^5.0.1",
"focus-trap-react": "^11.0.4", "focus-trap-react": "^11.0.4",
"format-graphql": "^1.5.0",
"fuzzbunny": "^1.0.1", "fuzzbunny": "^1.0.1",
"hexy": "^0.3.5", "hexy": "^0.3.5",
"history": "^5.3.0", "history": "^5.3.0",