type-graphql#NonEmptyArray TypeScript Examples
The following examples show how to use
type-graphql#NonEmptyArray.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: typegraphql-options.factory.ts From typegraphql-nestjs with MIT License | 6 votes |
async createGqlOptions(): Promise<GqlModuleOptions> {
const { globalMiddlewares } = this.rootModuleOptions;
const { resolversClasses, container, orphanedTypes } =
this.optionsPreparatorService.prepareOptions<TypeGraphQLFeatureModuleOptions>(
TYPEGRAPHQL_FEATURE_MODULE_OPTIONS,
globalMiddlewares,
);
const schema = await buildSchema({
...this.rootModuleOptions,
resolvers: resolversClasses as NonEmptyArray<ClassType>,
orphanedTypes,
container,
});
return {
...this.rootModuleOptions,
schema,
};
}
Example #2
Source File: index.ts From type-graphql-dataloader with MIT License | 6 votes |
export async function listen(
port: number,
resolvers: NonEmptyArray<Function>
): Promise<ListenResult> {
const app = express();
const schema = await buildSchema({
resolvers,
});
const apollo = new ApolloServer({
schema,
plugins: [
ApolloServerLoaderPlugin({
typeormGetConnection: getConnection,
}),
],
});
await apollo.start();
apollo.applyMiddleware({ app, cors: false });
const server = http.createServer(app);
await promisify(server.listen.bind(server, port))();
return {
port: (server.address() as AddressInfo).port,
close: promisify(server.close).bind(server),
};
}
Example #3
Source File: typegraphql-options-federation.factory.ts From typegraphql-nestjs with MIT License | 5 votes |
async createGqlOptions(): Promise<GqlModuleOptions> {
const { globalMiddlewares } = this.rootModuleOptions;
const {
resolversClasses,
container,
orphanedTypes,
featureModuleOptionsArray,
} = this.optionsPreparatorService.prepareOptions<TypeGraphQLFeatureFedarationModuleOptions>(
TYPEGRAPHQL_FEATURE_FEDERATION_MODULE_OPTIONS,
globalMiddlewares,
);
const referenceResolversArray = [...featureModuleOptionsArray].filter(
it => it.referenceResolvers,
);
const referenceResolvers =
referenceResolversArray.length > 0
? Object.fromEntries(
referenceResolversArray.flatMap(it =>
Object.entries(it.referenceResolvers!),
),
)
: undefined;
const baseSchema = await buildSchema({
...this.rootModuleOptions,
directives: [...specifiedDirectives, ...federationDirectives],
resolvers: resolversClasses as NonEmptyArray<ClassType>,
orphanedTypes,
container,
});
const schema = buildFederatedSchema({
typeDefs: gql(printSchema(baseSchema)),
resolvers: createResolversMap(baseSchema) as GraphQLResolverMap<any>,
});
if (referenceResolvers) {
addResolversToSchema(schema, referenceResolvers);
}
return {
...this.rootModuleOptions,
schema,
};
}
Example #4
Source File: express.ts From bouncecode-cms with GNU General Public License v3.0 | 5 votes |
resolvers: NonEmptyArray<Function> | NonEmptyArray<string> = [
__dirname + '/models/**/*.resolver.{ts,js}',
]