From 9c26b847838a9b5357dfcfb9015e7c6558f0ef89 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 14 Jul 2021 03:13:36 +0300 Subject: [PATCH] enhance(loaders): remove optional methods from the Loader interface --- .changeset/cool-onions-wink.md | 5 ++++ packages/loaders/apollo-engine/src/index.ts | 4 --- packages/loaders/code-file/src/index.ts | 4 --- packages/loaders/git/src/index.ts | 4 --- packages/loaders/git/tests/loader.spec.ts | 6 ---- packages/loaders/github/src/index.ts | 4 --- packages/loaders/graphql-file/src/index.ts | 4 --- .../loaders/graphql-file/tests/loader.spec.ts | 6 ---- packages/loaders/json-file/src/index.ts | 4 --- .../loaders/json-file/tests/loader.spec.ts | 6 ---- packages/loaders/module/src/index.ts | 4 --- packages/loaders/module/tests/loader.spec.ts | 6 ---- packages/loaders/prisma/src/index.ts | 4 --- packages/loaders/url/src/index.ts | 4 --- packages/utils/src/loaders.ts | 3 -- yarn.lock | 28 +++++++++---------- 16 files changed, 19 insertions(+), 77 deletions(-) create mode 100644 .changeset/cool-onions-wink.md diff --git a/.changeset/cool-onions-wink.md b/.changeset/cool-onions-wink.md new file mode 100644 index 00000000000..61e905e26ad --- /dev/null +++ b/.changeset/cool-onions-wink.md @@ -0,0 +1,5 @@ +--- +'@graphql-tools/utils': minor +--- + +enhance(loaders): remove optional methods from the Loader interface diff --git a/packages/loaders/apollo-engine/src/index.ts b/packages/loaders/apollo-engine/src/index.ts index 21b3340b3ed..03a66398062 100644 --- a/packages/loaders/apollo-engine/src/index.ts +++ b/packages/loaders/apollo-engine/src/index.ts @@ -21,10 +21,6 @@ const DEFAULT_APOLLO_ENDPOINT = 'https://engine-graphql.apollographql.com/api/gr * This loader loads a schema from Apollo Engine */ export class ApolloEngineLoader implements Loader { - loaderId() { - return 'apollo-engine'; - } - private getFetchArgs(options: ApolloEngineOptions): [string, RequestInit] { return [ options.engine.endpoint || DEFAULT_APOLLO_ENDPOINT, diff --git a/packages/loaders/code-file/src/index.ts b/packages/loaders/code-file/src/index.ts index e943c9c57ed..42b702f9cc5 100644 --- a/packages/loaders/code-file/src/index.ts +++ b/packages/loaders/code-file/src/index.ts @@ -70,10 +70,6 @@ export class CodeFileLoader implements Loader { return { ...this.config, ...options }; } - loaderId(): string { - return 'code-file'; - } - async canLoad(pointer: string, options: CodeFileLoaderOptions): Promise { options = this.getMergedOptions(options); diff --git a/packages/loaders/git/src/index.ts b/packages/loaders/git/src/index.ts index e94607d630c..45323de54e9 100644 --- a/packages/loaders/git/src/index.ts +++ b/packages/loaders/git/src/index.ts @@ -49,10 +49,6 @@ export type GitLoaderOptions = BaseLoaderOptions & { * ``` */ export class GitLoader implements Loader { - loaderId() { - return 'git-loader'; - } - async canLoad(pointer: string) { return this.canLoadSync(pointer); } diff --git a/packages/loaders/git/tests/loader.spec.ts b/packages/loaders/git/tests/loader.spec.ts index 8c3e7d85a9e..e4521bc8a77 100644 --- a/packages/loaders/git/tests/loader.spec.ts +++ b/packages/loaders/git/tests/loader.spec.ts @@ -10,12 +10,6 @@ describe('GitLoader', () => { return `git:${lastCommit}:packages/loaders/git/tests/test-files/${fileName}`; }; - describe('loaderId', () => { - it('should return a loader id', () => { - expect(loader.loaderId()).toBeDefined(); - }); - }); - describe('canLoad', () => { runTests({ async: loader.canLoad.bind(loader), diff --git a/packages/loaders/github/src/index.ts b/packages/loaders/github/src/index.ts index f72ad9210a3..9e16a01bde6 100644 --- a/packages/loaders/github/src/index.ts +++ b/packages/loaders/github/src/index.ts @@ -47,10 +47,6 @@ export interface GithubLoaderOptions extends BaseLoaderOptions { * ``` */ export class GithubLoader implements Loader { - loaderId() { - return 'github-loader'; - } - async canLoad(pointer: string) { return typeof pointer === 'string' && pointer.toLowerCase().startsWith('github:'); } diff --git a/packages/loaders/graphql-file/src/index.ts b/packages/loaders/graphql-file/src/index.ts index e851a1b1c0c..00d092718f8 100644 --- a/packages/loaders/graphql-file/src/index.ts +++ b/packages/loaders/graphql-file/src/index.ts @@ -55,10 +55,6 @@ function createGlobbyOptions(options: GraphQLFileLoaderOptions): GlobbyOptions { * ``` */ export class GraphQLFileLoader implements Loader { - loaderId(): string { - return 'graphql-file'; - } - async canLoad(pointer: string, options: GraphQLFileLoaderOptions): Promise { if (isValidPath(pointer)) { if (FILE_EXTENSIONS.find(extension => pointer.endsWith(extension))) { diff --git a/packages/loaders/graphql-file/tests/loader.spec.ts b/packages/loaders/graphql-file/tests/loader.spec.ts index 05069ddc290..318809fb36d 100644 --- a/packages/loaders/graphql-file/tests/loader.spec.ts +++ b/packages/loaders/graphql-file/tests/loader.spec.ts @@ -12,12 +12,6 @@ describe('GraphQLFileLoader', () => { return join('packages/loaders/graphql-file/tests/test-files', fileName); }; - describe('loaderId', () => { - it('should return a loader id', () => { - expect(loader.loaderId()).toBeDefined(); - }); - }); - describe('canLoad', () => { runTests({ async: loader.canLoad.bind(loader), diff --git a/packages/loaders/json-file/src/index.ts b/packages/loaders/json-file/src/index.ts index f451ec83c83..aef595fe62b 100644 --- a/packages/loaders/json-file/src/index.ts +++ b/packages/loaders/json-file/src/index.ts @@ -36,10 +36,6 @@ export interface JsonFileLoaderOptions extends BaseLoaderOptions {} * ``` */ export class JsonFileLoader implements Loader { - loaderId(): string { - return 'json-file'; - } - async canLoad(pointer: string, options: JsonFileLoaderOptions): Promise { if (isValidPath(pointer)) { if (FILE_EXTENSIONS.find(extension => pointer.endsWith(extension))) { diff --git a/packages/loaders/json-file/tests/loader.spec.ts b/packages/loaders/json-file/tests/loader.spec.ts index 50f3887fd41..1495b115cb3 100644 --- a/packages/loaders/json-file/tests/loader.spec.ts +++ b/packages/loaders/json-file/tests/loader.spec.ts @@ -9,12 +9,6 @@ describe('JsonFileLoader', () => { return join('packages/loaders/json-file/tests/test-files', fileName); }; - describe('loaderId', () => { - it('should return a loader id', () => { - expect(loader.loaderId()).toBeDefined(); - }); - }); - describe('canLoad', () => { runTests({ async: loader.canLoad.bind(loader), diff --git a/packages/loaders/module/src/index.ts b/packages/loaders/module/src/index.ts index db7840a5770..73abae15d89 100644 --- a/packages/loaders/module/src/index.ts +++ b/packages/loaders/module/src/index.ts @@ -35,10 +35,6 @@ function extractData(pointer: string): { * ``` */ export class ModuleLoader implements Loader { - loaderId() { - return 'module-loader'; - } - private isExpressionValid(pointer: string) { return typeof pointer === 'string' && pointer.toLowerCase().startsWith('module:'); } diff --git a/packages/loaders/module/tests/loader.spec.ts b/packages/loaders/module/tests/loader.spec.ts index 220af74d42f..077b3db1a52 100644 --- a/packages/loaders/module/tests/loader.spec.ts +++ b/packages/loaders/module/tests/loader.spec.ts @@ -10,12 +10,6 @@ describe('ModuleLoader', () => { return `module:${absolutePath}${exportName ? `#${exportName}` : ''}`; }; - describe('loaderId', () => { - it('should return a loader id', () => { - expect(loader.loaderId()).toBeDefined(); - }); - }); - describe('canLoad', () => { runTests({ async: loader.canLoad.bind(loader), diff --git a/packages/loaders/prisma/src/index.ts b/packages/loaders/prisma/src/index.ts index 14e6ab025c1..7b6c68e4a95 100644 --- a/packages/loaders/prisma/src/index.ts +++ b/packages/loaders/prisma/src/index.ts @@ -20,10 +20,6 @@ export interface PrismaLoaderOptions extends LoadFromUrlOptions { * This loader loads a schema from a `prisma.yml` file */ export class PrismaLoader extends UrlLoader { - loaderId() { - return 'prisma'; - } - canLoadSync() { return false; } diff --git a/packages/loaders/url/src/index.ts b/packages/loaders/url/src/index.ts index 116915812c6..ef29e22c07f 100644 --- a/packages/loaders/url/src/index.ts +++ b/packages/loaders/url/src/index.ts @@ -163,10 +163,6 @@ const isCompatibleUri = (uri: string): boolean => { * ``` */ export class UrlLoader implements Loader { - loaderId(): string { - return 'url'; - } - async canLoad(pointer: string, options: LoadFromUrlOptions): Promise { return this.canLoadSync(pointer, options); } diff --git a/packages/utils/src/loaders.ts b/packages/utils/src/loaders.ts index 73b1d6fac24..9c6a88d15d4 100644 --- a/packages/utils/src/loaders.ts +++ b/packages/utils/src/loaders.ts @@ -18,9 +18,6 @@ export type WithList = T | T[]; export type ElementOf = TList extends Array ? TElement : never; export interface Loader { - loaderId(): string; - canLoad(pointer: string, options?: TOptions): Promise; - canLoadSync?(pointer: string, options?: TOptions): boolean; load(pointer: string, options?: TOptions): Promise; loadSync?(pointer: string, options?: TOptions): Source[] | null | never; } diff --git a/yarn.lock b/yarn.lock index f1beecbfa22..70e2bc5df86 100644 --- a/yarn.lock +++ b/yarn.lock @@ -144,21 +144,21 @@ tslib "^1.10.0" zen-observable "^0.8.14" -"@apollo/federation@0.25.2", "@apollo/federation@^0.25.2": - version "0.25.2" - resolved "https://registry.yarnpkg.com/@apollo/federation/-/federation-0.25.2.tgz#10b2e22ac20e64701fd6d31d9abbf7f411b03763" - integrity sha512-TrRCrGniHpnRwALm2J7q2c1X4Lcc95e7SeHkVjascaQx6nBZGFbBXadw8rOPxlw5syfxYf8h9winF+wwld+gsg== +"@apollo/federation@0.26.0", "@apollo/federation@^0.26.0": + version "0.26.0" + resolved "https://registry.yarnpkg.com/@apollo/federation/-/federation-0.26.0.tgz#72c89f01995bd2e066d447fed4aa58678d759bf6" + integrity sha512-j3l6lhQod630LQzLm2hhDyQQJtQikT7vRtRgIa3PuKEq6ouuOd1OQERhBnecobJlUfRWJkfvjYJ/PhQZ2sm/7Q== dependencies: apollo-graphql "^0.9.3" lodash.xorby "^4.7.0" -"@apollo/gateway@0.32.0": - version "0.32.0" - resolved "https://registry.yarnpkg.com/@apollo/gateway/-/gateway-0.32.0.tgz#639b7b826c76a2bffdf777902010485dfd981918" - integrity sha512-Pxq3VVxG1ALrFNN8SM3RVy6Kwm+5p1KG3ObVmQX720Wx5WpRKvCRC23J/c3oFRpsGqjPOglh3vmpAQVdJJTCZA== +"@apollo/gateway@0.33.0": + version "0.33.0" + resolved "https://registry.yarnpkg.com/@apollo/gateway/-/gateway-0.33.0.tgz#6e282fb88eb86d9ab9ae35d6d5d3e174085a6907" + integrity sha512-NQTFysgRzPYR8g90K43/hgH+Rxe7F/E2G2Linfc81VVNk5NruRSUeQV0EnsROC7lLbCqiCJ+WSQcN0ZaR2Jo7A== dependencies: - "@apollo/federation" "^0.25.2" - "@apollo/query-planner" "^0.2.2" + "@apollo/federation" "^0.26.0" + "@apollo/query-planner" "^0.2.3" "@opentelemetry/api" "^1.0.1" "@types/node-fetch" "2.5.10" apollo-graphql "^0.9.3" @@ -191,10 +191,10 @@ "@types/node" "^10.1.0" long "^4.0.0" -"@apollo/query-planner@^0.2.2": - version "0.2.2" - resolved "https://registry.yarnpkg.com/@apollo/query-planner/-/query-planner-0.2.2.tgz#5397e5cd8a73dede34c485fb0c5fefa054f9153a" - integrity sha512-+RZSKY0xDYki9qwlzKXDNa+jrbj0Qstq44lcB21aViiDdEJWOTwf7Cqg3h/hN7QsUnL75XiDrwsjMLnwFdHSoQ== +"@apollo/query-planner@^0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@apollo/query-planner/-/query-planner-0.2.3.tgz#8018ae12c24541838541cc7b20d6a628556918e5" + integrity sha512-3jYHLhuUTolAouVTkR1NrGH7ZQzj91KfH1L1Ddd2i2hfCG6VDj9xuRe+nznYV1Sk3/Uy226d7BPKo110H/3Pow== dependencies: chalk "^4.1.0" deep-equal "^2.0.5"