
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@smatch-corp/nestjs-pothos-apollo-driver
Advanced tools
Use pothos as GraphQL schema builder in Nest.js application.
This is NOT production ready yet. API, Module, Service may be have some break changes.
$ yarn add @smatch-corp/nestjs-pothos
Write a factory to create own SchemaBuilder
and you have to get a type and export it of your SchemaBuilder
.
// builder.ts
interface SchemaBuilderOption {}
export function createBuilder() {
const builder = new SchemaBuilder<SchemaBuilderOption>({
plugins: [],
});
builder.queryType({});
// builder.mutationType({});
// builder.subscriptionType({});
return builder;
}
export type Builder = ReturnType<typeof createBuilder>
Add PothosModule
into your AppModule.
@Module({
imports: [
// ...
PothosModule.forRoot({
builder: {
useFactory: createBuilder,
},
}),
],
controllers: [/* ... */],
providers: [/* ... */],
})
export class AppModule {}
If you're using Pothos with Prisma, you can inject your PrismaClient
and pass to your factory function as parameter.
@Module({
imports: [
// ...
PrismaModule,
PothosModule.forRoot({
builder: {
inject: [PrismaService],
useFactory: (prisma) => createBuilder(prisma),
},
}),
],
controllers: [/* ... */],
providers: [/* ... */],
})
export class AppModule {}
SchemaBuilder
and @PothosRef
, @PothosInit
Now you can use own SchemaBuilder by @Inject(SchemaBuilderToken)
. use it with @PothosRef
and @PothosInit
decorators.
@Injectable()
export class UserSchema {
constructor(
@Inject(SchemaBuilderToken) private readonly builder: Builder,
private readonly prisma: PrismaService,
) {}
@PothosRef()
user() {
return this.builder.prismaObject('User', {
fields: t => ({
id: t.exposeID('id'),
name: t.exposeString('name'),
posts: t.relation('posts'),
}),
});
}
@PothosInit()
init() {
this.builder.queryFields(t => ({
users: t.prismaField({
type: [this.user()],
resolve: (query) => this.prisma.user.findMany({ ...query }),
}),
}));
}
}
Add your injectable class it used @PothosRef
or @PothosInit
to module's providers and import from your application module.
// user.module.ts
@Module({
providers: [UserSchema],
})
export class UserModule {}
// app.module.ts
@Module({
imports: [
PrismaModule,
UserModule,
PothosModule.forRoot({ /* ... */ }),
],
})
export class AppModule {}
You can get your GraphQLSchema
by SchemaBuilderService.getSchema()
. so you can set up your GraphQL endpoint as you want. below is an example of using GraphQLModule
.
@Module({
imports: [
PrismaModule,
UserModule,
PothosModule.forRoot({ /* ... */ }),
GraphQLModule.forRootAsync<ApolloDriverConfig>({
driver: ApolloDriver,
inject: [SchemaBuilderService],
useFactory: async (schemaBuilder: SchemaBuilderService) => {
const schema = schemaBuilder.getSchema();
return {
schema,
playground: true,
// ...
};
},
}),
],
})
export class AppModule {}
To check working example, please refer example-app package.
MIT
FAQs
Unknown package
The npm package @smatch-corp/nestjs-pothos-apollo-driver receives a total of 21 weekly downloads. As such, @smatch-corp/nestjs-pothos-apollo-driver popularity was classified as not popular.
We found that @smatch-corp/nestjs-pothos-apollo-driver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.