diff --git a/packages/next-core/src/trpc/create-trpc-next-layout.tsx b/packages/next-core/src/trpc/create-trpc-next-layout.tsx index 2776072..0ecd7c6 100644 --- a/packages/next-core/src/trpc/create-trpc-next-layout.tsx +++ b/packages/next-core/src/trpc/create-trpc-next-layout.tsx @@ -153,23 +153,28 @@ export function createTRPCNextLayout( const queryKey = getQueryKey(path, input, lastPart === 'fetchInfinite'); if (lastPart === 'fetchInfinite') { - return queryClient.fetchInfiniteQuery(queryKey, () => + return queryClient.fetchInfiniteQuery({ + queryKey: queryKey, + queryFn: () => + procedure({ + getRawInput: async () => input, + path: fullPath, + ctx, + type, + }), + initialPageParam: undefined, + }); + } + + return queryClient.fetchQuery({ + queryKey: queryKey, + queryFn: () => procedure({ getRawInput: async () => input, path: fullPath, ctx, type, - }) - ); - } - - return queryClient.fetchQuery(queryKey, () => - procedure({ - getRawInput: async () => input, - path: fullPath, - ctx, - type, - }) - ); + }), + }); }) as CreateTRPCNextLayout; } diff --git a/packages/next-demo/prisma-merge.js b/packages/next-demo/prisma-merge.js index ebd957f..ada7c1f 100644 --- a/packages/next-demo/prisma-merge.js +++ b/packages/next-demo/prisma-merge.js @@ -1,5 +1,8 @@ import { prismaMerge } from '@hyperse-io/next-prisma'; import { luciaPrismaContent } from '@hyperse-io/next-auth'; +import dotenv from 'dotenv'; + +dotenv.config(); prismaMerge({ luciaPrismaModel: luciaPrismaContent, diff --git a/packages/next-demo/prisma/schema.prisma b/packages/next-demo/prisma/schema.prisma index f902be2..013bf4b 100644 --- a/packages/next-demo/prisma/schema.prisma +++ b/packages/next-demo/prisma/schema.prisma @@ -6,6 +6,13 @@ datasource db { generator client { provider = "prisma-client-js" } +model Post { + id String @id @default(uuid()) + title String + text String + createdAt DateTime @default(now()) + updatedAt DateTime @default(now()) @updatedAt +} model User { id String @id username String @unique @@ -24,6 +31,7 @@ model Authorized { user User @relation(name: "AuthorizedToUser", fields: [userId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + @@index([userId]) } model Session { id Int @id @default(autoincrement()) @@ -33,11 +41,5 @@ model Session { user User @relation(name: "SessionToUser", fields: [userId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt -} -model Post { - id String @id @default(uuid()) - title String - text String - createdAt DateTime @default(now()) - updatedAt DateTime @default(now()) @updatedAt + @@index([userId]) } \ No newline at end of file diff --git a/packages/next-prisma/package.json b/packages/next-prisma/package.json index 0478bcb..bc52952 100644 --- a/packages/next-prisma/package.json +++ b/packages/next-prisma/package.json @@ -44,7 +44,6 @@ "dependencies": { "@prisma/generator-helper": "5.14.0", "@prisma/internals": "5.14.0", - "dotenv": "16.4.5", "glob": "^10.3.16" }, "devDependencies": { diff --git a/packages/next-prisma/src/merge.ts b/packages/next-prisma/src/merge.ts index 071e0f8..3f73205 100644 --- a/packages/next-prisma/src/merge.ts +++ b/packages/next-prisma/src/merge.ts @@ -8,11 +8,8 @@ import { type GeneratorConfig, } from '@prisma/generator-helper'; import getPrismaConfig from '@prisma/internals'; -import dotenv from 'dotenv'; import * as glob from 'glob'; -dotenv.config(); - import { deserializeEnums, deserializeDatasources,