
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
nest-type-graphql
Advanced tools
This is a TypeGraphQL module for Nest.
I manually combine both decorators of Nestjs Graphql with TypeGraphql. idea is that the typegraphql will create the graphql schema but Nestjs will provide the resolvers and other run times.
first install it
npm install nest-type-graphql
This module can only build a GraphQLSchema it does not run a graphQL server , you can simply run a graphql server yourself. for example for apollo server you can make it this way
@Module({
imports: [TypeGraphQLModule],
})
export class ApolloMdoule implements OnModuleInit {
apolloServer: ApolloServer;
constructor(
private readonly appRefHost: ApplicationReferenceHost,
private readonly graphQLFactory: SchemaBuilder,
) {}
async onModuleInit() {
if (!this.appRefHost) {
return;
}
const httpServer = this.appRefHost.applicationRef;
if (!httpServer) {
return;
}
const app = httpServer.getInstance();
const schema = await this.graphQLFactory.build();
this.apolloServer = new ApolloServer({ schema, playground: true });
this.apolloServer.applyMiddleware({
app,
});
}
}
cause the resolvers function is provided by NestJs you cannot use
for scalar type you can use @Scalar but it does not accept name anymore you should provide it in class but it accept a type funciton like typegraphQL it
@Scalar(type => Date)
export class DateScalar {
name = 'Date';
description = 'Date custom scalar type';
parseValue(value) {
return new Date(value); // value from the client
}
serialize(value) {
return value.getTime(); // value sent to the client
}
parseLiteral(ast) {
if (ast.kind === Kind.INT) {
return parseInt(ast.value, 10); // ast value is always in string format
}
return null;
}
}
then you should use provide it in a module so it will be created and for using this scalar in schema you can use type that you provided in decorator so for this scalar we can simply write this input type
@ObjectType()
class User {
@Field()
registrationDate: Date;
}
FAQs
Bridge Between graphql and typegrapql
We found that nest-type-graphql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.