From 592ffd3be1c93226a900aa6f5e7ca1a403e673da Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Thu, 23 Feb 2023 11:45:54 -1000 Subject: [PATCH] fix name option for prisma node --- .changeset/tricky-suns-bake.md | 5 +++++ packages/plugin-prisma/src/schema-builder.ts | 1 + .../tests/__snapshots__/index.test.ts.snap | 14 +++++++------- .../plugin-prisma/tests/example/schema/index.ts | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .changeset/tricky-suns-bake.md diff --git a/.changeset/tricky-suns-bake.md b/.changeset/tricky-suns-bake.md new file mode 100644 index 000000000..4d908efc9 --- /dev/null +++ b/.changeset/tricky-suns-bake.md @@ -0,0 +1,5 @@ +--- +'@pothos/plugin-prisma': patch +--- + +Fix name option for prismaNode diff --git a/packages/plugin-prisma/src/schema-builder.ts b/packages/plugin-prisma/src/schema-builder.ts index 75fcc11f2..dc0e0043c 100644 --- a/packages/plugin-prisma/src/schema-builder.ts +++ b/packages/plugin-prisma/src/schema-builder.ts @@ -93,6 +93,7 @@ schemaBuilderProto.prismaNode = function prismaNode( const extendedOptions = { ...options, + name, variant, interfaces: [interfaceRef], findUnique, diff --git a/packages/plugin-prisma/tests/__snapshots__/index.test.ts.snap b/packages/plugin-prisma/tests/__snapshots__/index.test.ts.snap index 52b69c798..0ae5da722 100644 --- a/packages/plugin-prisma/tests/__snapshots__/index.test.ts.snap +++ b/packages/plugin-prisma/tests/__snapshots__/index.test.ts.snap @@ -61,11 +61,6 @@ type FindUniqueRelations { withUniqueNode: WithUniqueNode! } -type Follow { - from: User! - to: User! -} - type Media { url: String! } @@ -300,7 +295,7 @@ type SelectUserFollowingConnection { type SelectUserFollowingConnectionEdge { cursor: String! - node: Follow! + node: UserFollow! } type SelectUserPostsConnection { @@ -362,6 +357,11 @@ type UserCommentsConnectionEdge { union UserDirectProfileWithErrorsResult = BaseError | Profile +type UserFollow { + from: User! + to: User! +} + type UserFollowingConnection { edges: [UserFollowingConnectionEdge]! pageInfo: PageInfo! @@ -369,7 +369,7 @@ type UserFollowingConnection { type UserFollowingConnectionEdge { cursor: String! - node: Follow! + node: UserFollow! } union UserOrProfile = Profile | User diff --git a/packages/plugin-prisma/tests/example/schema/index.ts b/packages/plugin-prisma/tests/example/schema/index.ts index bbe6eb4af..63fe737f3 100644 --- a/packages/plugin-prisma/tests/example/schema/index.ts +++ b/packages/plugin-prisma/tests/example/schema/index.ts @@ -107,6 +107,7 @@ const ViewerNode = builder.prismaNode('User', { }); builder.prismaObject('Follow', { + name: 'UserFollow', fields: (t) => ({ to: t.relation('to'), from: t.relation('from'),