@microbackend/plugin-type-graphql
v1.0.1
Published
Micro-backend type-graphql plugin
Downloads
4
Readme
@microbackend/plugin-type-graphql
Microbackend plugin to add core support for TypeGraphQL, without any specific server implementation.
Dependency
Installation
npx microbackend plugin add @microbackend/plugin-type-graphql
Usage
The extension patterns supported by this plugin are:
- TypeGraphQL Resolvers, supported by
extension/type_graphql/resolver
: Classes that are marked asResolver
and consumed by TypeGraphQL to generate GraphQL schema and resolvers.
Resolver
Define new resolvers under src/extension/type_graphql/resolver
using
TypeGraphQL decorators:
// extension/type_graphql/resolver/common.ts
import { Directive, ObjectType, Query, Resolver } from "type-graphql";
@ObjectType()
export class Test {}
@Resolver(() => Test)
export class TestResolver {
@Directive("@custom_directive")
@Query(() => Number)
async test(): Promise<number> {
return 1;
}
}
These resolvers will be loaded at runtime automatically and added to TypeGraphQL's configuration. For more information on how to use TypeGraphQL itself, please refer to its official documentation.