From 441c61e50c0f7b9c37eb7f7480f6389e41f8d843 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Thu, 19 Dec 2024 17:51:00 +0100 Subject: [PATCH] run prettier --- .prettierignore | 3 ++ .../configFileTypes/cjsConfig/package.json | 2 +- .../jsConfigWithCJS/package.json | 2 +- .../jsConfigWithESM/package.json | 2 +- .../configFileTypes/mjsConfig/package.json | 2 +- .../tsConfigWithCJS/package.json | 2 +- .../tsConfigWithESM/package.json | 2 +- .../localSchemaArray/apollo.config.json | 2 +- .../sampleWorkspace.code-workspace | 22 ++++++------ schemas/apollo.config.schema.json | 32 +++++------------ schemas/supergraph_config_schema.json | 35 +++++-------------- src/language-server/project/internal.ts | 4 +-- src/language-server/providers/schema/file.ts | 12 +++---- src/language-server/server.ts | 22 ++++++------ src/language-server/workspace.ts | 18 +++++----- 15 files changed, 64 insertions(+), 98 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..a89f32852 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +src/language-server/graphqlTypes.ts +src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts +README.md diff --git a/sampleWorkspace/configFileTypes/cjsConfig/package.json b/sampleWorkspace/configFileTypes/cjsConfig/package.json index 50c741610..e8729e45a 100644 --- a/sampleWorkspace/configFileTypes/cjsConfig/package.json +++ b/sampleWorkspace/configFileTypes/cjsConfig/package.json @@ -1,4 +1,4 @@ { "name": "test", "type": "module" -} \ No newline at end of file +} diff --git a/sampleWorkspace/configFileTypes/jsConfigWithCJS/package.json b/sampleWorkspace/configFileTypes/jsConfigWithCJS/package.json index 50c741610..e8729e45a 100644 --- a/sampleWorkspace/configFileTypes/jsConfigWithCJS/package.json +++ b/sampleWorkspace/configFileTypes/jsConfigWithCJS/package.json @@ -1,4 +1,4 @@ { "name": "test", "type": "module" -} \ No newline at end of file +} diff --git a/sampleWorkspace/configFileTypes/jsConfigWithESM/package.json b/sampleWorkspace/configFileTypes/jsConfigWithESM/package.json index 2b1be0bb1..236fcbf34 100644 --- a/sampleWorkspace/configFileTypes/jsConfigWithESM/package.json +++ b/sampleWorkspace/configFileTypes/jsConfigWithESM/package.json @@ -1,4 +1,4 @@ { "name": "test", "type": "commonjs" -} \ No newline at end of file +} diff --git a/sampleWorkspace/configFileTypes/mjsConfig/package.json b/sampleWorkspace/configFileTypes/mjsConfig/package.json index 2b1be0bb1..236fcbf34 100644 --- a/sampleWorkspace/configFileTypes/mjsConfig/package.json +++ b/sampleWorkspace/configFileTypes/mjsConfig/package.json @@ -1,4 +1,4 @@ { "name": "test", "type": "commonjs" -} \ No newline at end of file +} diff --git a/sampleWorkspace/configFileTypes/tsConfigWithCJS/package.json b/sampleWorkspace/configFileTypes/tsConfigWithCJS/package.json index 50c741610..e8729e45a 100644 --- a/sampleWorkspace/configFileTypes/tsConfigWithCJS/package.json +++ b/sampleWorkspace/configFileTypes/tsConfigWithCJS/package.json @@ -1,4 +1,4 @@ { "name": "test", "type": "module" -} \ No newline at end of file +} diff --git a/sampleWorkspace/configFileTypes/tsConfigWithESM/package.json b/sampleWorkspace/configFileTypes/tsConfigWithESM/package.json index 2b1be0bb1..236fcbf34 100644 --- a/sampleWorkspace/configFileTypes/tsConfigWithESM/package.json +++ b/sampleWorkspace/configFileTypes/tsConfigWithESM/package.json @@ -1,4 +1,4 @@ { "name": "test", "type": "commonjs" -} \ No newline at end of file +} diff --git a/sampleWorkspace/localSchemaArray/apollo.config.json b/sampleWorkspace/localSchemaArray/apollo.config.json index ff50a6de0..c18814ecd 100644 --- a/sampleWorkspace/localSchemaArray/apollo.config.json +++ b/sampleWorkspace/localSchemaArray/apollo.config.json @@ -6,4 +6,4 @@ "localSchemaFile": ["./starwarsSchema.graphql", "./planets.graphql"] } } -} \ No newline at end of file +} diff --git a/sampleWorkspace/sampleWorkspace.code-workspace b/sampleWorkspace/sampleWorkspace.code-workspace index a2ed20d1a..8da64cf5c 100644 --- a/sampleWorkspace/sampleWorkspace.code-workspace +++ b/sampleWorkspace/sampleWorkspace.code-workspace @@ -1,32 +1,32 @@ { "folders": [ { - "path": "localSchema" + "path": "localSchema", }, { - "path": "clientSchema" + "path": "clientSchema", }, { - "path": "spotifyGraph" + "path": "spotifyGraph", }, { - "path": "httpSchema" + "path": "httpSchema", }, { - "path": "localSchemaArray" + "path": "localSchemaArray", }, { - "path": "rover" + "path": "rover", }, { - "path": "configFileTypes" + "path": "configFileTypes", }, { - "path": "../src/language-server/__tests__/fixtures/documents" - } + "path": "../src/language-server/__tests__/fixtures/documents", + }, ], "settings": { "apollographql.devTools.showPanel": "detect", - "apollographql.devTools.serverPort": 7095 - } + "apollographql.devTools.serverPort": 7095, + }, } diff --git a/schemas/apollo.config.schema.json b/schemas/apollo.config.schema.json index a27c70b15..f564a2ec5 100644 --- a/schemas/apollo.config.schema.json +++ b/schemas/apollo.config.schema.json @@ -12,9 +12,7 @@ "$ref": "#/definitions/clientConfig" } }, - "required": [ - "client" - ], + "required": ["client"], "additionalProperties": false }, { @@ -24,9 +22,7 @@ "$ref": "#/definitions/roverConfig" } }, - "required": [ - "rover" - ], + "required": ["rover"], "additionalProperties": false } ] @@ -67,9 +63,7 @@ "description": "Skip SSL validation. May be required for self-signed certificates." } }, - "required": [ - "url" - ], + "required": ["url"], "additionalProperties": false, "description": "Configuration for using a local schema from a URL." }, @@ -97,9 +91,7 @@ "description": "Path to a local schema file to use as GraphQL Schema for this project. Can be a string or an array of strings to merge multiple partial schemas into one." } }, - "required": [ - "localSchemaFile" - ], + "required": ["localSchemaFile"], "additionalProperties": false, "description": "Configuration for using a local schema from a file." } @@ -127,10 +119,7 @@ "items": { "type": "string" }, - "default": [ - "**/node_modules", - "**/__tests__" - ], + "default": ["**/node_modules", "**/__tests__"], "description": "Files to exclude from this project. The Apollo GraphQL extension will not provide IntelliSense-like features in these files." }, "tagName": { @@ -157,9 +146,7 @@ "description": "This option is no longer supported, please remove it from your configuration file." } }, - "required": [ - "service" - ], + "required": ["service"], "additionalProperties": false, "description": "Configuration for a Client project." }, @@ -175,10 +162,7 @@ "description": "The name of the profile to use." }, "supergraphConfig": { - "type": [ - "string", - "null" - ], + "type": ["string", "null"], "description": "The path to your `supergraph.yaml` file. \nDefaults to a `supergraph.yaml` in the folder of your `apollo.config.json`, if there is one." }, "extraArgs": { @@ -231,4 +215,4 @@ } }, "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file +} diff --git a/schemas/supergraph_config_schema.json b/schemas/supergraph_config_schema.json index c0e99363a..258f43712 100644 --- a/schemas/supergraph_config_schema.json +++ b/schemas/supergraph_config_schema.json @@ -3,9 +3,7 @@ "title": "SupergraphConfig", "description": "The configuration for a single supergraph composed of multiple subgraphs.", "type": "object", - "required": [ - "subgraphs" - ], + "required": ["subgraphs"], "properties": { "federation_version": { "anyOf": [ @@ -33,9 +31,7 @@ "anyOf": [ { "type": "object", - "required": [ - "file" - ], + "required": ["file"], "properties": { "file": { "type": "string" @@ -44,15 +40,10 @@ }, { "type": "object", - "required": [ - "subgraph_url" - ], + "required": ["subgraph_url"], "properties": { "introspection_headers": { - "type": [ - "object", - "null" - ], + "type": ["object", "null"], "additionalProperties": { "type": "string" } @@ -65,10 +56,7 @@ }, { "type": "object", - "required": [ - "graphref", - "subgraph" - ], + "required": ["graphref", "subgraph"], "properties": { "graphref": { "type": "string" @@ -80,9 +68,7 @@ }, { "type": "object", - "required": [ - "sdl" - ], + "required": ["sdl"], "properties": { "sdl": { "type": "string" @@ -94,16 +80,11 @@ "SubgraphConfig": { "description": "Config for a single [subgraph](https://www.apollographql.com/docs/federation/subgraphs/)", "type": "object", - "required": [ - "schema" - ], + "required": ["schema"], "properties": { "routing_url": { "description": "The routing URL for the subgraph. This will appear in supergraph SDL and instructs the graph router to send all requests for this subgraph to this URL.", - "type": [ - "string", - "null" - ] + "type": ["string", "null"] }, "schema": { "description": "The location of the subgraph's SDL", diff --git a/src/language-server/project/internal.ts b/src/language-server/project/internal.ts index 1edf33bc5..1e965e6a3 100644 --- a/src/language-server/project/internal.ts +++ b/src/language-server/project/internal.ts @@ -252,8 +252,8 @@ export abstract class GraphQLInternalProject localSchemaFile === undefined ? [] : Array.isArray(localSchemaFile) - ? localSchemaFile - : [localSchemaFile] + ? localSchemaFile + : [localSchemaFile] ).map((filePath) => path.relative(this.rootURI.fsPath, path.join(process.cwd(), filePath)), ); diff --git a/src/language-server/providers/schema/file.ts b/src/language-server/providers/schema/file.ts index 655f9d30f..0b22d93d4 100644 --- a/src/language-server/providers/schema/file.ts +++ b/src/language-server/providers/schema/file.ts @@ -39,8 +39,8 @@ export class FileSchemaProvider implements GraphQLSchemaProvider { const documents = path ? [this.loadFileAndGetDocument(path)] : paths - ? paths.map(this.loadFileAndGetDocument, this) - : undefined; + ? paths.map(this.loadFileAndGetDocument, this) + : undefined; if (!documents) throw new Error( @@ -73,8 +73,8 @@ export class FileSchemaProvider implements GraphQLSchemaProvider { const __schema = parsed.data ? parsed.data.__schema : parsed.__schema - ? parsed.__schema - : parsed; + ? parsed.__schema + : parsed; const schema = buildClientSchema({ __schema }); return parse(printSchema(schema)); @@ -105,8 +105,8 @@ export class FileSchemaProvider implements GraphQLSchemaProvider { const SDLs = path ? [this.loadFileAndGetSDL(path)] : paths - ? paths.map(this.loadFileAndGetSDL, this) - : undefined; + ? paths.map(this.loadFileAndGetSDL, this) + : undefined; if (!SDLs || SDLs.filter((s) => !Boolean(s)).length > 0) return Debug.error( diff --git a/src/language-server/server.ts b/src/language-server/server.ts index 1252ebe80..4c37404d7 100644 --- a/src/language-server/server.ts +++ b/src/language-server/server.ts @@ -87,8 +87,8 @@ workspace.onConfigFilesFound(async (params) => { !value ? value : value instanceof Error || isValidationError(value) - ? { message: value.message, stack: value.stack } - : value, + ? { message: value.message, stack: value.stack } + : value, ), ); }); @@ -181,18 +181,16 @@ documents.onDidChangeContent((params) => { project.documentDidChange(params.document); }); -documents.onDidOpen( - (params) => - workspace - .projectForFile(params.document.uri, params.document.languageId) - ?.onDidOpen?.(params), +documents.onDidOpen((params) => + workspace + .projectForFile(params.document.uri, params.document.languageId) + ?.onDidOpen?.(params), ); -documents.onDidClose( - (params) => - workspace - .projectForFile(params.document.uri, params.document.languageId) - ?.onDidClose?.(params), +documents.onDidClose((params) => + workspace + .projectForFile(params.document.uri, params.document.languageId) + ?.onDidClose?.(params), ); connection.onDidChangeWatchedFiles((params) => { diff --git a/src/language-server/workspace.ts b/src/language-server/workspace.ts index 08f7803f1..7335ff151 100644 --- a/src/language-server/workspace.ts +++ b/src/language-server/workspace.ts @@ -71,15 +71,15 @@ export class GraphQLWorkspace { clientIdentity, }) : isRoverConfig(config) - ? new RoverProject({ - config, - loadingHandler: this.LanguageServerLoadingHandler, - configFolderURI: URI.parse(folder.uri), - capabilities: this.capabilities!, // TODO? - }) - : (() => { - throw new Error("Impossible config!"); - })(); + ? new RoverProject({ + config, + loadingHandler: this.LanguageServerLoadingHandler, + configFolderURI: URI.parse(folder.uri), + capabilities: this.capabilities!, // TODO? + }) + : (() => { + throw new Error("Impossible config!"); + })(); project.onDiagnostics((params) => { this._onDiagnostics && this._onDiagnostics(params);