Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .changeset/fix-query-param-generated-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@opensaas/stack-cli': patch
---

Fix missing `query` parameter in generated `FindManyArgs` and `FindUniqueArgs` types

Passing a fragment to `context.db.post.findMany({ query: fragment })` or `context.db.post.findUnique({ where: { id }, query: fragment })` no longer produces a TypeScript error. The generator now emits `query?: Fragment<PostOutput, FieldSelection<PostOutput>>` in the relevant args types.
6 changes: 4 additions & 2 deletions packages/cli/src/commands/__snapshots__/generate.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ exports[`Generate Command Integration > Generator Integration > should generate
* DO NOT EDIT - This file is automatically generated
*/

import type { Session as OpensaasSession, StorageUtils, ServerActionProps, AccessControlledDB, AccessContext } from '@opensaas/stack-core'
import type { Session as OpensaasSession, StorageUtils, ServerActionProps, AccessControlledDB, AccessContext, Fragment, FieldSelection } from '@opensaas/stack-core'
import type { PrismaClient, Prisma } from './prisma-client/client'
import type { PluginServices } from './plugin-types'

Expand Down Expand Up @@ -272,13 +272,15 @@ export type UserDefaultArgs = {
*/
export type UserFindUniqueArgs = Omit<Prisma.UserFindUniqueArgs, 'select'> & {
select?: UserSelect | null
query?: Fragment<UserOutput, FieldSelection<UserOutput>>
}

/**
* Custom FindManyArgs for User with virtual field support
*/
export type UserFindManyArgs = Omit<Prisma.UserFindManyArgs, 'select'> & {
select?: UserSelect | null
query?: Fragment<UserOutput, FieldSelection<UserOutput>>
}

/**
Expand Down Expand Up @@ -447,7 +449,7 @@ exports[`Generate Command Integration > Generator Integration > should handle em
* DO NOT EDIT - This file is automatically generated
*/

import type { Session as OpensaasSession, StorageUtils, ServerActionProps, AccessControlledDB, AccessContext } from '@opensaas/stack-core'
import type { Session as OpensaasSession, StorageUtils, ServerActionProps, AccessControlledDB, AccessContext, Fragment, FieldSelection } from '@opensaas/stack-core'
import type { PrismaClient, Prisma } from './prisma-client/client'
import type { PluginServices } from './plugin-types'

Expand Down
Loading
Loading