@aws-amplify/graphql-transformer-core
Version:
A framework to transform from GraphQL SDL to AWS CloudFormation.
46 lines • 2.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransformerContextProviderRegistry = void 0;
class TransformerContextProviderRegistry {
constructor() {
this.dataSourceProviderRegistry = new Map();
this.dataSourceEnhancerRegistry = new Map();
this.registerDataSourceProvider = (type, provider) => {
const typeName = type.name.value;
if (this.dataSourceProviderRegistry.has(typeName)) {
throw new Error(`A data source has been already registered for type ${typeName}`);
}
this.dataSourceProviderRegistry.set(typeName, provider);
};
this.getDataSourceProvider = (type) => {
const typeName = type.name.value;
if (this.dataSourceProviderRegistry.has(typeName)) {
return this.dataSourceProviderRegistry.get(typeName);
}
throw new Error(`No data source provider has been registered for type ${typeName}`);
};
this.hasDataSourceProvider = (type) => {
const typeName = type.name.value;
return this.dataSourceProviderRegistry.has(typeName);
};
this.addDataSourceEnhancer = (type, provider) => {
const typeName = type.name.value;
let entry;
if (!this.dataSourceEnhancerRegistry.has(typeName)) {
entry = new Set();
this.dataSourceEnhancerRegistry.set(typeName, entry);
}
else {
entry = this.dataSourceEnhancerRegistry.get(typeName);
}
entry.add(provider);
};
this.getDataSourceEnhancers = (type) => {
var _a;
const typeName = type.name.value;
return Array.from(((_a = this.dataSourceEnhancerRegistry.get(typeName)) === null || _a === void 0 ? void 0 : _a.values()) || []);
};
}
}
exports.TransformerContextProviderRegistry = TransformerContextProviderRegistry;
//# sourceMappingURL=provider-registry.js.map