From b6e563f3b53a54b3616a2afd2c7be7c29f73f25b Mon Sep 17 00:00:00 2001 From: Thomas Ladd Date: Sun, 7 Apr 2019 23:10:33 -0500 Subject: [PATCH] Add gql to default config in apollo-language-server Fixes #1128 --- CHANGELOG.md | 2 + .../src/config/__tests__/config.ts | 9 +- .../src/config/__tests__/loadConfig.ts | 102 +++++++++--------- .../src/config/config.ts | 2 +- 4 files changed, 56 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6567efb7c7..067fc06c90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - apollo - Update `service:check`'s `--markdown` output to include clients affected, number of operations checked, pluralization improvements, and backticks around service and schema variant [#1164](https://github.com/apollographql/apollo-tooling/pull/1164) - Update `service:check` output to show failures before passes [#1168](https://github.com/apollographql/apollo-tooling/pull/1168) +- apollo-language-server + - Add `gql` extension to the default `includes` configuration [#1176](https://github.com/apollographql/apollo-tooling/pull/1176) ## `apollo@2.8.1` diff --git a/packages/apollo-language-server/src/config/__tests__/config.ts b/packages/apollo-language-server/src/config/__tests__/config.ts index 7b116bbff9..9eee62cab1 100644 --- a/packages/apollo-language-server/src/config/__tests__/config.ts +++ b/packages/apollo-language-server/src/config/__tests__/config.ts @@ -1,9 +1,4 @@ -import { - ApolloConfig, - ApolloConfigFormat, - DefaultClientConfig, - DefaultServiceConfig -} from "../"; +import { ApolloConfig, ApolloConfigFormat } from "../"; import URI from "vscode-uri"; describe("ApolloConfig", () => { @@ -38,7 +33,7 @@ describe("ApolloConfig", () => { expect(projects).toHaveLength(1); expect(projects[0].isClient).toBeTruthy(); }); - it("creates a ClientConfig when client is present", () => { + it("creates a ServiceConfig when service is present", () => { const rawConfig: ApolloConfigFormat = { service: "my-service" }; const config = new ApolloConfig(rawConfig); const projects = config.projects; diff --git a/packages/apollo-language-server/src/config/__tests__/loadConfig.ts b/packages/apollo-language-server/src/config/__tests__/loadConfig.ts index 037bda4409..a7169c4f38 100644 --- a/packages/apollo-language-server/src/config/__tests__/loadConfig.ts +++ b/packages/apollo-language-server/src/config/__tests__/loadConfig.ts @@ -78,37 +78,37 @@ describe("loadConfig", () => { configFileName: "my.config.js" }); expect(config.rawConfig).toMatchInlineSnapshot(` -Object { - "client": Object { - "addTypename": true, - "clientOnlyDirectives": Array [ - "connection", - "type", - ], - "clientSchemaDirectives": Array [ - "client", - "rest", - ], - "excludes": Array [ - "**/node_modules", - "**/__tests__", - ], - "includes": Array [ - "src/**/*.{ts,tsx,js,jsx,graphql}", - ], - "service": "hello", - "statsWindow": Object { - "from": -86400, - "to": -0, - }, - "tagName": "gql", - }, - "engine": Object { - "endpoint": "https://engine-graphql.apollographql.com/api/graphql", - "frontend": "https://engine.apollographql.com", - }, -} -`); + Object { + "client": Object { + "addTypename": true, + "clientOnlyDirectives": Array [ + "connection", + "type", + ], + "clientSchemaDirectives": Array [ + "client", + "rest", + ], + "excludes": Array [ + "**/node_modules", + "**/__tests__", + ], + "includes": Array [ + "src/**/*.{ts,tsx,js,jsx,graphql,gql}", + ], + "service": "hello", + "statsWindow": Object { + "from": -86400, + "to": -0, + }, + "tagName": "gql", + }, + "engine": Object { + "endpoint": "https://engine-graphql.apollographql.com/api/graphql", + "frontend": "https://engine.apollographql.com", + }, + } + `); }); it("loads with service defaults from different dir", async () => { @@ -127,26 +127,26 @@ Object { configFileName: "my.config.js" }); expect(config.rawConfig).toMatchInlineSnapshot(` -Object { - "engine": Object { - "endpoint": "https://engine-graphql.apollographql.com/api/graphql", - "frontend": "https://engine.apollographql.com", - }, - "service": Object { - "endpoint": Object { - "url": "http://localhost:4000/graphql", - }, - "excludes": Array [ - "**/node_modules", - "**/__tests__", - ], - "includes": Array [ - "src/**/*.{ts,tsx,js,jsx,graphql}", - ], - "name": "hello", - }, -} -`); + Object { + "engine": Object { + "endpoint": "https://engine-graphql.apollographql.com/api/graphql", + "frontend": "https://engine.apollographql.com", + }, + "service": Object { + "endpoint": Object { + "url": "http://localhost:4000/graphql", + }, + "excludes": Array [ + "**/node_modules", + "**/__tests__", + ], + "includes": Array [ + "src/**/*.{ts,tsx,js,jsx,graphql,gql}", + ], + "name": "hello", + }, + } + `); }); it("[deprecated] loads config from package.json", async () => { diff --git a/packages/apollo-language-server/src/config/config.ts b/packages/apollo-language-server/src/config/config.ts index b72c294fc8..62fda629bd 100644 --- a/packages/apollo-language-server/src/config/config.ts +++ b/packages/apollo-language-server/src/config/config.ts @@ -47,7 +47,7 @@ export const DefaultEngineConfig = { }; export const DefaultConfigBase = { - includes: ["src/**/*.{ts,tsx,js,jsx,graphql}"], + includes: ["src/**/*.{ts,tsx,js,jsx,graphql,gql}"], excludes: ["**/node_modules", "**/__tests__"] };