Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 153 additions & 115 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@
"typegraphql-prisma": "lib/generator.js"
},
"peerDependencies": {
"@prisma/client": "^5.18.0",
"@prisma/client": "^6.0.0",
"@types/graphql-fields": "^1.3.9",
"@types/node": "*",
"graphql-fields": "^2.0.3",
"graphql-scalars": "^1.23.0",
"prisma": "^5.18.0",
"prisma": "^6.0.0",
"tslib": "^2.6.3",
"type-graphql": "^1.1.1 || >=1.2.0-rc || >=2.0.0-beta || >=2.0.0-rc"
},
"dependencies": {
"@prisma/generator-helper": "^5.18.0",
"@prisma/internals": "^5.18.0",
"@prisma/generator-helper": "^6.3.1",
"@prisma/internals": "^6.3.1",
"pluralize": "^8.0.0",
"semver": "^7.6.3",
"ts-morph": "^23.0.0",
"tslib": "^2.6.3"
},
"devDependencies": {
"@jest/types": "^29.6.3",
"@prisma/client": "^5.18.0",
"@prisma/client": "^6.3.1",
"@types/graphql-fields": "^1.3.9",
"@types/jest": "^29.5.12",
"@types/node": "^22.1.0",
Expand All @@ -57,7 +57,7 @@
"pg": "^8.12.0",
"prettier": "^3.3.3",
"prettier-2": "npm:prettier@^2",
"prisma": "^5.18.0",
"prisma": "^6.3.1",
"reflect-metadata": "0.1.13",
"ts-jest": "~29.2.4",
"ts-node": "^10.9.2",
Expand Down
1 change: 1 addition & 0 deletions src/generator/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const supportedMutationActions = [
"updateOne",
"deleteMany",
"updateMany",
"updateManyAndReturn",
"upsertOne",
] satisfies (keyof typeof DMMF.ModelAction)[];
export type SupportedMutations = (typeof supportedMutationActions)[number];
Expand Down
12 changes: 12 additions & 0 deletions src/generator/dmmf/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,18 @@ export function getMappedOutputTypeName(
return `CreateManyAndReturn${modelTypeName}`;
}

if (
outputTypeName.startsWith("UpdateMany") &&
outputTypeName.endsWith("AndReturnOutputType")
) {
const modelTypeName = dmmfDocument.getModelTypeName(
outputTypeName
.replace("UpdateMany", "")
.replace("AndReturnOutputType", ""),
);
return `UpdateManyAndReturn${modelTypeName}`;
}

if (dmmfDocument.isModelName(outputTypeName)) {
return dmmfDocument.getModelTypeName(outputTypeName)!;
}
Expand Down
3 changes: 2 additions & 1 deletion src/generator/dmmf/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export namespace DMMF {
}>;
export type FieldDefault = ReadonlyDeep<{
name: string;
args: any[];
args: (string | number)[];
}>;
export type FieldDefaultScalar = string | boolean | number;
export type Schema = ReadonlyDeep<{
Expand Down Expand Up @@ -247,6 +247,7 @@ export namespace DMMF {
createManyAndReturn = "createManyAndReturn",
updateOne = "updateOne",
updateMany = "updateMany",
updateManyAndReturn = "updateManyAndReturn",
upsertOne = "upsertOne",
deleteOne = "deleteOne",
deleteMany = "deleteMany",
Expand Down
1 change: 1 addition & 0 deletions src/generator/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function getInputKeywordPhrasePosition(inputTypeName: string) {
"Upsert",
"ScalarWhere",
"Where",
"ScalarRelationFilter",
"ListRelationFilter",
"RelationFilter",
"Filter",
Expand Down
45 changes: 33 additions & 12 deletions tests/functional/__snapshots__/integration.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ type Mutation {
createManyUser(data: [UserCreateManyInput!]!, skipDuplicates: Boolean): AffectedRowsOutput!
createOnePost(data: PostCreateInput!): Post!
createOneUser(data: UserCreateInput): User!
deleteManyPost(where: PostWhereInput): AffectedRowsOutput!
deleteManyUser(where: UserWhereInput): AffectedRowsOutput!
deleteManyPost(limit: Int, where: PostWhereInput): AffectedRowsOutput!
deleteManyUser(limit: Int, where: UserWhereInput): AffectedRowsOutput!
deleteOnePost(where: PostWhereUniqueInput!): Post
deleteOneUser(where: UserWhereUniqueInput!): User
updateManyPost(data: PostUpdateManyMutationInput!, where: PostWhereInput): AffectedRowsOutput!
updateManyUser(data: UserUpdateManyMutationInput!, where: UserWhereInput): AffectedRowsOutput!
updateManyAndReturnPost(data: PostUpdateManyMutationInput!, limit: Int, where: PostWhereInput): [UpdateManyAndReturnPost!]!
updateManyAndReturnUser(data: UserUpdateManyMutationInput!, limit: Int, where: UserWhereInput): [UpdateManyAndReturnUser!]!
updateManyPost(data: PostUpdateManyMutationInput!, limit: Int, where: PostWhereInput): AffectedRowsOutput!
updateManyUser(data: UserUpdateManyMutationInput!, limit: Int, where: UserWhereInput): AffectedRowsOutput!
updateOnePost(data: PostUpdateInput!, where: PostWhereUniqueInput!): Post
updateOneUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User
upsertOnePost(create: PostCreateInput!, update: PostUpdateInput!, where: PostWhereUniqueInput!): Post!
Expand Down Expand Up @@ -481,7 +483,7 @@ input PostWhereInput {
AND: [PostWhereInput!]
NOT: [PostWhereInput!]
OR: [PostWhereInput!]
author: UserRelationFilter
author: UserScalarRelationFilter
authorId: IntFilter
color: EnumColorFilter
content: StringFilter
Expand All @@ -492,7 +494,7 @@ input PostWhereUniqueInput {
AND: [PostWhereInput!]
NOT: [PostWhereInput!]
OR: [PostWhereInput!]
author: UserRelationFilter
author: UserScalarRelationFilter
authorId: IntFilter
color: EnumColorFilter
content: StringFilter
Expand Down Expand Up @@ -601,6 +603,19 @@ input StringWithAggregatesFilter {
startsWith: String
}

type UpdateManyAndReturnPost {
author: User!
authorId: Int!
color: Color!
content: String!
uuid: String!
}

type UpdateManyAndReturnUser {
id: Int!
name: String
}

type User {
_count: UserCount
id: Int!
Expand Down Expand Up @@ -702,16 +717,16 @@ input UserOrderByWithRelationInput {
posts: PostOrderByRelationAggregateInput
}

input UserRelationFilter {
is: UserWhereInput
isNot: UserWhereInput
}

enum UserScalarFieldEnum {
id
name
}

input UserScalarRelationFilter {
is: UserWhereInput
isNot: UserWhereInput
}

input UserScalarWhereWithAggregatesInput {
AND: [UserScalarWhereWithAggregatesInput!]
NOT: [UserScalarWhereWithAggregatesInput!]
Expand Down Expand Up @@ -814,6 +829,7 @@ exports[`generator integration should generates TypeGraphQL classes files to out
FindUniquePostResolver.ts
GroupByPostResolver.ts
PostCrudResolver.ts
UpdateManyAndReturnPostResolver.ts
UpdateManyPostResolver.ts
UpdateOnePostResolver.ts
UpsertOnePostResolver.ts
Expand All @@ -830,6 +846,7 @@ exports[`generator integration should generates TypeGraphQL classes files to out
FindUniquePostArgs.ts
FindUniquePostOrThrowArgs.ts
GroupByPostArgs.ts
UpdateManyAndReturnPostArgs.ts
UpdateManyPostArgs.ts
UpdateOnePostArgs.ts
UpsertOnePostArgs.ts
Expand All @@ -847,6 +864,7 @@ exports[`generator integration should generates TypeGraphQL classes files to out
FindUniqueUserOrThrowResolver.ts
FindUniqueUserResolver.ts
GroupByUserResolver.ts
UpdateManyAndReturnUserResolver.ts
UpdateManyUserResolver.ts
UpdateOneUserResolver.ts
UpsertOneUserResolver.ts
Expand All @@ -864,6 +882,7 @@ exports[`generator integration should generates TypeGraphQL classes files to out
FindUniqueUserArgs.ts
FindUniqueUserOrThrowArgs.ts
GroupByUserArgs.ts
UpdateManyAndReturnUserArgs.ts
UpdateManyUserArgs.ts
UpdateOneUserArgs.ts
UpsertOneUserArgs.ts
Expand Down Expand Up @@ -934,7 +953,7 @@ exports[`generator integration should generates TypeGraphQL classes files to out
UserMinOrderByAggregateInput.ts
UserOrderByWithAggregationInput.ts
UserOrderByWithRelationInput.ts
UserRelationFilter.ts
UserScalarRelationFilter.ts
UserScalarWhereWithAggregatesInput.ts
UserSumOrderByAggregateInput.ts
UserUpdateInput.ts
Expand All @@ -958,6 +977,8 @@ exports[`generator integration should generates TypeGraphQL classes files to out
PostMaxAggregate.ts
PostMinAggregate.ts
PostSumAggregate.ts
UpdateManyAndReturnPost.ts
UpdateManyAndReturnUser.ts
UserAvgAggregate.ts
UserCount.ts
UserCountAggregate.ts
Expand Down
Loading