Skip to content

Commit 55cfd5f

Browse files
committed
Added IGraphQLPrismaSelect
1 parent fc39187 commit 55cfd5f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/helpers/extract-grapql-selections.ts

+22
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ export type IGraphQLExtractSelectionMap<T extends object = object, K extends key
1818
[ k in K ]?: string | ((parentKeys: string[], fieldName: K) => string)
1919
}
2020

21+
/**
22+
* A recursive type that supports partial `select` mapping of a `Prisma`
23+
* select.
24+
*/
25+
export type IGraphQLPrismaSelect<T extends object = object, K extends keyof T = Exclude<ObjectKeys<T>, KeysMatching<T, Date | Function>>> = {
26+
[ k in K ]?: T[ k ] extends object
27+
? (T[ k ] extends Date
28+
? boolean
29+
: (
30+
T[ k ] extends any[]
31+
? boolean
32+
: (T[ k ] extends (...args: any[]) => any
33+
? never
34+
: (boolean | {
35+
select?: IGraphQLPrismaSelect<T[ k ], keyof T[ k ]>
36+
})
37+
)
38+
)
39+
)
40+
: boolean
41+
}
42+
2143
interface IExtractGraphQLSelectionsParams<T extends object = object, K extends keyof T = Exclude<ObjectKeys<T>, KeysMatching<T, Date>>> {
2244
/**
2345
* The root node of the GraphQL request.

0 commit comments

Comments
 (0)