@pothos/plugin-relay
Advanced tools
Comparing version 3.30.2 to 3.31.0
# Change Log | ||
## 3.31.0 | ||
### Minor Changes | ||
- c3db3bcd: Enable adding interfaces to connections and edges | ||
### Patch Changes | ||
- fd08a9d9: allow readonly lists to be exposed and improve inference of t.expose fields | ||
## 3.30.2 | ||
@@ -4,0 +14,0 @@ |
@@ -34,3 +34,3 @@ import { FieldKind, FieldNullability, FieldOptionsFromKind, FieldRef, FieldRequiredness, InputFieldMap, InputFieldRef, InputFieldsFromShape, InputShapeFromFields, InputShapeFromTypeParam, inputShapeKey, InterfaceParam, NormalizeArgs, ObjectFieldsShape, ObjectFieldThunk, ObjectParam, OutputShape, OutputType, ParentShape, Resolver, SchemaTypes, ShapeFromTypeParam } from '@pothos/core'; | ||
}; | ||
connectionObject: <Type extends OutputType<Types>, ResolveReturnShape, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean>(connectionOptions: ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape> & { | ||
connectionObject: <Type extends OutputType<Types>, ResolveReturnShape, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, ConnectionInterfaces extends InterfaceParam<Types>[] = [], EdgeInterfaces extends InterfaceParam<Types>[] = []>(connectionOptions: ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape, ConnectionInterfaces> & { | ||
name: string; | ||
@@ -42,7 +42,7 @@ type: Type; | ||
node?: ShapeFromTypeParam<Types, Type, NodeNullability>; | ||
}> | (ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape> & { | ||
}> | (ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape, EdgeInterfaces> & { | ||
name?: string; | ||
}) | ||
]>) => ObjectRef<ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>>; | ||
edgeObject: <Type extends OutputType<Types>, ResolveReturnShape, NodeNullability extends boolean = Types['DefaultNodeNullability']>(edgeOptions: ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape> & { | ||
edgeObject: <Type extends OutputType<Types>, ResolveReturnShape, NodeNullability extends boolean = Types['DefaultNodeNullability'], Interfaces extends InterfaceParam<Types>[] = []>(edgeOptions: ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape, Interfaces> & { | ||
type: Type; | ||
@@ -74,11 +74,11 @@ name: string; | ||
node: <Args extends InputFieldMap, ResolveShape>(options: NodeFieldOptions<Types, ParentShape, Args, ResolveShape, Kind>) => FieldRef<unknown>; | ||
nodeList: <Args extends InputFieldMap, ResolveShape>(options: NodeListFieldOptions<Types, ParentShape, Args, ResolveShape, Kind>) => FieldRef<unknown[]>; | ||
connection: <Type extends OutputType<Types>, Args extends InputFieldMap, Nullable extends boolean, ResolveShape, ResolveReturnShape, EdgeNullability extends FieldNullability<[unknown]> = Types['DefaultEdgesNullability'], NodeNullability extends boolean = Types['DefaultNodeNullability']>(options: FieldOptionsFromKind<Types, ParentShape, Type, Nullable, (InputFieldMap extends Args ? {} : Args) & InputFieldsFromShape<DefaultConnectionArguments>, Kind, ResolveShape, ResolveReturnShape> extends infer FieldOptions ? ConnectionFieldOptions<Types, FieldOptions extends { | ||
nodeList: <Args extends InputFieldMap, ResolveShape>(options: NodeListFieldOptions<Types, ParentShape, Args, ResolveShape, Kind>) => FieldRef<readonly unknown[]>; | ||
connection: <Type extends OutputType<Types>, Args extends InputFieldMap, Nullable extends boolean, ResolveShape, ResolveReturnShape, EdgeNullability extends FieldNullability<[unknown]> = Types['DefaultEdgesNullability'], NodeNullability extends boolean = Types['DefaultNodeNullability'], ConnectionInterfaces extends InterfaceParam<Types>[] = [], EdgeInterfaces extends InterfaceParam<Types>[] = []>(options: FieldOptionsFromKind<Types, ParentShape, Type, Nullable, (InputFieldMap extends Args ? {} : Args) & InputFieldsFromShape<DefaultConnectionArguments>, Kind, ResolveShape, ResolveReturnShape> extends infer FieldOptions ? ConnectionFieldOptions<Types, FieldOptions extends { | ||
resolve?: (parent: infer P, ...args: any[]) => unknown; | ||
} ? P : unknown extends ResolveShape ? ParentShape : ResolveShape, Type, Nullable, EdgeNullability, NodeNullability, Args, ResolveReturnShape> & Omit<FieldOptions, 'args' | 'resolve' | 'type'> : never, ...args: NormalizeArgs<[ | ||
connectionOptions: ObjectRef<ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>> | Omit<ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape>, 'edgesNullable'>, | ||
connectionOptions: ObjectRef<ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>> | Omit<ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape, ConnectionInterfaces>, 'edgesNullable'>, | ||
edgeOptions: ObjectRef<{ | ||
cursor: string; | ||
node?: ShapeFromTypeParam<Types, Type, NodeNullability>; | ||
}> | ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape> | ||
}> | ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape, EdgeInterfaces> | ||
], 0>) => FieldRef<ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability>>; | ||
@@ -93,3 +93,3 @@ } | ||
} | ||
interface ConnectionObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Resolved> extends ObjectTypeOptions<Types, ConnectionShapeFromResolve<Types, Type, false, EdgeNullability, NodeNullability, Resolved>> { | ||
interface ConnectionObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam<Types>[] = []> extends ObjectTypeWithInterfaceOptions<Types, ConnectionShapeFromResolve<Types, Type, false, EdgeNullability, NodeNullability, Resolved>, Interfaces> { | ||
name?: string; | ||
@@ -99,3 +99,3 @@ edgesNullable?: EdgeNullability; | ||
} | ||
interface ConnectionEdgeObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, NodeNullability extends boolean, Resolved> extends ObjectTypeOptions<Types, NonNullable<ConnectionShapeFromResolve<Types, Type, false, false, NodeNullability, Resolved>['edges']>[number]> { | ||
interface ConnectionEdgeObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam<Types>[] = []> extends ObjectTypeWithInterfaceOptions<Types, NonNullable<ConnectionShapeFromResolve<Types, Type, false, false, NodeNullability, Resolved>['edges']>[number], Interfaces> { | ||
name?: string; | ||
@@ -102,0 +102,0 @@ } |
@@ -40,3 +40,5 @@ import { FieldKind, FieldNullability, FieldOptionsFromKind, FieldRef, FieldRequiredness, InputFieldMap, InputFieldRef, InputFieldsFromShape, InputShapeFromFields, InputShapeFromTypeParam, inputShapeKey, InterfaceParam, NormalizeArgs, ObjectFieldsShape, ObjectFieldThunk, ObjectParam, OutputShape, OutputType, ParentShape, Resolver, SchemaTypes, ShapeFromTypeParam } from '@pothos/core'; | ||
unknown | ||
]>, NodeNullability extends boolean>(connectionOptions: ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape> & { | ||
]>, NodeNullability extends boolean, ConnectionInterfaces extends InterfaceParam<Types>[] = [ | ||
], EdgeInterfaces extends InterfaceParam<Types>[] = [ | ||
]>(connectionOptions: ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape, ConnectionInterfaces> & { | ||
name: string; | ||
@@ -48,7 +50,8 @@ type: Type; | ||
node?: ShapeFromTypeParam<Types, Type, NodeNullability>; | ||
}> | (ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape> & { | ||
}> | (ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape, EdgeInterfaces> & { | ||
name?: string; | ||
}) | ||
]>) => ObjectRef<ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>>; | ||
edgeObject: <Type extends OutputType<Types>, ResolveReturnShape, NodeNullability extends boolean = Types["DefaultNodeNullability"]>(edgeOptions: ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape> & { | ||
edgeObject: <Type extends OutputType<Types>, ResolveReturnShape, NodeNullability extends boolean = Types["DefaultNodeNullability"], Interfaces extends InterfaceParam<Types>[] = [ | ||
]>(edgeOptions: ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape, Interfaces> & { | ||
type: Type; | ||
@@ -90,13 +93,15 @@ name: string; | ||
node: <Args extends InputFieldMap, ResolveShape>(options: NodeFieldOptions<Types, ParentShape, Args, ResolveShape, Kind>) => FieldRef<unknown>; | ||
nodeList: <Args extends InputFieldMap, ResolveShape>(options: NodeListFieldOptions<Types, ParentShape, Args, ResolveShape, Kind>) => FieldRef<unknown[]>; | ||
nodeList: <Args extends InputFieldMap, ResolveShape>(options: NodeListFieldOptions<Types, ParentShape, Args, ResolveShape, Kind>) => FieldRef<readonly unknown[]>; | ||
connection: <Type extends OutputType<Types>, Args extends InputFieldMap, Nullable extends boolean, ResolveShape, ResolveReturnShape, EdgeNullability extends FieldNullability<[ | ||
unknown | ||
]> = Types["DefaultEdgesNullability"], NodeNullability extends boolean = Types["DefaultNodeNullability"]>(options: FieldOptionsFromKind<Types, ParentShape, Type, Nullable, (InputFieldMap extends Args ? {} : Args) & InputFieldsFromShape<DefaultConnectionArguments>, Kind, ResolveShape, ResolveReturnShape> extends infer FieldOptions ? ConnectionFieldOptions<Types, FieldOptions extends { | ||
]> = Types["DefaultEdgesNullability"], NodeNullability extends boolean = Types["DefaultNodeNullability"], ConnectionInterfaces extends InterfaceParam<Types>[] = [ | ||
], EdgeInterfaces extends InterfaceParam<Types>[] = [ | ||
]>(options: FieldOptionsFromKind<Types, ParentShape, Type, Nullable, (InputFieldMap extends Args ? {} : Args) & InputFieldsFromShape<DefaultConnectionArguments>, Kind, ResolveShape, ResolveReturnShape> extends infer FieldOptions ? ConnectionFieldOptions<Types, FieldOptions extends { | ||
resolve?: (parent: infer P, ...args: any[]) => unknown; | ||
} ? P : unknown extends ResolveShape ? ParentShape : ResolveShape, Type, Nullable, EdgeNullability, NodeNullability, Args, ResolveReturnShape> & Omit<FieldOptions, "args" | "resolve" | "type"> : never, ...args: NormalizeArgs<[ | ||
connectionOptions: ObjectRef<ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>> | Omit<ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape>, "edgesNullable">, | ||
connectionOptions: ObjectRef<ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>> | Omit<ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape, ConnectionInterfaces>, "edgesNullable">, | ||
edgeOptions: ObjectRef<{ | ||
cursor: string; | ||
node?: ShapeFromTypeParam<Types, Type, NodeNullability>; | ||
}> | ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape> | ||
}> | ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape, EdgeInterfaces> | ||
], 0>) => FieldRef<ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability>>; | ||
@@ -115,3 +120,4 @@ } | ||
unknown | ||
]>, NodeNullability extends boolean, Resolved> extends ObjectTypeOptions<Types, ConnectionShapeFromResolve<Types, Type, false, EdgeNullability, NodeNullability, Resolved>> { | ||
]>, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam<Types>[] = [ | ||
]> extends ObjectTypeWithInterfaceOptions<Types, ConnectionShapeFromResolve<Types, Type, false, EdgeNullability, NodeNullability, Resolved>, Interfaces> { | ||
name?: string; | ||
@@ -121,3 +127,4 @@ edgesNullable?: EdgeNullability; | ||
} | ||
interface ConnectionEdgeObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, NodeNullability extends boolean, Resolved> extends ObjectTypeOptions<Types, NonNullable<ConnectionShapeFromResolve<Types, Type, false, false, NodeNullability, Resolved>["edges"]>[number]> { | ||
interface ConnectionEdgeObjectOptions<Types extends SchemaTypes, Type extends OutputType<Types>, NodeNullability extends boolean, Resolved, Interfaces extends InterfaceParam<Types>[] = [ | ||
]> extends ObjectTypeWithInterfaceOptions<Types, NonNullable<ConnectionShapeFromResolve<Types, Type, false, false, NodeNullability, Resolved>["edges"]>[number], Interfaces> { | ||
name?: string; | ||
@@ -124,0 +131,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { defaultTypeResolver } from 'graphql'; | ||
import { defaultTypeResolver } from 'graphql'; | ||
import SchemaBuilder, { createContextCache, getTypeBrand, InputObjectRef, ObjectRef, verifyRef } from '@pothos/core'; | ||
@@ -313,3 +313,2 @@ import { capitalize, resolveNodes } from './utils/index.js'; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
resolve: (con) => { | ||
@@ -316,0 +315,0 @@ var _con_edges; |
@@ -1,2 +0,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ "use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -363,3 +363,2 @@ value: true | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
resolve: (con)=>{ | ||
@@ -366,0 +365,0 @@ var _con_edges; |
{ | ||
"name": "@pothos/plugin-relay", | ||
"version": "3.30.2", | ||
"version": "3.31.0", | ||
"description": "A Pothos plugin for adding relay style connections, nodes, and cursor based pagination to your GraphQL schema", | ||
@@ -46,3 +46,3 @@ "main": "./lib/index.js", | ||
"graphql-tag": "^2.12.6", | ||
"@pothos/core": "3.23.2", | ||
"@pothos/core": "3.24.0", | ||
"@pothos/plugin-complexity": "3.11.7", | ||
@@ -49,0 +49,0 @@ "@pothos/test-utils": "1.4.7" |
@@ -123,2 +123,4 @@ import { | ||
NodeNullability extends boolean, | ||
ConnectionInterfaces extends InterfaceParam<Types>[] = [], | ||
EdgeInterfaces extends InterfaceParam<Types>[] = [], | ||
>( | ||
@@ -130,3 +132,4 @@ connectionOptions: ConnectionObjectOptions< | ||
NodeNullability, | ||
ResolveReturnShape | ||
ResolveReturnShape, | ||
ConnectionInterfaces | ||
> & { | ||
@@ -143,3 +146,9 @@ name: string; | ||
}> | ||
| (ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape> & { | ||
| (ConnectionEdgeObjectOptions< | ||
Types, | ||
Type, | ||
NodeNullability, | ||
ResolveReturnShape, | ||
EdgeInterfaces | ||
> & { | ||
name?: string; | ||
@@ -154,2 +163,3 @@ }), | ||
NodeNullability extends boolean = Types['DefaultNodeNullability'], | ||
Interfaces extends InterfaceParam<Types>[] = [], | ||
>( | ||
@@ -160,3 +170,4 @@ edgeOptions: ConnectionEdgeObjectOptions< | ||
NodeNullability, | ||
ResolveReturnShape | ||
ResolveReturnShape, | ||
Interfaces | ||
> & { | ||
@@ -238,3 +249,3 @@ type: Type; | ||
options: NodeListFieldOptions<Types, ParentShape, Args, ResolveShape, Kind>, | ||
) => FieldRef<unknown[]>; | ||
) => FieldRef<readonly unknown[]>; | ||
connection: < | ||
@@ -248,2 +259,4 @@ Type extends OutputType<Types>, | ||
NodeNullability extends boolean = Types['DefaultNodeNullability'], | ||
ConnectionInterfaces extends InterfaceParam<Types>[] = [], | ||
EdgeInterfaces extends InterfaceParam<Types>[] = [], | ||
>( | ||
@@ -289,3 +302,4 @@ options: FieldOptionsFromKind< | ||
NodeNullability, | ||
ResolveReturnShape | ||
ResolveReturnShape, | ||
ConnectionInterfaces | ||
>, | ||
@@ -299,3 +313,9 @@ 'edgesNullable' | ||
}> | ||
| ConnectionEdgeObjectOptions<Types, Type, NodeNullability, ResolveReturnShape>, | ||
| ConnectionEdgeObjectOptions< | ||
Types, | ||
Type, | ||
NodeNullability, | ||
ResolveReturnShape, | ||
EdgeInterfaces | ||
>, | ||
], | ||
@@ -338,5 +358,7 @@ 0 | ||
Resolved, | ||
> extends ObjectTypeOptions< | ||
Interfaces extends InterfaceParam<Types>[] = [], | ||
> extends ObjectTypeWithInterfaceOptions< | ||
Types, | ||
ConnectionShapeFromResolve<Types, Type, false, EdgeNullability, NodeNullability, Resolved> | ||
ConnectionShapeFromResolve<Types, Type, false, EdgeNullability, NodeNullability, Resolved>, | ||
Interfaces | ||
> { | ||
@@ -353,7 +375,9 @@ name?: string; | ||
Resolved, | ||
> extends ObjectTypeOptions< | ||
Interfaces extends InterfaceParam<Types>[] = [], | ||
> extends ObjectTypeWithInterfaceOptions< | ||
Types, | ||
NonNullable< | ||
ConnectionShapeFromResolve<Types, Type, false, false, NodeNullability, Resolved>['edges'] | ||
>[number] | ||
>[number], | ||
Interfaces | ||
> { | ||
@@ -360,0 +384,0 @@ name?: string; |
@@ -1,3 +0,1 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
import { defaultTypeResolver, GraphQLResolveInfo } from 'graphql'; | ||
@@ -74,3 +72,3 @@ import SchemaBuilder, { | ||
nullable: true, | ||
...startCursorFieldOptions, | ||
...(startCursorFieldOptions as {}), | ||
type: cursorType, | ||
@@ -80,3 +78,3 @@ }) as never, | ||
nullable: true, | ||
...endCursorFieldOptions, | ||
...(endCursorFieldOptions as {}), | ||
type: cursorType, | ||
@@ -469,3 +467,3 @@ }) as never, | ||
...(this.options.relayOptions?.defaultConnectionTypeOptions as {}), | ||
...connectionOptions, | ||
...(connectionOptions as {}), | ||
fields: (t) => ({ | ||
@@ -497,3 +495,2 @@ pageInfo: t.field({ | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
resolve: (con) => (con.edges?.map((edge) => edge?.node) ?? []) as never, | ||
@@ -500,0 +497,0 @@ }), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
373537
4799