Skip to content

Commit

Permalink
feat: support for graphql files (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Jun 21, 2024
1 parent c382cbb commit c9abe0e
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 108 deletions.
131 changes: 84 additions & 47 deletions Cargo.lock

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.86"
biome_analyze = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_cli = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_configuration = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_console = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_css_analyze = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_css_parser = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_css_syntax = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_diagnostics = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_js_analyze = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_js_formatter = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_js_parser = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_js_syntax = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_json_analyze = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_json_formatter = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_json_parser = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_json_syntax = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_rowan = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_service = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_string_case = { git = "https://github.com/biomejs/biome.git", rev = "54b4c9a39078836843ef363bb6986fad74834480" }
biome_analyze = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_cli = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_configuration = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_console = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_css_analyze = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_css_parser = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_css_syntax = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_diagnostics = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_js_analyze = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_js_formatter = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_js_parser = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_js_syntax = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_json_analyze = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_json_formatter = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_json_parser = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_json_syntax = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_rowan = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_service = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
biome_string_case = { git = "https://github.com/biomejs/biome.git", rev = "ad7881a16b38ea930fa668bce5196cae38bef3de" }
bpaf = { version = "0.9.12", features = ["docgen"] }
# If you update this library, be aware of the breaking changes
pulldown-cmark = "0.10.3"
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/lintdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ fn print_diagnostics(
}
}
// Unknown code blocks should be ignored by tests
DocumentFileSource::Unknown => {}
DocumentFileSource::Unknown => {} | DocumentFileSource::Graphql(_) => {}
}

Ok(())
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@astrojs/rss": "4.0.6",
"@astrojs/starlight": "0.24.2",
"@biomejs/biome": "1.8.1",
"@biomejs/wasm-web": "https://pkg.pr.new/biomejs/biome/@biomejs/wasm-web@54b4c9a",
"@biomejs/wasm-web": "https://pkg.pr.new/biomejs/biome/@biomejs/wasm-web@ad7881a",
"@codemirror/lang-css": "6.2.1",
"@codemirror/lang-javascript": "6.2.2",
"@codemirror/lang-json": "6.0.1",
Expand Down Expand Up @@ -59,12 +59,11 @@
"textlint-rule-prh": "6.0.0",
"typescript": "5.4.5",
"vite": "5.3.1",
"vite-plugin-svgr": "4.2.0"
},
"dependencies": {
"vite-plugin-svgr": "4.2.0",
"astro": "^4.10.3",
"astro-og-canvas": "^0.5.1",
"canvaskit-wasm": "^0.39.1"
"canvaskit-wasm": "^0.39.1",
"cm6-graphql": "^0.0.15"
},
"packageManager": "[email protected]"
}
84 changes: 68 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/playground/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getCurrentCode,
getFileState,
isCssFilename,
isGraphqlFilename,
isJsonFilename,
isJsxFilename,
isTypeScriptFilename,
Expand All @@ -30,6 +31,7 @@ import { json } from "@codemirror/lang-json";
import { EditorSelection } from "@codemirror/state";
import type { ViewUpdate } from "@codemirror/view";
import type { ReactCodeMirrorRef } from "@uiw/react-codemirror";
import { graphql } from "cm6-graphql";
import * as codeMirrorLangBiomeAst from "codemirror-lang-rome-ast";
import {
createRef,
Expand Down Expand Up @@ -60,6 +62,9 @@ export default function Playground({
if (isCssFilename(playgroundState.currentFile)) {
return [css()];
}
if (isGraphqlFilename(playgroundState.currentFile)) {
return [graphql()];
}
return [
javascript({
jsx: isJsxFilename(playgroundState.currentFile),
Expand Down
9 changes: 7 additions & 2 deletions src/playground/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,17 @@ export function isModuleFilename(filename: string): boolean {
}

export function isJsonFilename(filename: string): boolean {
return filename.endsWith(".json");
return filename.endsWith(".json") || filename.endsWith(".jsonc");
}

export function isCssFilename(filename: string): boolean {
return filename.endsWith(".css");
}

export function isGraphqlFilename(filename: string): boolean {
return filename.endsWith(".gql") || filename.endsWith(".graphql");
}

export function modifyFilename(
filename: string,
opts: ExtensionOptions,
Expand Down Expand Up @@ -279,7 +283,8 @@ export function isValidExtension(filename: string): boolean {
isTypeScriptFilename(filename) ||
isJsxFilename(filename) ||
isJsonFilename(filename) ||
isCssFilename(filename)
isCssFilename(filename) ||
isGraphqlFilename(filename)
);
}

Expand Down
Loading

0 comments on commit c9abe0e

Please sign in to comment.