@@ -23,6 +23,44 @@ You can have one request and get any nested data you want
23
23
npm i @nazariistrohush/gql-prisma-select
24
24
```
25
25
26
+ ## Types
27
+
28
+ ### Arguments of ` new GQLPrismaSelect(info, options) ` constructor
29
+
30
+ - ` info ` - ` GraphQLResolveInfo ` object
31
+ - ` options ` - ` object ` with options
32
+ - ` options.get ` - ` string | string[] ` String split by ` . ` or an array to get custom path of selection (similar to lodash.get)
33
+ - ` options.exclude ` - ` string[] ` Fields to exclude from selection
34
+ - ` __typename ` excluded by default (because not exists in prisma model)
35
+
36
+ ### Results of ` new GQLPrismaSelect(info, options) `
37
+
38
+ - ` include ` - ` object ` with include object for Prisma
39
+ - ` select ` - ` object ` with select object for Prisma
40
+ - ` originalInclude ` - ` object ` with original include object (same as ` include ` in case ` get ` option is not used)
41
+ - ` originalSelect ` - ` object ` with original select object (same as ` select ` in case ` get ` option is not used)
42
+
43
+ ### Static methods
44
+
45
+ - ` GQLPrismaSelect.get(selection, path) ` - get some specific selections by path
46
+ - ` selection ` - ` object ` with selection ({ include, select } result of ` new GQLPrismaSelect(info, options) ` constructor)
47
+ - ` path ` - ` string | string[] ` String split by ` . ` or an array
48
+ - Used to get specific selection from select/include object
49
+
50
+ E.g. get different selections from one GQLPrismaSelect constructor call
51
+
52
+ ``` ts
53
+ const includeSelect = new GQLPrismaSelect (info );
54
+ const { include, select } = GQLPrismaSelect .get (
55
+ includeSelect ,
56
+ ' collection.User'
57
+ );
58
+ const { include : includePosts, select : selectPosts } = GQLPrismaSelect .get (
59
+ includeSelect ,
60
+ ' collection.Post'
61
+ );
62
+ ```
63
+
26
64
## Quick example
27
65
28
66
Get info from your request using ` @nestjs/graphql `
0 commit comments