Fork of typegraphql-prisma
This project is a fork of another with minor changes, created for personal use.
Long term support is not guaranteed, use of this copy is at your own risk.
npm install typegraphql-prisma-nestjs --save-dev
Original:
import { Ctx, Query, Resolver } from "type-graphql";
In fork:
import { Context, Query, Resolver } from "@nestjs/graphql";
Append transformArgsIntoPrismaArgs and setTransformArgsIntoPrismaArgs for modify args before send it to prisma
PR: https://github.com/MichalLytek/typegraphql-prisma/pull/399
Sample fork with this integrations: https://github.com/EndyKaufman/typegraphql-prisma-nestjs/commit/f80d055a9aad227502d023c673ba9eed28d5cc9b
Sample application with this feature: https://github.com/EndyKaufman/typegraphql-prisma-nestjs-example/commit/c43118e952bee58e2620f159fcc62c2595a9189b
@TypeGraphQL.optional(input: ["create", "update"])
setTransformArgsIntoPrismaArgs(async function <
TArgs = Record<string, any>,
TContext = any,
>(
info: GraphQLResolveInfo,
args: TArgs,
ctx: TContext,
modelName?: string,
collectionName?: string,
prismaMethod?: string,
afterProcessEvents?: ((result: any) => Promise<any>)[],
): Promise<TArgs> {
// ...some logic before request to prisma
afterProcessEvents?.push(async function (result) {
// ...some logic after request to prisma, variable result store output data
});
return args;
});
emitActions: 'findUnique, findUniqueOrThrow, findFirst, findFirstOrThrow, findMany, createOne, createMany, createManyAndReturn, updateOne, updateMany, deleteOne, deleteMany, upsertOne, aggregate, groupBy'
emitPropertyMethods: 'create, connectOrCreate, upsert, set, disconnect, delete, connect, update, updateMany, deleteMany'
https://github.com/EndyKaufman/typegraphql-prisma-nestjs-example
Prisma generator to emit TypeGraphQL types and CRUD resolvers from your Prisma schema.
https://prisma.typegraphql.com
The documentation, installation guide, detailed description of the API and all of its features is available on the website.
You can check out some usage examples on this repo:
https://github.com/EndyKaufman/typegraphql-prisma-nestjs-example
Currently released version 0.x
is just a preview of the upcoming integration. For now it lacks some customization option - picking models or fields of object types to expose in the schema, hiding input fields as well as picking exposed args fields. However, the base functionality is working well, so I strongly encourage you to give it a try and play with it.
Any feedback about the developers experience or ideas about new features or enhancements are very welcome - please feel free to put your two cents by using the GitHub Discussions feature:
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
This project is not sponsored by Prisma anymore, so there will be provided only bug fixes and Prisma compatibility upgrades. You can read more about this in the GitHub issue #385.
Let's keep typegraphql-prisma
alive together! 💪
- Visit the Official Website
- Chat on Discord