diff --git a/.changeset/legal-mugs-care.md b/.changeset/legal-mugs-care.md new file mode 100644 index 000000000000..5180aef321bd --- /dev/null +++ b/.changeset/legal-mugs-care.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": minor +--- + +Added support for `.graphqls` files. Biome can now format and lint GraphQL files that have the extension `.graphqls` diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs index 11b145b949ba..bbe517d831df 100644 --- a/crates/biome_cli/tests/commands/format.rs +++ b/crates/biome_cli/tests/commands/format.rs @@ -157,6 +157,21 @@ const APPLY_BRACKET_SAME_LINE_AFTER: &str = r#" Hi ; +"#; + +const SPACING_GRAPHQLS_SANITY_BEFORE: &str = r#" scalar Time + scalar UUID + + + type User { + id: UUID! + name: String! + updatedAt: Time! + } + + + + "#; const APPLY_ATTRIBUTE_POSITION_BEFORE: &str = r#". Fixed 1 file. +``` diff --git a/crates/biome_graphql_syntax/src/file_source.rs b/crates/biome_graphql_syntax/src/file_source.rs index 994d50ebd37a..173c783843e5 100644 --- a/crates/biome_graphql_syntax/src/file_source.rs +++ b/crates/biome_graphql_syntax/src/file_source.rs @@ -36,10 +36,13 @@ impl GraphqlFileSource { } /// Try to return the GraphQL file source corresponding to this file extension + /// See the difference between .graphql and .graphqls files here: + /// https://www.apollographql.com/docs/kotlin/essentials/file-types#sdl-schemas-graphqls + /// https://graphql.com/learn/schema/#inspecting-the-schema pub fn try_from_extension(extension: &str) -> Result { // We assume the file extension is normalized to lowercase match extension { - "graphql" | "gql" => Ok(Self::default()), + "graphqls" | "graphql" | "gql" => Ok(Self::default()), _ => Err(FileSourceError::UnknownExtension), } } @@ -52,7 +55,7 @@ impl GraphqlFileSource { /// [VS Code spec]: https://code.visualstudio.com/docs/languages/identifiers pub fn try_from_language_id(language_id: &str) -> Result { match language_id { - "graphql" | "gql" => Ok(Self::default()), + "graphqls" | "graphql" | "gql" => Ok(Self::default()), _ => Err(FileSourceError::UnknownLanguageId), } }