@pothos/plugin-relay
Advanced tools
Comparing version 3.15.0 to 3.16.0
# Change Log | ||
## 3.16.0 | ||
### Minor Changes | ||
- ad928594: Add defaultConnectionTypeOptions and defaultEdgeTypeOptions | ||
### Patch Changes | ||
- 04ed2b0c: Fix args in plugin methods on connection fields sometimes not being typed correctly | ||
## 3.15.0 | ||
@@ -4,0 +14,0 @@ |
@@ -75,3 +75,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'; | ||
connection: <Type extends OutputType<Types>, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, EdgeNullability extends FieldNullability<[unknown]> = Types['DefaultEdgesNullability'], NodeNullability extends boolean = Types['DefaultNodeNullability']>(...args: NormalizeArgs<[ | ||
options: ConnectionFieldOptions<Types, ParentShape, Type, Nullable, EdgeNullability, NodeNullability, Args, ResolveReturnShape> & Omit<FieldOptionsFromKind<Types, ParentShape, Type, Nullable, Args & InputFieldsFromShape<DefaultConnectionArguments>, Kind, ParentShape, ResolveReturnShape>, 'args' | 'resolve' | 'type'>, | ||
options: ConnectionFieldOptions<Types, ParentShape, Type, Nullable, EdgeNullability, NodeNullability, Args, ResolveReturnShape> & Omit<FieldOptionsFromKind<Types, ParentShape, Type, Nullable, (InputFieldMap extends Args ? {} : Args) & InputFieldsFromShape<DefaultConnectionArguments>, Kind, ParentShape, ResolveReturnShape>, 'args' | 'resolve' | 'type'>, | ||
connectionOptions?: ObjectRef<ConnectionShapeForType<Types, Type, false, EdgeNullability, NodeNullability>> | Omit<ConnectionObjectOptions<Types, Type, EdgeNullability, NodeNullability, ResolveReturnShape>, 'edgesNullable'>, | ||
@@ -78,0 +78,0 @@ edgeOptions?: ObjectRef<{ |
@@ -45,2 +45,10 @@ import { GraphQLResolveInfo } from 'graphql'; | ||
}; | ||
defaultConnectionTypeOptions: Partial<Omit<PothosSchemaTypes.ObjectFieldOptions<Types, {}, OutputRef<ConnectionShape<Types, unknown, false, true, true>>, boolean, {}, ConnectionShape<Types, unknown, false, true, true>>, 'args' | 'resolve' | 'type'>>; | ||
defaultEdgeTypeOptions: Partial<Omit<PothosSchemaTypes.ObjectFieldOptions<Types, {}, OutputRef<{ | ||
cursor: string; | ||
node: unknown; | ||
}>, boolean, {}, { | ||
cursor: string; | ||
node: unknown; | ||
}>, 'args' | 'resolve' | 'type'>>; | ||
}>; | ||
@@ -47,0 +55,0 @@ export interface DefaultEdgesNullability { |
@@ -237,3 +237,3 @@ import SchemaBuilder, { createContextCache, getTypeBrand, InputObjectRef, ObjectRef, verifyRef } from '@pothos/core'; | ||
schemaBuilderProto.connectionObject = function connectionObject({ type, name: connectionName, edgesNullable: edgesNullableField, nodeNullable, ...connectionOptions }, edgeOptionsOrRef) { | ||
var ref; | ||
var ref, ref1; | ||
verifyRef(type); | ||
@@ -253,2 +253,3 @@ const { edgesFieldOptions: { nullable: edgesNullable = { | ||
this.objectType(connectionRef, { | ||
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultConnectionTypeOptions, | ||
...connectionOptions, | ||
@@ -279,6 +280,7 @@ fields: (t) => { | ||
connectionRefs.get(this).push(connectionRef); | ||
(ref = globalConnectionFieldsMap.get(this)) === null || ref === void 0 ? void 0 : ref.forEach((fieldFn) => void fieldFn(connectionRef)); | ||
(ref1 = globalConnectionFieldsMap.get(this)) === null || ref1 === void 0 ? void 0 : ref1.forEach((fieldFn) => void fieldFn(connectionRef)); | ||
return connectionRef; | ||
}; | ||
schemaBuilderProto.edgeObject = function edgeObject({ type, name: edgeName, nodeNullable: nodeFieldNullable, ...edgeOptions }) { | ||
var ref; | ||
verifyRef(type); | ||
@@ -289,2 +291,3 @@ const { cursorType = "String", cursorFieldOptions = {}, nodeFieldOptions: { nullable: nodeNullable = false, ...nodeFieldOptions } = {}, } = this.options.relayOptions; | ||
this.objectType(edgeRef, { | ||
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultEdgeTypeOptions, | ||
...edgeOptions, | ||
@@ -291,0 +294,0 @@ fields: (t) => { |
@@ -288,3 +288,3 @@ "use strict"; | ||
schemaBuilderProto.connectionObject = function connectionObject({ type , name: connectionName , edgesNullable: edgesNullableField , nodeNullable , ...connectionOptions }, edgeOptionsOrRef) { | ||
var ref; | ||
var ref, ref1; | ||
(0, _core.verifyRef)(type); | ||
@@ -304,2 +304,3 @@ const { edgesFieldOptions: { nullable: edgesNullable = { | ||
this.objectType(connectionRef, { | ||
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultConnectionTypeOptions, | ||
...connectionOptions, | ||
@@ -330,6 +331,7 @@ fields: (t)=>{ | ||
connectionRefs.get(this).push(connectionRef); | ||
(ref = globalConnectionFieldsMap.get(this)) === null || ref === void 0 ? void 0 : ref.forEach((fieldFn)=>void fieldFn(connectionRef)); | ||
(ref1 = globalConnectionFieldsMap.get(this)) === null || ref1 === void 0 ? void 0 : ref1.forEach((fieldFn)=>void fieldFn(connectionRef)); | ||
return connectionRef; | ||
}; | ||
schemaBuilderProto.edgeObject = function edgeObject({ type , name: edgeName , nodeNullable: nodeFieldNullable , ...edgeOptions }) { | ||
var ref; | ||
(0, _core.verifyRef)(type); | ||
@@ -340,2 +342,3 @@ const { cursorType ='String' , cursorFieldOptions ={} , nodeFieldOptions: { nullable: nodeNullable = false , ...nodeFieldOptions } = {} , } = this.options.relayOptions; | ||
this.objectType(edgeRef, { | ||
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultEdgeTypeOptions, | ||
...edgeOptions, | ||
@@ -342,0 +345,0 @@ fields: (t)=>{ |
{ | ||
"name": "@pothos/plugin-relay", | ||
"version": "3.15.0", | ||
"version": "3.16.0", | ||
"description": "A Pothos plugin for adding relay style connections, nodes, and cursor based pagination to your GraphQL schema", | ||
@@ -41,2 +41,3 @@ "main": "./lib/index.js", | ||
"@pothos/core": "3.12.1", | ||
"@pothos/plugin-complexity": "3.4.0", | ||
"@pothos/test-utils": "1.2.3", | ||
@@ -43,0 +44,0 @@ "graphql": "16.5.0", |
@@ -57,2 +57,4 @@ # Relay Plugin | ||
- `lastArgOptions`: Options for the `last` arg on a connection field. | ||
- `defaultConnectionTypeOptions`: Options for the `Connection` Object type. | ||
- `defaultEdgeTypeOptions`: Options for the `Edge` Object type. | ||
@@ -59,0 +61,0 @@ ### Global IDs |
@@ -111,3 +111,3 @@ import { GraphQLResolveInfo } from 'graphql'; | ||
return this.field<{}, InterfaceRef<unknown>, unknown, Promise<unknown>, true>({ | ||
...options, | ||
...(options as {}), | ||
type: this.builder.nodeInterfaceRef(), | ||
@@ -197,5 +197,5 @@ nullable: true, | ||
...this.arg.connectionArgs(), | ||
} as unknown as {}, | ||
}, | ||
resolve: fieldOptions.resolve as never, | ||
}); | ||
} as never); | ||
@@ -202,0 +202,0 @@ if (!(connectionOptionsOrRef instanceof ObjectRef)) { |
@@ -259,3 +259,4 @@ import { | ||
Nullable, | ||
Args & InputFieldsFromShape<DefaultConnectionArguments>, | ||
(InputFieldMap extends Args ? {} : Args) & | ||
InputFieldsFromShape<DefaultConnectionArguments>, | ||
Kind, | ||
@@ -262,0 +263,0 @@ ParentShape, |
@@ -406,2 +406,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
this.objectType(connectionRef, { | ||
...(this.options.relayOptions?.defaultConnectionTypeOptions as {}), | ||
...connectionOptions, | ||
@@ -466,2 +467,3 @@ fields: (t) => ({ | ||
this.objectType(edgeRef, { | ||
...(this.options.relayOptions?.defaultEdgeTypeOptions as {}), | ||
...edgeOptions, | ||
@@ -468,0 +470,0 @@ fields: (t) => ({ |
@@ -180,2 +180,28 @@ import { GraphQLResolveInfo } from 'graphql'; | ||
}; | ||
defaultConnectionTypeOptions: Partial< | ||
Omit< | ||
PothosSchemaTypes.ObjectFieldOptions< | ||
Types, | ||
{}, | ||
OutputRef<ConnectionShape<Types, unknown, false, true, true>>, | ||
boolean, | ||
{}, | ||
ConnectionShape<Types, unknown, false, true, true> | ||
>, | ||
'args' | 'resolve' | 'type' | ||
> | ||
>; | ||
defaultEdgeTypeOptions: Partial< | ||
Omit< | ||
PothosSchemaTypes.ObjectFieldOptions< | ||
Types, | ||
{}, | ||
OutputRef<{ cursor: string; node: unknown }>, | ||
boolean, | ||
{}, | ||
{ cursor: string; node: unknown } | ||
>, | ||
'args' | 'resolve' | 'type' | ||
> | ||
>; | ||
}>; | ||
@@ -182,0 +208,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
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
358493
4088
676
6