@pothos/plugin-prisma 3.38.1 → 3.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +314 -234
- package/dts/global-types.d.ts +5 -5
- package/dts/global-types.d.ts.map +1 -1
- package/dts/index.d.ts +2 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/prisma-field-builder.d.ts +4 -4
- package/dts/prisma-field-builder.d.ts.map +1 -1
- package/dts/util/cursors.d.ts +3 -2
- package/dts/util/cursors.d.ts.map +1 -1
- package/esm/global-types.d.ts +9 -5
- package/esm/global-types.d.ts.map +1 -1
- package/esm/global-types.js.map +1 -1
- package/esm/index.d.ts +2 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -1
- package/esm/prisma-field-builder.d.ts +6 -4
- package/esm/prisma-field-builder.d.ts.map +1 -1
- package/esm/prisma-field-builder.js.map +1 -1
- package/esm/util/cursors.d.ts +3 -2
- package/esm/util/cursors.d.ts.map +1 -1
- package/esm/util/cursors.js +9 -6
- package/esm/util/cursors.js.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/prisma-field-builder.js.map +1 -1
- package/lib/util/cursors.js +12 -8
- package/lib/util/cursors.js.map +1 -1
- package/package.json +3 -3
- package/src/global-types.ts +13 -2
- package/src/index.ts +2 -1
- package/src/prisma-field-builder.ts +7 -2
- package/src/util/cursors.ts +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.40.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 75d13217: Export utils for formatting prisma cursors
|
|
8
|
+
|
|
9
|
+
## 3.39.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- c3db3bcd: Enable adding interfaces to connections and edges
|
|
14
|
+
|
|
3
15
|
## 3.38.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -600,6 +600,105 @@ use
|
|
|
600
600
|
|
|
601
601
|
`builder.prismaObjectField` or `builder.prismaObjectFields` instead.
|
|
602
602
|
|
|
603
|
+
## Type variants
|
|
604
|
+
|
|
605
|
+
The prisma plugin supports defining multiple GraphQL types based on the same prisma model.
|
|
606
|
+
Additional types are called `variants`. You will always need to have a "Primary" variant (defined as
|
|
607
|
+
described above). Additional variants can be defined by providing a `variant` option instead of a
|
|
608
|
+
`name` option when creating the type:
|
|
609
|
+
|
|
610
|
+
```typescript
|
|
611
|
+
const Viewer = builder.prismaObject('User', {
|
|
612
|
+
variant: 'Viewer',
|
|
613
|
+
fields: (t) => ({
|
|
614
|
+
id: t.exposeID('id'),
|
|
615
|
+
});
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
You can define variant fields that reference one variant from another:
|
|
619
|
+
|
|
620
|
+
```typescript
|
|
621
|
+
const Viewer = builder.prismaObject('User', {
|
|
622
|
+
variant: 'Viewer',
|
|
623
|
+
fields: (t) => ({
|
|
624
|
+
id: t.exposeID('id'),
|
|
625
|
+
// Using the model name ('User') will reference the primary variant
|
|
626
|
+
user: t.variant('User'),
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const User = builder.prismaNode('User', {
|
|
631
|
+
id: {
|
|
632
|
+
resolve: (user) => user.id,
|
|
633
|
+
},
|
|
634
|
+
fields: (t) => ({
|
|
635
|
+
// To reference another variant, use the returned object Ref instead of the model name:
|
|
636
|
+
viewer: t.variant(Viewer, {
|
|
637
|
+
// return null for viewer if the parent User is not the current user
|
|
638
|
+
isNull: (user, args, ctx) => user.id !== ctx.user.id,
|
|
639
|
+
}),
|
|
640
|
+
email: t.exposeString('email'),
|
|
641
|
+
}),
|
|
642
|
+
});
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
You can also use variants when defining relations by providing a `type` option:
|
|
646
|
+
|
|
647
|
+
```typescript
|
|
648
|
+
const PostDraft = builder.prismaNode('Post', {
|
|
649
|
+
variant: 'PostDraft'
|
|
650
|
+
// This set's what database field to use for the nodes id field
|
|
651
|
+
id: { field: 'id' },
|
|
652
|
+
// fields work just like they do for builder.prismaObject
|
|
653
|
+
fields: (t) => ({
|
|
654
|
+
title: t.exposeString('title'),
|
|
655
|
+
author: t.relation('author'),
|
|
656
|
+
}),
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
const Viewer = builder.prismaObject('User', {
|
|
660
|
+
variant: 'Viewer',
|
|
661
|
+
fields: (t) => ({
|
|
662
|
+
id: t.exposeID('id'),
|
|
663
|
+
drafts: t.relation('posts', {
|
|
664
|
+
// This will cause this relation to use the PostDraft variant rather than the default Post variant
|
|
665
|
+
type: PostDraft,
|
|
666
|
+
query: { where: { draft: true } },
|
|
667
|
+
}),
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
You may run into circular reference issues if you use 2 prisma object refs to reference each other.
|
|
673
|
+
To avoid this, you can split out the field definition for one of the relationships using
|
|
674
|
+
`builder.prismaObjectField`
|
|
675
|
+
|
|
676
|
+
```typescript
|
|
677
|
+
const Viewer = builder.prismaObject('User', {
|
|
678
|
+
variant: 'Viewer',
|
|
679
|
+
fields: (t) => ({
|
|
680
|
+
id: t.exposeID('id'),
|
|
681
|
+
user: t.variant(User),
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
const User = builder.prismaNode('User', {
|
|
686
|
+
interfaces: [Named],
|
|
687
|
+
id: {
|
|
688
|
+
resolve: (user) => user.id,
|
|
689
|
+
},
|
|
690
|
+
fields: (t) => ({
|
|
691
|
+
email: t.exposeString('email'),
|
|
692
|
+
}),
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
// Viewer references the `User` ref in its field definiton,
|
|
696
|
+
// referencing the `User` in fields would cause a circular type issue
|
|
697
|
+
builder.prismaObjectField(Viewer, 'user', t.variant(User));
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
This same workaround applies when defining relations using variants.
|
|
701
|
+
|
|
603
702
|
## Selecting fields from a nested GraphQL field
|
|
604
703
|
|
|
605
704
|
By default, the `nestedSelection` function will return selections based on the type of the current
|
|
@@ -720,7 +819,212 @@ const Media = builder.prismaObject('Media', {
|
|
|
720
819
|
});
|
|
721
820
|
```
|
|
722
821
|
|
|
723
|
-
##
|
|
822
|
+
## Optimized queries without `t.prismaField`
|
|
823
|
+
|
|
824
|
+
In some cases, it may be useful to get an optimized query for fields where you can't use
|
|
825
|
+
`t.prismaField`.
|
|
826
|
+
|
|
827
|
+
This may be required for combining with other plugins, or because your query does not directly
|
|
828
|
+
return a `PrismaObject`. In these cases, you can use the `queryFromInfo` helper. An example of this
|
|
829
|
+
might be a mutation that wraps the prisma object in a result type.
|
|
830
|
+
|
|
831
|
+
```typescript
|
|
832
|
+
const Post = builder.prismaObject('Post', {...});
|
|
833
|
+
|
|
834
|
+
builder.objectRef<{
|
|
835
|
+
success: boolean;
|
|
836
|
+
post?: Post
|
|
837
|
+
}>('CreatePostResult').implement({
|
|
838
|
+
fields: (t) => ({
|
|
839
|
+
success: t.boolean(),
|
|
840
|
+
post: t.field({
|
|
841
|
+
type: Post,
|
|
842
|
+
nullable:
|
|
843
|
+
resolve: (result) => result.post,
|
|
844
|
+
}),
|
|
845
|
+
}),
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
builder.mutationField(
|
|
849
|
+
'createPost',
|
|
850
|
+
{
|
|
851
|
+
args: (t) => ({
|
|
852
|
+
title: t.string({ required: true }),
|
|
853
|
+
...
|
|
854
|
+
}),
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
resolve: async (parent, args, context, info) => {
|
|
858
|
+
if (!validateCreatePostArgs(args)) {
|
|
859
|
+
return {
|
|
860
|
+
success: false,
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
const post = prisma.city.create({
|
|
865
|
+
...queryFromInfo({
|
|
866
|
+
context,
|
|
867
|
+
info,
|
|
868
|
+
// nested path where the selections for this type can be found
|
|
869
|
+
path: ['post']
|
|
870
|
+
// optionally you can pass a custom initial selection, genereally you wouldn't need this
|
|
871
|
+
// but if the field at `path` is not selected, the initial selection set may be empty
|
|
872
|
+
select: {
|
|
873
|
+
comments: true,
|
|
874
|
+
},
|
|
875
|
+
}),
|
|
876
|
+
data: {
|
|
877
|
+
title: args.input.title,
|
|
878
|
+
...
|
|
879
|
+
},
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
return {
|
|
883
|
+
success: true,
|
|
884
|
+
post,
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
},
|
|
888
|
+
);
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
## Relay integration
|
|
892
|
+
|
|
893
|
+
This plugin has extensive integration with the
|
|
894
|
+
[relay plugin](https://pothos-graphql.dev/docs/plugins/relay), which makes creating nodes and
|
|
895
|
+
connections very easy.
|
|
896
|
+
|
|
897
|
+
### `prismaNode`
|
|
898
|
+
|
|
899
|
+
The `prismaNode` method works just like the `prismaObject` method with a couple of small
|
|
900
|
+
differences:
|
|
901
|
+
|
|
902
|
+
- there is a new `id` option that mirrors the `id` option from `node` method of the relay plugin,
|
|
903
|
+
and must contain a resolve function that returns the id from an instance of the node. Rather than
|
|
904
|
+
defining a resolver for the id field, you can set the `field` option to the name of a unique
|
|
905
|
+
column or index.
|
|
906
|
+
|
|
907
|
+
```typescript
|
|
908
|
+
builder.prismaNode('Post', {
|
|
909
|
+
// This set's what database field to use for the nodes id field
|
|
910
|
+
id: { field: 'id' },
|
|
911
|
+
// fields work just like they do for builder.prismaObject
|
|
912
|
+
fields: (t) => ({
|
|
913
|
+
title: t.exposeString('title'),
|
|
914
|
+
author: t.relation('author'),
|
|
915
|
+
}),
|
|
916
|
+
});
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
If you need to customize how ids are formatted, you can add a resolver for the `id`, and provide a
|
|
920
|
+
`findUnique` option that can be used to load the node by it's id. This is generally not necissary.
|
|
921
|
+
|
|
922
|
+
```typescript
|
|
923
|
+
builder.prismaNode('Post', {
|
|
924
|
+
id: { resolve: (post) => String(post.id) },
|
|
925
|
+
// The return value will be passed as the `where` of a `prisma.post.findUnique`
|
|
926
|
+
findUnique: (id) => ({ id: Number.parseInt(id, 10) }),
|
|
927
|
+
fields: (t) => ({
|
|
928
|
+
title: t.exposeString('title'),
|
|
929
|
+
author: t.relation('author'),
|
|
930
|
+
}),
|
|
931
|
+
});
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
### `prismaConnection`
|
|
935
|
+
|
|
936
|
+
The `prismaConnection` method on a field builder can be used to create a relay `connection` field
|
|
937
|
+
that also pre-loads all the data nested inside that connection.
|
|
938
|
+
|
|
939
|
+
```typescript
|
|
940
|
+
builder.queryType({
|
|
941
|
+
fields: (t) => ({
|
|
942
|
+
posts: t.prismaConnection(
|
|
943
|
+
{
|
|
944
|
+
type: 'Post',
|
|
945
|
+
cursor: 'id',
|
|
946
|
+
resolve: (query, parent, args, context, info) => prisma.post.findMany({ ...query }),
|
|
947
|
+
}),
|
|
948
|
+
{}, // optional options for the Connection type
|
|
949
|
+
{}, // optional options for the Edge type),
|
|
950
|
+
),
|
|
951
|
+
}),
|
|
952
|
+
});
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
#### options
|
|
956
|
+
|
|
957
|
+
- `type`: the name of the prisma model being connected to
|
|
958
|
+
- `cursor`: a `@unique` column of the model being connected to. This is used as the `cursor` option
|
|
959
|
+
passed to prisma.
|
|
960
|
+
- `defaultSize`: (default: 20) The default page size to use if `first` and `last` are not provided.
|
|
961
|
+
- `maxSize`: (default: 100) The maximum number of nodes returned for a connection.
|
|
962
|
+
- `resolve`: Like the resolver for `prismaField`, the first argument is a `query` object that should
|
|
963
|
+
be spread into your prisma query. The `resolve` function should return an array of nodes for the
|
|
964
|
+
connection. The `query` will contain the correct `take`, `skip`, and `cursor` options based on the
|
|
965
|
+
connection arguments (`before`, `after`, `first`, `last`), along with `include` options for nested
|
|
966
|
+
selections.
|
|
967
|
+
- `totalCount`: A function for loading the total count for the connection. This will add a
|
|
968
|
+
`totalCount` field to the connection object. The `totalCount` method will receive (`connection`,
|
|
969
|
+
`args`, `context`, `info`) as arguments
|
|
970
|
+
|
|
971
|
+
The created connection queries currently support the following combinations of connection arguments:
|
|
972
|
+
|
|
973
|
+
- `first`, `last`, or `before`
|
|
974
|
+
- `first` and `before`
|
|
975
|
+
- `last` and `after`
|
|
976
|
+
|
|
977
|
+
Queries for other combinations are not as useful, and generally requiring loading all records
|
|
978
|
+
between 2 cursors, or between a cursor and the end of the set. Generating query options for these
|
|
979
|
+
cases is more complex and likely very inefficient, so they will currently throw an Error indicating
|
|
980
|
+
the argument combinations are not supported.
|
|
981
|
+
|
|
982
|
+
### `relatedConnection`
|
|
983
|
+
|
|
984
|
+
The `relatedConnection` method can be used to create a relay `connection` field based on a relation
|
|
985
|
+
of the current model.
|
|
986
|
+
|
|
987
|
+
```typescript
|
|
988
|
+
builder.prismaNode('User', {
|
|
989
|
+
id: { field: 'id' },
|
|
990
|
+
fields: (t) => ({
|
|
991
|
+
// Connections can be very simple to define
|
|
992
|
+
simplePosts: t.relatedConnection('posts', {
|
|
993
|
+
cursor: 'id',
|
|
994
|
+
}),
|
|
995
|
+
// Or they can include custom arguments, and other options
|
|
996
|
+
posts: t.relatedConnection(
|
|
997
|
+
'posts',
|
|
998
|
+
{
|
|
999
|
+
cursor: 'id',
|
|
1000
|
+
args: {
|
|
1001
|
+
oldestFirst: t.arg.boolean(),
|
|
1002
|
+
},
|
|
1003
|
+
query: (args, context) => ({
|
|
1004
|
+
orderBy: {
|
|
1005
|
+
createdAt: args.oldestFirst ? 'asc' : 'desc',
|
|
1006
|
+
},
|
|
1007
|
+
}),
|
|
1008
|
+
},
|
|
1009
|
+
{}, // optional options for the Connection type
|
|
1010
|
+
{}, // optional options for the Edge type),
|
|
1011
|
+
),
|
|
1012
|
+
}),
|
|
1013
|
+
});
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
#### options
|
|
1017
|
+
|
|
1018
|
+
- `cursor`: a `@unique` column of the model being connected to. This is used as the `cursor` option
|
|
1019
|
+
passed to prisma.
|
|
1020
|
+
- `defaultSize`: (default: 20) The default page size to use if `first` and `last` are not provided.
|
|
1021
|
+
- `maxSize`: (default: 100) The maximum number of nodes returned for a connection.
|
|
1022
|
+
- `query`: A method that accepts the `args` and `context` for the connection field, and returns
|
|
1023
|
+
filtering and sorting logic that will be merged into the query for the relation.
|
|
1024
|
+
- `totalCount`: when set to true, this will add a `totalCount` field to the connection object. see
|
|
1025
|
+
`relationCount` above for more details.
|
|
1026
|
+
|
|
1027
|
+
### Indirect relations as connections
|
|
724
1028
|
|
|
725
1029
|
Creating connections from indirect relations is a little more involved, but can be acheived using
|
|
726
1030
|
`prismaConnectionHelpers` with a normal `t.connection` field.
|
|
@@ -809,7 +1113,7 @@ const SelectPost = builder.prismaObject('Post', {
|
|
|
809
1113
|
});
|
|
810
1114
|
```
|
|
811
1115
|
|
|
812
|
-
|
|
1116
|
+
### Sharing Connections objects
|
|
813
1117
|
|
|
814
1118
|
You can create reusable connection objects by using `builder.connectionObject`.
|
|
815
1119
|
|
|
@@ -840,7 +1144,7 @@ builder.prismaObject('Post', {
|
|
|
840
1144
|
});
|
|
841
1145
|
```
|
|
842
1146
|
|
|
843
|
-
|
|
1147
|
+
### Extending connection edges
|
|
844
1148
|
|
|
845
1149
|
In some cases you may want to expose some data from an indirect connection on the edge object.
|
|
846
1150
|
|
|
@@ -891,240 +1195,16 @@ builder.prismaObjectFields('Post', (t) => ({
|
|
|
891
1195
|
}));
|
|
892
1196
|
```
|
|
893
1197
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
The prisma plugin supports defining multiple GraphQL types based on the same prisma model.
|
|
897
|
-
Additional types are called `variants`. You will always need to have a "Primary" variant (defined as
|
|
898
|
-
described above). Additional variants can be defined by providing a `variant` option instead of a
|
|
899
|
-
`name` option when creating the type:
|
|
900
|
-
|
|
901
|
-
```typescript
|
|
902
|
-
const Viewer = builder.prismaObject('User', {
|
|
903
|
-
variant: 'Viewer',
|
|
904
|
-
fields: (t) => ({
|
|
905
|
-
id: t.exposeID('id'),
|
|
906
|
-
});
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
You can define variant fields that reference one variant from another:
|
|
910
|
-
|
|
911
|
-
```typescript
|
|
912
|
-
const Viewer = builder.prismaObject('User', {
|
|
913
|
-
variant: 'Viewer',
|
|
914
|
-
fields: (t) => ({
|
|
915
|
-
id: t.exposeID('id'),
|
|
916
|
-
// Using the model name ('User') will reference the primary variant
|
|
917
|
-
user: t.variant('User'),
|
|
918
|
-
});
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
const User = builder.prismaNode('User', {
|
|
922
|
-
id: {
|
|
923
|
-
resolve: (user) => user.id,
|
|
924
|
-
},
|
|
925
|
-
fields: (t) => ({
|
|
926
|
-
// To reference another variant, use the returned object Ref instead of the model name:
|
|
927
|
-
viewer: t.variant(Viewer, {
|
|
928
|
-
// return null for viewer if the parent User is not the current user
|
|
929
|
-
isNull: (user, args, ctx) => user.id !== ctx.user.id,
|
|
930
|
-
}),
|
|
931
|
-
email: t.exposeString('email'),
|
|
932
|
-
}),
|
|
933
|
-
});
|
|
934
|
-
```
|
|
935
|
-
|
|
936
|
-
You can also use variants when defining relations by providing a `type` option:
|
|
937
|
-
|
|
938
|
-
```typescript
|
|
939
|
-
const PostDraft = builder.prismaNode('Post', {
|
|
940
|
-
variant: 'PostDraft'
|
|
941
|
-
// This set's what database field to use for the nodes id field
|
|
942
|
-
id: { field: 'id' },
|
|
943
|
-
// fields work just like they do for builder.prismaObject
|
|
944
|
-
fields: (t) => ({
|
|
945
|
-
title: t.exposeString('title'),
|
|
946
|
-
author: t.relation('author'),
|
|
947
|
-
}),
|
|
948
|
-
});
|
|
949
|
-
|
|
950
|
-
const Viewer = builder.prismaObject('User', {
|
|
951
|
-
variant: 'Viewer',
|
|
952
|
-
fields: (t) => ({
|
|
953
|
-
id: t.exposeID('id'),
|
|
954
|
-
drafts: t.relation('posts', {
|
|
955
|
-
// This will cause this relation to use the PostDraft variant rather than the default Post variant
|
|
956
|
-
type: PostDraft,
|
|
957
|
-
query: { where: { draft: true } },
|
|
958
|
-
}),
|
|
959
|
-
});
|
|
960
|
-
});
|
|
961
|
-
```
|
|
962
|
-
|
|
963
|
-
You may run into circular reference issues if you use 2 prisma object refs to reference each other.
|
|
964
|
-
To avoid this, you can split out the field definition for one of the relationships using
|
|
965
|
-
`builder.prismaObjectField`
|
|
966
|
-
|
|
967
|
-
```typescript
|
|
968
|
-
const Viewer = builder.prismaObject('User', {
|
|
969
|
-
variant: 'Viewer',
|
|
970
|
-
fields: (t) => ({
|
|
971
|
-
id: t.exposeID('id'),
|
|
972
|
-
user: t.variant(User),
|
|
973
|
-
});
|
|
974
|
-
});
|
|
975
|
-
|
|
976
|
-
const User = builder.prismaNode('User', {
|
|
977
|
-
interfaces: [Named],
|
|
978
|
-
id: {
|
|
979
|
-
resolve: (user) => user.id,
|
|
980
|
-
},
|
|
981
|
-
fields: (t) => ({
|
|
982
|
-
email: t.exposeString('email'),
|
|
983
|
-
}),
|
|
984
|
-
});
|
|
985
|
-
|
|
986
|
-
// Viewer references the `User` ref in its field definiton,
|
|
987
|
-
// referencing the `User` in fields would cause a circular type issue
|
|
988
|
-
builder.prismaObjectField(Viewer, 'user', t.variant(User));
|
|
989
|
-
```
|
|
990
|
-
|
|
991
|
-
This same workaround applies when defining relations using variants.
|
|
1198
|
+
### Relay Utils
|
|
992
1199
|
|
|
993
|
-
|
|
1200
|
+
#### `parsePrismaCursor` and `formatPrismaCursor`
|
|
994
1201
|
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
connections very easy.
|
|
998
|
-
|
|
999
|
-
### `prismaNode`
|
|
1202
|
+
These functions can be used to manually parse and format cursors that are compatible with prisma
|
|
1203
|
+
connections.
|
|
1000
1204
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
- there is a new `id` option that mirrors the `id` option from `node` method of the relay plugin,
|
|
1005
|
-
and must contain a resolve function that returns the id from an instance of the node. Rather than
|
|
1006
|
-
defining a resolver for the id field, you can set the `field` option to the name of a unique
|
|
1007
|
-
column or index.
|
|
1008
|
-
|
|
1009
|
-
```typescript
|
|
1010
|
-
builder.prismaNode('Post', {
|
|
1011
|
-
// This set's what database field to use for the nodes id field
|
|
1012
|
-
id: { field: 'id' },
|
|
1013
|
-
// fields work just like they do for builder.prismaObject
|
|
1014
|
-
fields: (t) => ({
|
|
1015
|
-
title: t.exposeString('title'),
|
|
1016
|
-
author: t.relation('author'),
|
|
1017
|
-
}),
|
|
1018
|
-
});
|
|
1019
|
-
```
|
|
1020
|
-
|
|
1021
|
-
If you need to customize how ids are formatted, you can add a resolver for the `id`, and provide a
|
|
1022
|
-
`findUnique` option that can be used to load the node by it's id. This is generally not necissary.
|
|
1023
|
-
|
|
1024
|
-
```typescript
|
|
1025
|
-
builder.prismaNode('Post', {
|
|
1026
|
-
id: { resolve: (post) => String(post.id) },
|
|
1027
|
-
// The return value will be passed as the `where` of a `prisma.post.findUnique`
|
|
1028
|
-
findUnique: (id) => ({ id: Number.parseInt(id, 10) }),
|
|
1029
|
-
fields: (t) => ({
|
|
1030
|
-
title: t.exposeString('title'),
|
|
1031
|
-
author: t.relation('author'),
|
|
1032
|
-
}),
|
|
1033
|
-
});
|
|
1034
|
-
```
|
|
1035
|
-
|
|
1036
|
-
### `prismaConnection`
|
|
1037
|
-
|
|
1038
|
-
The `prismaConnection` method on a field builder can be used to create a relay `connection` field
|
|
1039
|
-
that also pre-loads all the data nested inside that connection.
|
|
1040
|
-
|
|
1041
|
-
```typescript
|
|
1042
|
-
builder.queryType({
|
|
1043
|
-
fields: (t) => ({
|
|
1044
|
-
posts: t.prismaConnection(
|
|
1045
|
-
{
|
|
1046
|
-
type: 'Post',
|
|
1047
|
-
cursor: 'id',
|
|
1048
|
-
resolve: (query, parent, args, context, info) => prisma.post.findMany({ ...query }),
|
|
1049
|
-
}),
|
|
1050
|
-
{}, // optional options for the Connection type
|
|
1051
|
-
{}, // optional options for the Edge type),
|
|
1052
|
-
),
|
|
1053
|
-
}),
|
|
1054
|
-
});
|
|
1055
|
-
```
|
|
1056
|
-
|
|
1057
|
-
#### options
|
|
1058
|
-
|
|
1059
|
-
- `type`: the name of the prisma model being connected to
|
|
1060
|
-
- `cursor`: a `@unique` column of the model being connected to. This is used as the `cursor` option
|
|
1061
|
-
passed to prisma.
|
|
1062
|
-
- `defaultSize`: (default: 20) The default page size to use if `first` and `last` are not provided.
|
|
1063
|
-
- `maxSize`: (default: 100) The maximum number of nodes returned for a connection.
|
|
1064
|
-
- `resolve`: Like the resolver for `prismaField`, the first argument is a `query` object that should
|
|
1065
|
-
be spread into your prisma query. The `resolve` function should return an array of nodes for the
|
|
1066
|
-
connection. The `query` will contain the correct `take`, `skip`, and `cursor` options based on the
|
|
1067
|
-
connection arguments (`before`, `after`, `first`, `last`), along with `include` options for nested
|
|
1068
|
-
selections.
|
|
1069
|
-
- `totalCount`: A function for loading the total count for the connection. This will add a
|
|
1070
|
-
`totalCount` field to the connection object. The `totalCount` method will receive (`connection`,
|
|
1071
|
-
`args`, `context`, `info`) as arguments
|
|
1072
|
-
|
|
1073
|
-
The created connection queries currently support the following combinations of connection arguments:
|
|
1074
|
-
|
|
1075
|
-
- `first`, `last`, or `before`
|
|
1076
|
-
- `first` and `before`
|
|
1077
|
-
- `last` and `after`
|
|
1078
|
-
|
|
1079
|
-
Queries for other combinations are not as useful, and generally requiring loading all records
|
|
1080
|
-
between 2 cursors, or between a cursor and the end of the set. Generating query options for these
|
|
1081
|
-
cases is more complex and likely very inefficient, so they will currently throw an Error indicating
|
|
1082
|
-
the argument combinations are not supported.
|
|
1083
|
-
|
|
1084
|
-
### `relatedConnection`
|
|
1085
|
-
|
|
1086
|
-
The `relatedConnection` method can be used to create a relay `connection` field based on a relation
|
|
1087
|
-
of the current model.
|
|
1088
|
-
|
|
1089
|
-
```typescript
|
|
1090
|
-
builder.prismaNode('User', {
|
|
1091
|
-
id: { field: 'id' },
|
|
1092
|
-
fields: (t) => ({
|
|
1093
|
-
// Connections can be very simple to define
|
|
1094
|
-
simplePosts: t.relatedConnection('posts', {
|
|
1095
|
-
cursor: 'id',
|
|
1096
|
-
}),
|
|
1097
|
-
// Or they can include custom arguments, and other options
|
|
1098
|
-
posts: t.relatedConnection(
|
|
1099
|
-
'posts',
|
|
1100
|
-
{
|
|
1101
|
-
cursor: 'id',
|
|
1102
|
-
args: {
|
|
1103
|
-
oldestFirst: t.arg.boolean(),
|
|
1104
|
-
},
|
|
1105
|
-
query: (args, context) => ({
|
|
1106
|
-
orderBy: {
|
|
1107
|
-
createdAt: args.oldestFirst ? 'asc' : 'desc',
|
|
1108
|
-
},
|
|
1109
|
-
}),
|
|
1110
|
-
},
|
|
1111
|
-
{}, // optional options for the Connection type
|
|
1112
|
-
{}, // optional options for the Edge type),
|
|
1113
|
-
),
|
|
1114
|
-
}),
|
|
1115
|
-
});
|
|
1116
|
-
```
|
|
1117
|
-
|
|
1118
|
-
#### options
|
|
1119
|
-
|
|
1120
|
-
- `cursor`: a `@unique` column of the model being connected to. This is used as the `cursor` option
|
|
1121
|
-
passed to prisma.
|
|
1122
|
-
- `defaultSize`: (default: 20) The default page size to use if `first` and `last` are not provided.
|
|
1123
|
-
- `maxSize`: (default: 100) The maximum number of nodes returned for a connection.
|
|
1124
|
-
- `query`: A method that accepts the `args` and `context` for the connection field, and returns
|
|
1125
|
-
filtering and sorting logic that will be merged into the query for the relation.
|
|
1126
|
-
- `totalCount`: when set to true, this will add a `totalCount` field to the connection object. see
|
|
1127
|
-
`relationCount` above for more details.
|
|
1205
|
+
Parsing a cursor will return the value from the column used for the cursor (often the `id`), this
|
|
1206
|
+
value may be an array or object when a compound index is used as the cursor. Similarly, to format a
|
|
1207
|
+
cursor, you must provide the column(s) that make up the cursor.
|
|
1128
1208
|
|
|
1129
1209
|
## Using Prisma without a plugin
|
|
1130
1210
|
|
package/dts/global-types.d.ts
CHANGED
|
@@ -65,9 +65,9 @@ declare global {
|
|
|
65
65
|
}
|
|
66
66
|
interface RootFieldBuilder<Types extends SchemaTypes, ParentShape, Kind extends FieldKind = FieldKind> {
|
|
67
67
|
prismaField: <Args extends InputFieldMap, TypeParam extends PrismaObjectRef<PrismaModelTypes> | keyof Types['PrismaTypes'] | [keyof Types['PrismaTypes']] | [PrismaObjectRef<PrismaModelTypes>], Nullable extends FieldNullability<Type>, ResolveShape, ResolveReturnShape, Type extends TypeParam extends [unknown] ? [ObjectRef<Model['Shape']>] : ObjectRef<Model['Shape']>, Model extends PrismaModelTypes = PrismaModelTypes & (TypeParam extends [keyof Types['PrismaTypes']] ? Types['PrismaTypes'][TypeParam[0]] : TypeParam extends [PrismaObjectRef<PrismaModelTypes>] ? TypeParam[0][typeof prismaModelKey] : TypeParam extends PrismaObjectRef<PrismaModelTypes> ? TypeParam[typeof prismaModelKey] : TypeParam extends keyof Types['PrismaTypes'] ? Types['PrismaTypes'][TypeParam] : never)>(options: PrismaFieldOptions<Types, ParentShape, TypeParam, Model, Type, Args, Nullable, ResolveShape, ResolveReturnShape, Kind>) => FieldRef<ShapeFromTypeParam<Types, Type, Nullable>>;
|
|
68
|
-
prismaConnection: 'relay' extends PluginName ? <Type extends PrismaObjectRef<PrismaModelTypes> | keyof Types['PrismaTypes'], Nullable extends boolean, ResolveReturnShape, Args extends InputFieldMap = {}, Model extends PrismaModelTypes = Type extends PrismaObjectRef<infer T> ? T : PrismaModelTypes & Types['PrismaTypes'][Type & keyof Types['PrismaTypes']], Shape = Type extends PrismaObjectRef<PrismaModelTypes, infer S> ? S : Model['Shape']>(options: PrismaConnectionFieldOptions<Types, ParentShape, Type, Model, ObjectRef<Model['Shape']>, Nullable, Args, ResolveReturnShape, Kind>, ...args: NormalizeArgs<[
|
|
69
|
-
connectionOptions: ConnectionObjectOptions<Types, ObjectRef<Shape>, false, false, ResolveReturnShape> | ObjectRef<ShapeFromConnection<ConnectionShapeHelper<Types, Shape, false>>>,
|
|
70
|
-
edgeOptions: ConnectionEdgeObjectOptions<Types, ObjectRef<Shape>, false, ResolveReturnShape> | ObjectRef<{
|
|
68
|
+
prismaConnection: 'relay' extends PluginName ? <Type extends PrismaObjectRef<PrismaModelTypes> | keyof Types['PrismaTypes'], Nullable extends boolean, ResolveReturnShape, Args extends InputFieldMap = {}, Model extends PrismaModelTypes = Type extends PrismaObjectRef<infer T> ? T : PrismaModelTypes & Types['PrismaTypes'][Type & keyof Types['PrismaTypes']], Shape = Type extends PrismaObjectRef<PrismaModelTypes, infer S> ? S : Model['Shape'], ConnectionInterfaces extends InterfaceParam<Types>[] = [], EdgeInterfaces extends InterfaceParam<Types>[] = []>(options: PrismaConnectionFieldOptions<Types, ParentShape, Type, Model, ObjectRef<Model['Shape']>, Nullable, Args, ResolveReturnShape, Kind>, ...args: NormalizeArgs<[
|
|
69
|
+
connectionOptions: ConnectionObjectOptions<Types, ObjectRef<Shape>, false, false, ResolveReturnShape, ConnectionInterfaces> | ObjectRef<ShapeFromConnection<ConnectionShapeHelper<Types, Shape, false>>>,
|
|
70
|
+
edgeOptions: ConnectionEdgeObjectOptions<Types, ObjectRef<Shape>, false, ResolveReturnShape, EdgeInterfaces> | ObjectRef<{
|
|
71
71
|
cursor: string;
|
|
72
72
|
node?: Shape | null | undefined;
|
|
73
73
|
}>
|
|
@@ -78,9 +78,9 @@ declare global {
|
|
|
78
78
|
}
|
|
79
79
|
interface ConnectionFieldOptions<Types extends SchemaTypes, ParentShape, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Args extends InputFieldMap, ResolveReturnShape> {
|
|
80
80
|
}
|
|
81
|
-
interface ConnectionObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Resolved> {
|
|
81
|
+
interface ConnectionObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam<Types>[] = []> {
|
|
82
82
|
}
|
|
83
|
-
interface ConnectionEdgeObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, NodeNullability extends boolean, Resolved> {
|
|
83
|
+
interface ConnectionEdgeObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam<Types>[] = []> {
|
|
84
84
|
}
|
|
85
85
|
interface DefaultConnectionArguments {
|
|
86
86
|
first?: number | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-types.d.ts","sourceRoot":"","sources":["../src/global-types.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,wBAAwB,IAAI,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,kBAAkB,EAClB,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;AAEtC,OAAO,CAAC,MAAM,CAAC;IACb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