Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return __awaiter(this, void 0, void 0, function* () {
try {
// load schema
const gQlSdlPattern = this.ENVIRONMENT.path + this.schemaBuilderConfig.schemaPattern;
this.gQlSdl = yield helper_1.AHelper.loadFilesByGlobPattern(gQlSdlPattern);
// check if any files were loaded
if (this.gQlSdl.length === 0) {
this.logger.warn("boot.no.sdl.files.found");
return;
}
// Combine all Schemas to a big one and add extensions from other modules
const gQlSdlCombined = this.gQlSdl.concat(this.gqlSdlExtensions.slice()).join("\n");
this.gQlAst = helper_2.AGraphQlHelper.parseGraphQlSchema(gQlSdlCombined);
this.dbMeta = gQlAstToDbMeta_1.parseGQlAstToDbMeta(this.gQlAst);
// load permissions and expressions and generate views and put them into schemas
// load permissions
const permissionsPattern = this.ENVIRONMENT.path + this.schemaBuilderConfig.permissionsPattern;
const permissionsArray = yield helper_1.AHelper.requireFilesByGlobPattern(permissionsPattern);
this.permissions = [].concat.apply([], permissionsArray);
// load expressions
const expressionsPattern = this.ENVIRONMENT.path + this.schemaBuilderConfig.expressionsPattern;
// load schema
const gQlSdlPattern = this.ENVIRONMENT.path + this.schemaBuilderConfig.schemaPattern;
this.gQlSdl = yield helper_1.AHelper.loadFilesByGlobPattern(gQlSdlPattern);
// check if any files were loaded
if (this.gQlSdl.length === 0) {
this.logger.warn("boot.no.sdl.files.found");
return;
}
// Combine all Schemas to a big one and add extensions from other modules
const gQlSdlCombined = this.gQlSdl.concat(this.gqlSdlExtensions.slice()).join("\n");
this.gQlAst = helper_2.AGraphQlHelper.parseGraphQlSchema(gQlSdlCombined);
this.dbMeta = gQlAstToDbMeta_1.parseGQlAstToDbMeta(this.gQlAst);
// load permissions and expressions and generate views and put them into schemas
// load permissions
const permissionsPattern = this.ENVIRONMENT.path + this.schemaBuilderConfig.permissionsPattern;
const permissionsArray = yield helper_1.AHelper.requireFilesByGlobPattern(permissionsPattern);
this.permissions = [].concat.apply([], permissionsArray);
// load expressions
const expressionsPattern = this.ENVIRONMENT.path + this.schemaBuilderConfig.expressionsPattern;
const expressionsArray = yield helper_1.AHelper.requireFilesByGlobPattern(expressionsPattern);
this.expressions = [].concat.apply([], expressionsArray);
const dbConfig = this.config.getConfig("Db");
const config = {
schemaName: dbConfig.viewSchemaName,
userName: dbConfig.general.user,
databaseName: dbConfig.general.database
};
const context = {
gqlDocument: this.gQlAst,
dbMeta: this.dbMeta,
expressions: this.expressions
};
return __awaiter(this, void 0, void 0, function* () {
const gqlKoaRouter = new KoaRouter();
// Load resolvers
const resolversPattern = this.ENVIRONMENT.path + this.graphQlConfig.resolversPattern;
this.addResolvers(yield helper_1.AHelper.requireFilesByGlobPatternAsObject(resolversPattern));
const { gqlRuntimeDocument, dbMeta, resolverMeta } = this.schemaBuilder.getGQlRuntimeObject();
const runtimeSchema = this.prepareSchema(gqlRuntimeDocument, dbMeta, resolverMeta);
const schema = graphql_tools_1.makeExecutableSchema({
typeDefs: runtimeSchema,
resolvers: resolvers_1.getResolvers(this.operations, this.resolvers, this.hooks, this.dbGeneralPool, this.logger)
});
this.apolloSchema = schema;
this.apolloClient = new apollo_client_1.ApolloClient({
ssrMode: true,
cache: new apollo_cache_inmemory_1.InMemoryCache(),
link: new apollo_link_schema_1.SchemaLink({
schema: this.apolloSchema,
context: {
ctx: {},
accessToken: null
}
return __awaiter(this, void 0, void 0, function* () {
try {
// load schema
const gQlSdlPattern = this.ENVIRONMENT.path + this.graphQlConfig.schemaPattern;
this.gQlSdl = yield helper_2.helper.loadFilesByGlobPattern(gQlSdlPattern);
// Combine all Schemas to a big one and add extensions from other modules
const gQlSdlCombined = this.gQlSdl.concat(this.gQlSdlExtensions.slice()).join('\n');
this.gQlAst = helper_1.graphQl.helper.parseGraphQlSchema(gQlSdlCombined);
this.dbMeta = gQlAstToDbMeta_1.parseGQlAstToDbMeta(this.gQlAst);
// load permissions and expressions and generate views and put them into schemas
try {
// load permissions
const viewsPattern = this.ENVIRONMENT.path + this.graphQlConfig.viewsPattern;
const viewsArray = yield helper_2.helper.requireFilesByGlobPattern(viewsPattern);
this.views = [].concat.apply([], viewsArray);
// load expressions
const expressionsPattern = this.ENVIRONMENT.path + this.graphQlConfig.expressionsPattern;
const expressionsArray = yield helper_2.helper.requireFilesByGlobPattern(expressionsPattern);
this.expressions = [].concat.apply([], expressionsArray);
const viewSchemaName = di_1.Container.get(config_1.Config).getConfig('db').viewSchemaName;
const combinedSchemaInformation = parser_1.runtimeParser(this.gQlAst, this.views, this.expressions, this.dbMeta, viewSchemaName, this.parsers);
// load schema
const gQlSdlPattern = this.ENVIRONMENT.path + this.graphQlConfig.schemaPattern;
this.gQlSdl = yield helper_2.helper.loadFilesByGlobPattern(gQlSdlPattern);
// Combine all Schemas to a big one and add extensions from other modules
const gQlSdlCombined = this.gQlSdl.concat(this.gQlSdlExtensions.slice()).join('\n');
this.gQlAst = helper_1.graphQl.helper.parseGraphQlSchema(gQlSdlCombined);
this.dbMeta = gQlAstToDbMeta_1.parseGQlAstToDbMeta(this.gQlAst);
// load permissions and expressions and generate views and put them into schemas
try {
// load permissions
const viewsPattern = this.ENVIRONMENT.path + this.graphQlConfig.viewsPattern;
const viewsArray = yield helper_2.helper.requireFilesByGlobPattern(viewsPattern);
this.views = [].concat.apply([], viewsArray);
// load expressions
const expressionsPattern = this.ENVIRONMENT.path + this.graphQlConfig.expressionsPattern;
const expressionsArray = yield helper_2.helper.requireFilesByGlobPattern(expressionsPattern);
this.expressions = [].concat.apply([], expressionsArray);
const viewSchemaName = di_1.Container.get(config_1.Config).getConfig('db').viewSchemaName;
const combinedSchemaInformation = parser_1.runtimeParser(this.gQlAst, this.views, this.expressions, this.dbMeta, viewSchemaName, this.parsers);
this.gQlRuntimeDocument = combinedSchemaInformation.document;
this.gQlRuntimeSchema = helper_1.graphQl.helper.printGraphQlDocument(this.gQlRuntimeDocument);
this.gQlTypes = combinedSchemaInformation.gQlTypes;
this.queries = combinedSchemaInformation.queries;
this.mutations = combinedSchemaInformation.mutations;
this.customOperations = {
fields: combinedSchemaInformation.customFields,
queries: combinedSchemaInformation.customQueries,
mutations: combinedSchemaInformation.customMutations
};
Object.values(combinedSchemaInformation.dbViews).forEach((dbView) => {
if (this.dbMeta.schemas[dbView.viewSchemaName] == null) {
this.dbMeta.schemas[dbView.viewSchemaName] = {
const gQlSdlCombined = this.gQlSdl.concat(this.gQlSdlExtensions.slice()).join('\n');
this.gQlAst = gQLHelper.helper.parseGraphQlSchema(gQlSdlCombined);
this.dbMeta = parseGQlAstToDbMeta(this.gQlAst);
// load permissions and expressions and generate views and put them into schemas
try {
// load permissions
const viewsPattern = this.ENVIRONMENT.path + this.graphQlConfig.viewsPattern;
const viewsArray = await helper.requireFilesByGlobPattern(viewsPattern);
this.views = [].concat.apply([], viewsArray);
// load expressions
const expressionsPattern = this.ENVIRONMENT.path + this.graphQlConfig.expressionsPattern;
const expressionsArray = await helper.requireFilesByGlobPattern(expressionsPattern);
this.expressions = [].concat.apply([], expressionsArray);
const viewSchemaName = Container.get(Config).getConfig('db').viewSchemaName;
const combinedSchemaInformation = runtimeParser(this.gQlAst, this.views, this.expressions, this.dbMeta, viewSchemaName, this.parsers);
this.gQlRuntimeDocument = combinedSchemaInformation.document;
this.gQlRuntimeSchema = gQLHelper.helper.printGraphQlDocument(this.gQlRuntimeDocument);
this.gQlTypes = combinedSchemaInformation.gQlTypes;
this.queries = combinedSchemaInformation.queries;
this.mutations = combinedSchemaInformation.mutations;
this.customOperations = {
fields: combinedSchemaInformation.customFields,
queries: combinedSchemaInformation.customQueries,
mutations: combinedSchemaInformation.customMutations
this.logger.warn('boot.no.sdl.files.found');
return;
}
// Combine all Schemas to a big one and add extensions from other modules
const gQlSdlCombined = this.gQlSdl.concat(this.gQlSdlExtensions.slice()).join('\n');
this.gQlAst = gQLHelper.helper.parseGraphQlSchema(gQlSdlCombined);
this.dbMeta = parseGQlAstToDbMeta(this.gQlAst);
// load permissions and expressions and generate views and put them into schemas
try {
// load permissions
const viewsPattern = this.ENVIRONMENT.path + this.graphQlConfig.viewsPattern;
const viewsArray = await helper.requireFilesByGlobPattern(viewsPattern);
this.views = [].concat.apply([], viewsArray);
// load expressions
const expressionsPattern = this.ENVIRONMENT.path + this.graphQlConfig.expressionsPattern;
const expressionsArray = await helper.requireFilesByGlobPattern(expressionsPattern);
this.expressions = [].concat.apply([], expressionsArray);
const viewSchemaName = Container.get(Config).getConfig('db').viewSchemaName;
const combinedSchemaInformation = runtimeParser(this.gQlAst, this.views, this.expressions, this.dbMeta, viewSchemaName, this.parsers);
this.gQlRuntimeDocument = combinedSchemaInformation.document;
this.gQlRuntimeSchema = gQLHelper.helper.printGraphQlDocument(this.gQlRuntimeDocument);
this.gQlTypes = combinedSchemaInformation.gQlTypes;
this.queries = combinedSchemaInformation.queries;
this.mutations = combinedSchemaInformation.mutations;
private async boot(): Promise {
try {
this.logger.trace("boot", "started");
this.extendSchema(this.orm.getGraphQlSDL());
// load schema
const gQlSdlPattern = this.ENVIRONMENT.path + this.schemaBuilderConfig.schemaPattern;
this.gQlSdl = await AHelper.loadFilesByGlobPattern(gQlSdlPattern);
this.logger.trace("boot", "GraphQl schema loaded");
// check if any files were loaded
if (this.gQlSdl.length === 0) {
this.logger.warn("boot.no.sdl.files.found");
return;
}
// Combine all Schemas to a big one and add extensions from other modules
const gQlSdlCombined = this.gQlSdl.concat(this.gqlSdlExtensions.slice()).join("\n");
this.gQlAst = AGraphQlHelper.parseGraphQlSchema(gQlSdlCombined);
this.logger.trace("boot", "GraphQl schema parsed");
this.dbMeta = parseGQlAstToDbMeta(this.gQlAst);
this.logger.trace("boot", "GraphQl AST parsed");
private async boot(): Promise {
try {
// load schema
const gQlSdlPattern = this.ENVIRONMENT.path + this.graphQlConfig.schemaPattern;
this.gQlSdl = await helper.loadFilesByGlobPattern(gQlSdlPattern);
// check if any files were loaded
if (this.gQlSdl.length === 0) {
this.logger.warn('boot.no.sdl.files.found');
return;
}
// Combine all Schemas to a big one and add extensions from other modules
const gQlSdlCombined = this.gQlSdl.concat(this.gQlSdlExtensions.slice()).join('\n');
this.gQlAst = gQLHelper.helper.parseGraphQlSchema(gQlSdlCombined);
this.dbMeta = parseGQlAstToDbMeta(this.gQlAst);
// load permissions and expressions and generate views and put them into schemas
try {
private async boot() {
const gqlKoaRouter = new KoaRouter();
// Load resolvers
const resolversPattern = this.ENVIRONMENT.path + this.graphQlConfig.resolversPattern;
this.addResolvers(await helper.requireFilesByGlobPatternAsObject(resolversPattern));
const gQlRuntimeObject = this.gqlParser.getGQlRuntimeObject();
let customOperations: any = {};
if (gQlRuntimeObject.customOperations == null) {
this.logger.warn('boot.no.resolver.files.found');
gQlRuntimeObject.customOperations = {};
return;
} else {
customOperations = JSON.parse(JSON.stringify(gQlRuntimeObject.customOperations));
customOperations.queries = customOperations.queries.concat(this.customQueries.slice());
customOperations.mutations = customOperations.mutations.concat(this.customMutations.slice());
customOperations.fields = Object.assign(customOperations.fields, this.customFields);
}
const schema = makeExecutableSchema({