@graphql-inspector/loaders
Advanced tools
Comparing version
@@ -11,6 +11,9 @@ 'use strict'; | ||
} | ||
register(loaderName) { | ||
register(loader) { | ||
this.loaders.push(loader); | ||
} | ||
registerModule(loaderName) { | ||
try { | ||
const loader = loadModule(`@graphql-inspector/${loaderName}-loader`); | ||
this.loaders.push(loader); | ||
this.register(loader); | ||
} | ||
@@ -23,6 +26,6 @@ catch (error) { | ||
loadSchema(pointer, options = {}) { | ||
return load.loadSchema(pointer, Object.assign({ loaders: this.loaders, assumeValid: true, assumeValidSDL: true }, options)); | ||
return load.loadSchema(pointer, Object.assign({ loaders: this.loaders }, options)); | ||
} | ||
loadDocuments(pointer, options = {}) { | ||
return load.loadDocuments(pointer, Object.assign({ loaders: this.loaders, assumeValid: true, assumeValidSDL: true }, options)); | ||
return load.loadDocuments(pointer, Object.assign({ loaders: this.loaders }, options)); | ||
} | ||
@@ -32,3 +35,3 @@ } | ||
const loaders = new LoadersRegistry(); | ||
config.loaders.forEach((loaderName) => loaders.register(loaderName)); | ||
config.loaders.forEach((loaderName) => loaders.registerModule(loaderName)); | ||
return loaders; | ||
@@ -35,0 +38,0 @@ } |
import { InspectorConfig } from '@graphql-inspector/config'; | ||
import { Source, SchemaPointerSingle } from '@graphql-tools/utils'; | ||
import { Source, UniversalLoader, SchemaPointerSingle } from '@graphql-tools/utils'; | ||
import { LoadSchemaOptions, LoadTypedefsOptions } from '@graphql-tools/load'; | ||
@@ -7,3 +7,4 @@ import { GraphQLSchema } from 'graphql'; | ||
private loaders; | ||
register(loaderName: string): void; | ||
register(loader: UniversalLoader): void; | ||
registerModule(loaderName: string): void; | ||
loadSchema(pointer: SchemaPointerSingle, options?: Omit<LoadSchemaOptions, 'loaders'>): Promise<GraphQLSchema>; | ||
@@ -10,0 +11,0 @@ loadDocuments(pointer: SchemaPointerSingle, options?: Omit<LoadTypedefsOptions, 'loaders'>): Promise<Source[]>; |
@@ -7,6 +7,9 @@ import { loadSchema, loadDocuments } from '@graphql-tools/load'; | ||
} | ||
register(loaderName) { | ||
register(loader) { | ||
this.loaders.push(loader); | ||
} | ||
registerModule(loaderName) { | ||
try { | ||
const loader = loadModule(`@graphql-inspector/${loaderName}-loader`); | ||
this.loaders.push(loader); | ||
this.register(loader); | ||
} | ||
@@ -19,6 +22,6 @@ catch (error) { | ||
loadSchema(pointer, options = {}) { | ||
return loadSchema(pointer, Object.assign({ loaders: this.loaders, assumeValid: true, assumeValidSDL: true }, options)); | ||
return loadSchema(pointer, Object.assign({ loaders: this.loaders }, options)); | ||
} | ||
loadDocuments(pointer, options = {}) { | ||
return loadDocuments(pointer, Object.assign({ loaders: this.loaders, assumeValid: true, assumeValidSDL: true }, options)); | ||
return loadDocuments(pointer, Object.assign({ loaders: this.loaders }, options)); | ||
} | ||
@@ -28,3 +31,3 @@ } | ||
const loaders = new LoadersRegistry(); | ||
config.loaders.forEach((loaderName) => loaders.register(loaderName)); | ||
config.loaders.forEach((loaderName) => loaders.registerModule(loaderName)); | ||
return loaders; | ||
@@ -31,0 +34,0 @@ } |
{ | ||
"name": "@graphql-inspector/loaders", | ||
"version": "0.0.0-canary.9cf9b2c", | ||
"version": "0.0.0-canary.da4bdcc", | ||
"description": "Loaders in GraphQL Inspector", | ||
"sideEffects": false, | ||
"peerDependencies": { | ||
"@graphql-inspector/config": "0.0.0-canary.9cf9b2c", | ||
"@graphql-inspector/config": "0.0.0-canary.da4bdcc", | ||
"@graphql-tools/utils": "^6.0.0", | ||
@@ -9,0 +9,0 @@ "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9321
0.52%88
8.64%