New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pothos/plugin-relay

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pothos/plugin-relay - npm Package Compare versions

Comparing version 3.29.0 to 3.29.1

6

CHANGELOG.md
# Change Log
## 3.29.1
### Patch Changes
- 15d19a38: Fix hasNextPage when paginating backwards with resolveOffsetConnection
## 3.29.0

@@ -4,0 +10,0 @@

36

dts/types.d.ts
import { GraphQLResolveInfo } from 'graphql';
import { EmptyToOptional, FieldKind, FieldNullability, FieldOptionsFromKind, FieldRequiredness, InputFieldMap, InputFieldRef, InputFieldsFromShape, InputRef, InputShape, InputShapeFromFields, inputShapeKey, InterfaceParam, MaybePromise, Normalize, ObjectFieldsShape, ObjectParam, ObjectRef, ObjectTypeOptions, OutputRef, OutputRefShape, OutputShape, OutputType, ParentShape, Resolver, SchemaTypes, ShapeFromListTypeParam, ShapeFromTypeParam } from '@pothos/core';
export declare type RelayPluginOptions<Types extends SchemaTypes> = EmptyToOptional<{
export type RelayPluginOptions<Types extends SchemaTypes> = EmptyToOptional<{
idFieldName?: string;

@@ -76,3 +76,3 @@ idFieldOptions?: Partial<Omit<PothosSchemaTypes.ObjectFieldOptions<Types, {}, 'ID', boolean, {}, PageInfoShape>, 'args' | 'resolve' | 'type' | 'nullable'>>;

}
export declare type ConnectionShape<Types extends SchemaTypes, T, Nullable, EdgesNullable extends FieldNullability<[unknown]> = Types['DefaultEdgesNullability'], NodeNullable extends boolean = Types['DefaultNodeNullability']> = (Nullable extends false ? never : null | undefined) | (Types['Connection'] & {
export type ConnectionShape<Types extends SchemaTypes, T, Nullable, EdgesNullable extends FieldNullability<[unknown]> = Types['DefaultEdgesNullability'], NodeNullable extends boolean = Types['DefaultNodeNullability']> = (Nullable extends false ? never : null | undefined) | (Types['Connection'] & {
pageInfo: PageInfoShape;

@@ -86,9 +86,9 @@ edges: ShapeFromListTypeParam<Types, [

});
export declare type ConnectionShapeFromBaseShape<Types extends SchemaTypes, Shape, Nullable extends boolean> = ConnectionShape<Types, Shape, Nullable>;
export declare type ConnectionShapeForType<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean> = ConnectionShape<Types, ShapeFromTypeParam<Types, Type, false>, Nullable, EdgeNullability, NodeNullability>;
export declare type ConnectionShapeFromResolve<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Resolved> = Resolved extends Promise<infer T> ? NonNullable<T> extends ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> ? NonNullable<T> : ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> : Resolved extends ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> ? NonNullable<Resolved> : ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability>;
export type ConnectionShapeFromBaseShape<Types extends SchemaTypes, Shape, Nullable extends boolean> = ConnectionShape<Types, Shape, Nullable>;
export type ConnectionShapeForType<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean> = ConnectionShape<Types, ShapeFromTypeParam<Types, Type, false>, Nullable, EdgeNullability, NodeNullability>;
export type ConnectionShapeFromResolve<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[unknown]>, NodeNullability extends boolean, Resolved> = Resolved extends Promise<infer T> ? NonNullable<T> extends ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> ? NonNullable<T> : ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> : Resolved extends ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> ? NonNullable<Resolved> : ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability>;
export interface DefaultConnectionArguments extends PothosSchemaTypes.DefaultConnectionArguments {
}
export declare type NodeBaseObjectOptionsForParam<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = ObjectTypeOptions<Types, Param, ParentShape<Types, Param>, Interfaces>;
export declare type NodeObjectOptions<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = NodeBaseObjectOptionsForParam<Types, Param, Interfaces> & {
export type NodeBaseObjectOptionsForParam<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = ObjectTypeOptions<Types, Param, ParentShape<Types, Param>, Interfaces>;
export type NodeObjectOptions<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = NodeBaseObjectOptionsForParam<Types, Param, Interfaces> & {
id: Omit<FieldOptionsFromKind<Types, ParentShape<Types, Param>, 'ID', false, {}, 'Object', OutputShape<Types, 'ID'>, MaybePromise<OutputShape<Types, 'ID'>>>, 'args' | 'nullable' | 'type'>;

@@ -101,11 +101,11 @@ brandLoadedObjects?: boolean;

};
export declare type GlobalIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, 'ID', Nullable, Args, Kind, ParentShape, ResolveReturnShape>, 'resolve' | 'type'> & {
export type GlobalIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, 'ID', Nullable, Args, Kind, ParentShape, ResolveReturnShape>, 'resolve' | 'type'> & {
resolve: Resolver<ParentShape, InputShapeFromFields<Args>, Types['Context'], ShapeFromTypeParam<Types, OutputRefShape<GlobalIDShape<Types> | string>, true>, ResolveReturnShape>;
};
export declare type GlobalIDInputFieldOptions<Types extends SchemaTypes, Req extends boolean, Kind extends 'Arg' | 'InputObject'> = Omit<PothosSchemaTypes.InputFieldOptionsByKind<Types, 'ID', Req>[Kind], 'type'>;
export declare type GlobalIDListInputFieldOptions<Types extends SchemaTypes, Req extends FieldRequiredness<['ID']>, Kind extends 'Arg' | 'InputObject'> = Omit<PothosSchemaTypes.InputFieldOptionsByKind<Types, ['ID'], Req>[Kind], 'type'>;
export declare type NodeIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, 'ID', Nullable, Args, Kind, ParentShape, ResolveReturnShape>, 'resolve' | 'type'> & {
export type GlobalIDInputFieldOptions<Types extends SchemaTypes, Req extends boolean, Kind extends 'Arg' | 'InputObject'> = Omit<PothosSchemaTypes.InputFieldOptionsByKind<Types, 'ID', Req>[Kind], 'type'>;
export type GlobalIDListInputFieldOptions<Types extends SchemaTypes, Req extends FieldRequiredness<['ID']>, Kind extends 'Arg' | 'InputObject'> = Omit<PothosSchemaTypes.InputFieldOptionsByKind<Types, ['ID'], Req>[Kind], 'type'>;
export type NodeIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, 'ID', Nullable, Args, Kind, ParentShape, ResolveReturnShape>, 'resolve' | 'type'> & {
resolve: Resolver<ParentShape, InputShapeFromFields<Args>, Types['Context'], ShapeFromTypeParam<Types, OutputRefShape<GlobalIDShape<Types> | string>, true>, ResolveReturnShape>;
};
export declare type GlobalIDListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends FieldNullability<[unknown]>, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, [
export type GlobalIDListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends FieldNullability<[unknown]>, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, [
'ID'

@@ -120,6 +120,6 @@ ], Nullable, Args, Kind, ParentShape, ResolveReturnShape>, 'resolve' | 'type'> & {

};
export declare type NodeFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, OutputRefShape<GlobalIDShape<Types> | string>, true, Args, Kind, ParentShape, ResolveReturnShape>, 'nullable' | 'resolve' | 'type'> & {
export type NodeFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, OutputRefShape<GlobalIDShape<Types> | string>, true, Args, Kind, ParentShape, ResolveReturnShape>, 'nullable' | 'resolve' | 'type'> & {
id: Resolver<ParentShape, InputShapeFromFields<Args>, Types['Context'], ShapeFromTypeParam<Types, OutputRefShape<GlobalIDShape<Types> | string>, true>, ResolveReturnShape>;
};
export declare type NodeListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, [
export type NodeListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, [
OutputRefShape<GlobalIDShape<Types> | string>

@@ -143,3 +143,3 @@ ], {

}
export declare type RelayMutationInputOptions<Types extends SchemaTypes, Fields extends InputFieldMap, InputName extends string> = Omit<PothosSchemaTypes.InputObjectTypeOptions<Types, Fields>, 'fields'> & {
export type RelayMutationInputOptions<Types extends SchemaTypes, Fields extends InputFieldMap, InputName extends string> = Omit<PothosSchemaTypes.InputObjectTypeOptions<Types, Fields>, 'fields'> & {
name?: string;

@@ -149,12 +149,12 @@ argName?: InputName;

};
export declare type RelayMutationFieldOptions<Types extends SchemaTypes, Fields extends InputFieldMap, Nullable extends boolean, InputName extends string, ResolveShape, ResolveReturnShape> = Omit<FieldOptionsFromKind<Types, Types['Root'], OutputRef<ResolveShape>, Nullable, {
export type RelayMutationFieldOptions<Types extends SchemaTypes, Fields extends InputFieldMap, Nullable extends boolean, InputName extends string, ResolveShape, ResolveReturnShape> = Omit<FieldOptionsFromKind<Types, Types['Root'], OutputRef<ResolveShape>, Nullable, {
[K in InputName]: InputFieldRef<InputShapeWithClientMutationId<Types, Fields>>;
}, 'Mutation', ResolveShape, ResolveReturnShape>, 'args' | 'type'>;
export declare type RelayMutationPayloadOptions<Types extends SchemaTypes, Shape, Interfaces extends InterfaceParam<Types>[]> = Omit<PothosSchemaTypes.ObjectTypeOptions<Types, Shape> | PothosSchemaTypes.ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, 'fields'> & {
export type RelayMutationPayloadOptions<Types extends SchemaTypes, Shape, Interfaces extends InterfaceParam<Types>[]> = Omit<PothosSchemaTypes.ObjectTypeOptions<Types, Shape> | PothosSchemaTypes.ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, 'fields'> & {
name?: string;
outputFields: ObjectFieldsShape<Types, Shape>;
};
export declare type InputShapeWithClientMutationId<Types extends SchemaTypes, Fields extends InputFieldMap> = InputShapeFromFields<Fields & {
export type InputShapeWithClientMutationId<Types extends SchemaTypes, Fields extends InputFieldMap> = InputShapeFromFields<Fields & {
clientMutationId: InputFieldRef<Types['Scalars']['ID']['Input']>;
}>;
//# sourceMappingURL=types.d.ts.map

@@ -38,5 +38,5 @@ import { MaybePromise, SchemaTypes } from '@pothos/core';

}, false>;
declare type NodeType<T> = T extends Promise<(infer N)[] | null> | (infer N)[] | null ? N : never;
type NodeType<T> = T extends Promise<(infer N)[] | null> | (infer N)[] | null ? N : never;
export declare function resolveCursorConnection<U extends Promise<unknown[] | null> | unknown[] | null>(options: ResolveCursorConnectionOptions<NodeType<U>>, resolve: (params: ResolveCursorConnectionArgs) => U): Promise<ConnectionShape<SchemaTypes, NodeType<U>, false, false, false>>;
export {};
//# sourceMappingURL=connections.d.ts.map

@@ -80,6 +80,6 @@ import { assertArray, ObjectRef, RootFieldBuilder } from '@pothos/core';

fieldBuilderProto.connection = function connection({ type, edgesNullable, nodeNullable, ...fieldOptions }, connectionOptionsOrRef = {}, edgeOptionsOrRef = {}) {
var ref;
var _this_builder_options_relayOptions;
const connectionRef = connectionOptionsOrRef instanceof ObjectRef ? connectionOptionsOrRef : this.builder.objectRef("Unnamed connection");
const fieldRef = this.field({
...(ref = this.builder.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultConnectionFieldOptions,
...(_this_builder_options_relayOptions = this.builder.options.relayOptions) === null || _this_builder_options_relayOptions === void 0 ? void 0 : _this_builder_options_relayOptions.defaultConnectionFieldOptions,
...fieldOptions,

@@ -95,4 +95,4 @@ type: connectionRef,

this.builder.configStore.onFieldUse(fieldRef, (fieldConfig) => {
var _name;
const connectionName = (_name = connectionOptionsOrRef.name) !== null && _name !== void 0 ? _name : `${this.typename}${capitalize(fieldConfig.name)}${fieldConfig.name.toLowerCase().endsWith("connection") ? "" : "Connection"}`;
var _connectionOptionsOrRef_name;
const connectionName = (_connectionOptionsOrRef_name = connectionOptionsOrRef.name) !== null && _connectionOptionsOrRef_name !== void 0 ? _connectionOptionsOrRef_name : `${this.typename}${capitalize(fieldConfig.name)}${fieldConfig.name.toLowerCase().endsWith("connection") ? "" : "Connection"}`;
this.builder.connectionObject({

@@ -99,0 +99,0 @@ type,

@@ -14,4 +14,4 @@ import './global-types.js';

const argMappings = mapInputFields(fieldConfig.args, this.buildCache, (inputField) => {
var ref;
if ((ref = inputField.extensions) === null || ref === void 0 ? void 0 : ref.isRelayGlobalID) {
var _inputField_extensions;
if ((_inputField_extensions = inputField.extensions) === null || _inputField_extensions === void 0 ? void 0 : _inputField_extensions.isRelayGlobalID) {
return true;

@@ -29,4 +29,4 @@ }

const argMappings = mapInputFields(fieldConfig.args, this.buildCache, (inputField) => {
var ref;
if ((ref = inputField.extensions) === null || ref === void 0 ? void 0 : ref.isRelayGlobalID) {
var _inputField_extensions;
if ((_inputField_extensions = inputField.extensions) === null || _inputField_extensions === void 0 ? void 0 : _inputField_extensions.isRelayGlobalID) {
return true;

@@ -33,0 +33,0 @@ }

@@ -47,3 +47,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { defaultTypeResolver } from 'graphql';

nodeInterfaceRefMap.set(this, ref);
var ref1;
var _this_options_relayOptions_idFieldName;
ref.implement({

@@ -83,5 +83,5 @@ resolveType: (value, context, info, graphQLType) => {

fields: (t) => {
var ref;
var _this_options_relayOptions;
return {
[(ref1 = (ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.idFieldName) !== null && ref1 !== void 0 ? ref1 : "id"]: t.globalID({
[(_this_options_relayOptions_idFieldName = (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.idFieldName) !== null && _this_options_relayOptions_idFieldName !== void 0 ? _this_options_relayOptions_idFieldName : "id"]: t.globalID({
nullable: false,

@@ -133,6 +133,6 @@ resolve: (parent) => {

let nodeName;
var _isTypeOf;
var _options_isTypeOf;
const ref = this.objectType(param, {
...options,
isTypeOf: (_isTypeOf = options.isTypeOf) !== null && _isTypeOf !== void 0 ? _isTypeOf : typeof param === "function" ? (maybeNode, context, info) => {
isTypeOf: (_options_isTypeOf = options.isTypeOf) !== null && _options_isTypeOf !== void 0 ? _options_isTypeOf : typeof param === "function" ? (maybeNode, context, info) => {
if (!maybeNode) {

@@ -160,4 +160,4 @@ return false;

nodeName = nodeConfig.name;
var _idFieldName;
this.objectField(ref, (_idFieldName = this.options.relayOptions.idFieldName) !== null && _idFieldName !== void 0 ? _idFieldName : "id", (t) => t.globalID({
var _this_options_relayOptions_idFieldName;
this.objectField(ref, (_this_options_relayOptions_idFieldName = this.options.relayOptions.idFieldName) !== null && _this_options_relayOptions_idFieldName !== void 0 ? _this_options_relayOptions_idFieldName : "id", (t) => t.globalID({
nullable: false,

@@ -177,7 +177,7 @@ ...this.options.relayOptions.idFieldOptions,

schemaBuilderProto.globalConnectionField = function globalConnectionField(name, field) {
var ref;
var _connectionRefs_get;
const onRef = (ref) => {
this.objectField(ref, name, field);
};
(ref = connectionRefs.get(this)) === null || ref === void 0 ? void 0 : ref.forEach((ref) => void onRef(ref));
(_connectionRefs_get = connectionRefs.get(this)) === null || _connectionRefs_get === void 0 ? void 0 : _connectionRefs_get.forEach((ref) => void onRef(ref));
if (!globalConnectionFieldsMap.has(this)) {

@@ -189,7 +189,7 @@ globalConnectionFieldsMap.set(this, []);

schemaBuilderProto.globalConnectionFields = function globalConnectionFields(fields) {
var ref;
var _connectionRefs_get;
const onRef = (ref) => {
this.objectFields(ref, fields);
};
(ref = connectionRefs.get(this)) === null || ref === void 0 ? void 0 : ref.forEach((ref) => void onRef(ref));
(_connectionRefs_get = connectionRefs.get(this)) === null || _connectionRefs_get === void 0 ? void 0 : _connectionRefs_get.forEach((ref) => void onRef(ref));
if (!globalConnectionFieldsMap.has(this)) {

@@ -202,3 +202,3 @@ globalConnectionFieldsMap.set(this, []);

schemaBuilderProto.relayMutationField = function relayMutationField(fieldName, inputOptionsOrRef, { resolve, ...fieldOptions }, { name: payloadName = `${capitalize(fieldName)}Payload`, outputFields, interfaces, ...paylaodOptions }) {
var ref;
var _this_options_relayOptions;
const { relayOptions: { clientMutationIdInputOptions = {}, clientMutationIdFieldOptions = {}, mutationInputArgOptions = {} } } = this.options;

@@ -212,7 +212,7 @@ const includeClientMutationId = this.options.relayOptions.clientMutationId !== "omit";

else {
var ref1;
var _this_options_relayOptions1;
const { name: inputName = `${capitalize(fieldName)}Input`, argName: argNameFromOptions = "input", inputFields, ...inputOptions } = inputOptionsOrRef;
argName = argNameFromOptions;
inputRef = this.inputType(inputName, {
...(ref1 = this.options.relayOptions) === null || ref1 === void 0 ? void 0 : ref1.defaultMutationInputTypeOptions,
...(_this_options_relayOptions1 = this.options.relayOptions) === null || _this_options_relayOptions1 === void 0 ? void 0 : _this_options_relayOptions1.defaultMutationInputTypeOptions,
...inputOptions,

@@ -231,3 +231,3 @@ fields: (t) => ({

const payloadRef = this.objectRef(payloadName).implement({
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultPayloadTypeOptions,
...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultPayloadTypeOptions,
...paylaodOptions,

@@ -268,3 +268,3 @@ interfaces: interfaces,

schemaBuilderProto.connectionObject = function connectionObject({ type, name: connectionName, edgesNullable: edgesNullableField, nodeNullable, ...connectionOptions }, edgeOptionsOrRef) {
var ref, ref1;
var _this_options_relayOptions, _globalConnectionFieldsMap_get;
verifyRef(type);

@@ -287,8 +287,8 @@ const { edgesFieldOptions: { nullable: edgesNullable = {

const edgeItemsNullable = typeof edgesNullableOption === "object" && "items" in edgesNullableOption ? edgesNullableOption.items : false;
var ref2, ref3, ref4;
var _ref, _ref1, _con_edges_map;
this.objectType(connectionRef, {
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultConnectionTypeOptions,
...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultConnectionTypeOptions,
...connectionOptions,
fields: (t) => {
var ref, ref1;
var _this_options_relayOptions, _this_options_relayOptions_nodeFieldOptions;
return {

@@ -317,10 +317,10 @@ pageInfo: t.field({

list: edgeListNullable,
items: (ref3 = (ref2 = edgeItemsNullable !== null && edgeItemsNullable !== void 0 ? edgeItemsNullable : nodeNullable) !== null && ref2 !== void 0 ? ref2 : (ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : (ref1 = ref.nodeFieldOptions) === null || ref1 === void 0 ? void 0 : ref1.nullable) !== null && ref3 !== void 0 ? ref3 : false
items: (_ref1 = (_ref = edgeItemsNullable !== null && edgeItemsNullable !== void 0 ? edgeItemsNullable : nodeNullable) !== null && _ref !== void 0 ? _ref : (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : (_this_options_relayOptions_nodeFieldOptions = _this_options_relayOptions.nodeFieldOptions) === null || _this_options_relayOptions_nodeFieldOptions === void 0 ? void 0 : _this_options_relayOptions_nodeFieldOptions.nullable) !== null && _ref1 !== void 0 ? _ref1 : false
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
resolve: (con) => {
var ref;
return (ref4 = (ref = con.edges) === null || ref === void 0 ? void 0 : ref.map((edge) => {
var _con_edges;
return (_con_edges_map = (_con_edges = con.edges) === null || _con_edges === void 0 ? void 0 : _con_edges.map((edge) => {
return edge === null || edge === void 0 ? void 0 : edge.node;
})) !== null && ref4 !== void 0 ? ref4 : [];
})) !== null && _con_edges_map !== void 0 ? _con_edges_map : [];
}

@@ -337,7 +337,7 @@ })

connectionRefs.get(this).push(connectionRef);
(ref1 = globalConnectionFieldsMap.get(this)) === null || ref1 === void 0 ? void 0 : ref1.forEach((fieldFn) => void fieldFn(connectionRef));
(_globalConnectionFieldsMap_get = globalConnectionFieldsMap.get(this)) === null || _globalConnectionFieldsMap_get === void 0 ? void 0 : _globalConnectionFieldsMap_get.forEach((fieldFn) => void fieldFn(connectionRef));
return connectionRef;
};
schemaBuilderProto.edgeObject = function edgeObject({ type, name: edgeName, nodeNullable: nodeFieldNullable, ...edgeOptions }) {
var ref;
var _this_options_relayOptions;
verifyRef(type);

@@ -348,3 +348,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,
...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultEdgeTypeOptions,
...edgeOptions,

@@ -351,0 +351,0 @@ fields: (t) => {

import { GraphQLResolveInfo } from 'graphql';
import { EmptyToOptional, FieldKind, FieldNullability, FieldOptionsFromKind, FieldRequiredness, InputFieldMap, InputFieldRef, InputFieldsFromShape, InputRef, InputShape, InputShapeFromFields, inputShapeKey, InterfaceParam, MaybePromise, Normalize, ObjectFieldsShape, ObjectParam, ObjectRef, ObjectTypeOptions, OutputRef, OutputRefShape, OutputShape, OutputType, ParentShape, Resolver, SchemaTypes, ShapeFromListTypeParam, ShapeFromTypeParam } from '@pothos/core';
export declare type RelayPluginOptions<Types extends SchemaTypes> = EmptyToOptional<{
export type RelayPluginOptions<Types extends SchemaTypes> = EmptyToOptional<{
idFieldName?: string;

@@ -78,3 +78,3 @@ idFieldOptions?: Partial<Omit<PothosSchemaTypes.ObjectFieldOptions<Types, {}, "ID", boolean, {}, PageInfoShape>, "args" | "resolve" | "type" | "nullable">>;

}
export declare type ConnectionShape<Types extends SchemaTypes, T, Nullable, EdgesNullable extends FieldNullability<[
export type ConnectionShape<Types extends SchemaTypes, T, Nullable, EdgesNullable extends FieldNullability<[
unknown

@@ -90,7 +90,7 @@ ]> = Types["DefaultEdgesNullability"], NodeNullable extends boolean = Types["DefaultNodeNullability"]> = (Nullable extends false ? never : null | undefined) | (Types["Connection"] & {

});
export declare type ConnectionShapeFromBaseShape<Types extends SchemaTypes, Shape, Nullable extends boolean> = ConnectionShape<Types, Shape, Nullable>;
export declare type ConnectionShapeForType<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[
export type ConnectionShapeFromBaseShape<Types extends SchemaTypes, Shape, Nullable extends boolean> = ConnectionShape<Types, Shape, Nullable>;
export type ConnectionShapeForType<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[
unknown
]>, NodeNullability extends boolean> = ConnectionShape<Types, ShapeFromTypeParam<Types, Type, false>, Nullable, EdgeNullability, NodeNullability>;
export declare type ConnectionShapeFromResolve<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[
export type ConnectionShapeFromResolve<Types extends SchemaTypes, Type extends OutputType<Types>, Nullable extends boolean, EdgeNullability extends FieldNullability<[
unknown

@@ -100,4 +100,4 @@ ]>, NodeNullability extends boolean, Resolved> = Resolved extends Promise<infer T> ? NonNullable<T> extends ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> ? NonNullable<T> : ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> : Resolved extends ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability> ? NonNullable<Resolved> : ConnectionShapeForType<Types, Type, Nullable, EdgeNullability, NodeNullability>;

}
export declare type NodeBaseObjectOptionsForParam<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = ObjectTypeOptions<Types, Param, ParentShape<Types, Param>, Interfaces>;
export declare type NodeObjectOptions<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = NodeBaseObjectOptionsForParam<Types, Param, Interfaces> & {
export type NodeBaseObjectOptionsForParam<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = ObjectTypeOptions<Types, Param, ParentShape<Types, Param>, Interfaces>;
export type NodeObjectOptions<Types extends SchemaTypes, Param extends ObjectParam<Types>, Interfaces extends InterfaceParam<Types>[]> = NodeBaseObjectOptionsForParam<Types, Param, Interfaces> & {
id: Omit<FieldOptionsFromKind<Types, ParentShape<Types, Param>, "ID", false, {}, "Object", OutputShape<Types, "ID">, MaybePromise<OutputShape<Types, "ID">>>, "args" | "nullable" | "type">;

@@ -110,7 +110,7 @@ brandLoadedObjects?: boolean;

};
export declare type GlobalIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, "ID", Nullable, Args, Kind, ParentShape, ResolveReturnShape>, "resolve" | "type"> & {
export type GlobalIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, "ID", Nullable, Args, Kind, ParentShape, ResolveReturnShape>, "resolve" | "type"> & {
resolve: Resolver<ParentShape, InputShapeFromFields<Args>, Types["Context"], ShapeFromTypeParam<Types, OutputRefShape<GlobalIDShape<Types> | string>, true>, ResolveReturnShape>;
};
export declare type GlobalIDInputFieldOptions<Types extends SchemaTypes, Req extends boolean, Kind extends "Arg" | "InputObject"> = Omit<PothosSchemaTypes.InputFieldOptionsByKind<Types, "ID", Req>[Kind], "type">;
export declare type GlobalIDListInputFieldOptions<Types extends SchemaTypes, Req extends FieldRequiredness<[
export type GlobalIDInputFieldOptions<Types extends SchemaTypes, Req extends boolean, Kind extends "Arg" | "InputObject"> = Omit<PothosSchemaTypes.InputFieldOptionsByKind<Types, "ID", Req>[Kind], "type">;
export type GlobalIDListInputFieldOptions<Types extends SchemaTypes, Req extends FieldRequiredness<[
"ID"

@@ -120,6 +120,6 @@ ]>, Kind extends "Arg" | "InputObject"> = Omit<PothosSchemaTypes.InputFieldOptionsByKind<Types, [

], Req>[Kind], "type">;
export declare type NodeIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, "ID", Nullable, Args, Kind, ParentShape, ResolveReturnShape>, "resolve" | "type"> & {
export type NodeIDFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends boolean, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, "ID", Nullable, Args, Kind, ParentShape, ResolveReturnShape>, "resolve" | "type"> & {
resolve: Resolver<ParentShape, InputShapeFromFields<Args>, Types["Context"], ShapeFromTypeParam<Types, OutputRefShape<GlobalIDShape<Types> | string>, true>, ResolveReturnShape>;
};
export declare type GlobalIDListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends FieldNullability<[
export type GlobalIDListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, Nullable extends FieldNullability<[
unknown

@@ -136,6 +136,6 @@ ]>, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, [

};
export declare type NodeFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, OutputRefShape<GlobalIDShape<Types> | string>, true, Args, Kind, ParentShape, ResolveReturnShape>, "nullable" | "resolve" | "type"> & {
export type NodeFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, OutputRefShape<GlobalIDShape<Types> | string>, true, Args, Kind, ParentShape, ResolveReturnShape>, "nullable" | "resolve" | "type"> & {
id: Resolver<ParentShape, InputShapeFromFields<Args>, Types["Context"], ShapeFromTypeParam<Types, OutputRefShape<GlobalIDShape<Types> | string>, true>, ResolveReturnShape>;
};
export declare type NodeListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, [
export type NodeListFieldOptions<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap, ResolveReturnShape, Kind extends FieldKind = FieldKind> = Omit<FieldOptionsFromKind<Types, ParentShape, [
OutputRefShape<GlobalIDShape<Types> | string>

@@ -159,3 +159,3 @@ ], {

}
export declare type RelayMutationInputOptions<Types extends SchemaTypes, Fields extends InputFieldMap, InputName extends string> = Omit<PothosSchemaTypes.InputObjectTypeOptions<Types, Fields>, "fields"> & {
export type RelayMutationInputOptions<Types extends SchemaTypes, Fields extends InputFieldMap, InputName extends string> = Omit<PothosSchemaTypes.InputObjectTypeOptions<Types, Fields>, "fields"> & {
name?: string;

@@ -165,12 +165,12 @@ argName?: InputName;

};
export declare type RelayMutationFieldOptions<Types extends SchemaTypes, Fields extends InputFieldMap, Nullable extends boolean, InputName extends string, ResolveShape, ResolveReturnShape> = Omit<FieldOptionsFromKind<Types, Types["Root"], OutputRef<ResolveShape>, Nullable, {
export type RelayMutationFieldOptions<Types extends SchemaTypes, Fields extends InputFieldMap, Nullable extends boolean, InputName extends string, ResolveShape, ResolveReturnShape> = Omit<FieldOptionsFromKind<Types, Types["Root"], OutputRef<ResolveShape>, Nullable, {
[K in InputName]: InputFieldRef<InputShapeWithClientMutationId<Types, Fields>>;
}, "Mutation", ResolveShape, ResolveReturnShape>, "args" | "type">;
export declare type RelayMutationPayloadOptions<Types extends SchemaTypes, Shape, Interfaces extends InterfaceParam<Types>[]> = Omit<PothosSchemaTypes.ObjectTypeOptions<Types, Shape> | PothosSchemaTypes.ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, "fields"> & {
export type RelayMutationPayloadOptions<Types extends SchemaTypes, Shape, Interfaces extends InterfaceParam<Types>[]> = Omit<PothosSchemaTypes.ObjectTypeOptions<Types, Shape> | PothosSchemaTypes.ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, "fields"> & {
name?: string;
outputFields: ObjectFieldsShape<Types, Shape>;
};
export declare type InputShapeWithClientMutationId<Types extends SchemaTypes, Fields extends InputFieldMap> = InputShapeFromFields<Fields & {
export type InputShapeWithClientMutationId<Types extends SchemaTypes, Fields extends InputFieldMap> = InputShapeFromFields<Fields & {
clientMutationId: InputFieldRef<Types["Scalars"]["ID"]["Input"]>;
}>;
//# sourceMappingURL=types.d.ts.map

@@ -38,5 +38,5 @@ import { MaybePromise, SchemaTypes } from '@pothos/core';

}, false>;
declare type NodeType<T> = T extends Promise<(infer N)[] | null> | (infer N)[] | null ? N : never;
type NodeType<T> = T extends Promise<(infer N)[] | null> | (infer N)[] | null ? N : never;
export declare function resolveCursorConnection<U extends Promise<unknown[] | null> | unknown[] | null>(options: ResolveCursorConnectionOptions<NodeType<U>>, resolve: (params: ResolveCursorConnectionArgs) => U): Promise<ConnectionShape<SchemaTypes, NodeType<U>, false, false, false>>;
export {};
//# sourceMappingURL=connections.d.ts.map

@@ -7,6 +7,6 @@ import { decodeBase64, encodeBase64 } from '@pothos/core';

const { before, after, first, last } = options.args;
var _defaultSize;
const defaultSize = (_defaultSize = options.defaultSize) !== null && _defaultSize !== void 0 ? _defaultSize : DEFAULT_SIZE;
var _maxSize;
const maxSize = (_maxSize = options.maxSize) !== null && _maxSize !== void 0 ? _maxSize : DEFAULT_MAX_SIZE;
var _options_defaultSize;
const defaultSize = (_options_defaultSize = options.defaultSize) !== null && _options_defaultSize !== void 0 ? _options_defaultSize : DEFAULT_SIZE;
var _options_maxSize;
const maxSize = (_options_maxSize = options.maxSize) !== null && _options_maxSize !== void 0 ? _options_maxSize : DEFAULT_MAX_SIZE;
const beforeOffset = before ? cursorToOffset(before) : Number.POSITIVE_INFINITY;

@@ -33,16 +33,9 @@ const afterOffset = after ? cursorToOffset(after) : 0;

endOffset = Math.min(endOffset, startOffset + Math.min(size, maxSize));
// Get one extra to check for next page
endOffset += 1;
const totalSize = endOffset - startOffset;
const lowerBound = after == null ? 0 : afterOffset;
const hasPreviousPage = last == null ? startOffset > 0 : startOffset > lowerBound;
return {
offset: startOffset,
limit: endOffset - startOffset,
hasPreviousPage,
expectedSize: totalSize - 1,
hasNextPage: (resultSize) => {
const upperBound = before == null ? startOffset + resultSize : beforeOffset;
return last == null ? resultSize >= totalSize : upperBound > endOffset;
}
limit: totalSize + 1,
hasPreviousPage: startOffset > 0,
expectedSize: totalSize,
hasNextPage: (resultSize) => resultSize > totalSize
};

@@ -104,6 +97,6 @@ }

const { before, after, first, last } = options.args;
var _defaultSize;
const defaultSize = (_defaultSize = options.defaultSize) !== null && _defaultSize !== void 0 ? _defaultSize : DEFAULT_SIZE;
var _maxSize;
const maxSize = (_maxSize = options.maxSize) !== null && _maxSize !== void 0 ? _maxSize : DEFAULT_MAX_SIZE;
var _options_defaultSize;
const defaultSize = (_options_defaultSize = options.defaultSize) !== null && _options_defaultSize !== void 0 ? _options_defaultSize : DEFAULT_SIZE;
var _options_maxSize;
const maxSize = (_options_maxSize = options.maxSize) !== null && _options_maxSize !== void 0 ? _options_maxSize : DEFAULT_MAX_SIZE;
if (first != null && first < 0) {

@@ -115,4 +108,4 @@ throw new TypeError("Argument \"first\" must be a non-negative integer");

}
var ref;
const limit = Math.min((ref = first !== null && first !== void 0 ? first : last) !== null && ref !== void 0 ? ref : defaultSize, maxSize) + 1;
var _ref;
const limit = Math.min((_ref = first !== null && first !== void 0 ? first : last) !== null && _ref !== void 0 ? _ref : defaultSize, maxSize) + 1;
const inverted = after ? !!last && !first : !!before && !first || !first && !!last;

@@ -130,3 +123,3 @@ return {

export async function resolveCursorConnection(options, resolve) {
var ref, ref1;
var _edges_, _edges_1;
const { before, after, limit, inverted, expectedSize, hasPreviousPage, hasNextPage } = parseCurserArgs(options);

@@ -150,6 +143,6 @@ const nodes = await resolve({

});
var _after, ref2;
const startCursor = edges.length > 0 ? (ref = edges[0]) === null || ref === void 0 ? void 0 : ref.cursor : (ref2 = (_after = options.args.after) !== null && _after !== void 0 ? _after : options.args.before) !== null && ref2 !== void 0 ? ref2 : "";
var _after1, ref3;
const endCursor = edges.length > 0 ? (ref1 = edges[edges.length - 1]) === null || ref1 === void 0 ? void 0 : ref1.cursor : (ref3 = (_after1 = options.args.after) !== null && _after1 !== void 0 ? _after1 : options.args.before) !== null && ref3 !== void 0 ? ref3 : "";
var _options_args_after, _ref;
const startCursor = edges.length > 0 ? (_edges_ = edges[0]) === null || _edges_ === void 0 ? void 0 : _edges_.cursor : (_ref = (_options_args_after = options.args.after) !== null && _options_args_after !== void 0 ? _options_args_after : options.args.before) !== null && _ref !== void 0 ? _ref : "";
var _options_args_after1, _ref1;
const endCursor = edges.length > 0 ? (_edges_1 = edges[edges.length - 1]) === null || _edges_1 === void 0 ? void 0 : _edges_1.cursor : (_ref1 = (_options_args_after1 = options.args.after) !== null && _options_args_after1 !== void 0 ? _options_args_after1 : options.args.before) !== null && _ref1 !== void 0 ? _ref1 : "";
return {

@@ -156,0 +149,0 @@ edges: edges,

@@ -29,4 +29,4 @@ import { brandWithType, createContextCache } from '@pothos/core';

const options = config.pothosOptions;
var _brandLoadedObjects, ref;
const shouldBrandObjects = (ref = (_brandLoadedObjects = options.brandLoadedObjects) !== null && _brandLoadedObjects !== void 0 ? _brandLoadedObjects : builder.options.relayOptions.brandLoadedObjects) !== null && ref !== void 0 ? ref : false;
var _options_brandLoadedObjects, _ref;
const shouldBrandObjects = (_ref = (_options_brandLoadedObjects = options.brandLoadedObjects) !== null && _options_brandLoadedObjects !== void 0 ? _options_brandLoadedObjects : builder.options.relayOptions.brandLoadedObjects) !== null && _ref !== void 0 ? _ref : false;
const resultsForType = await resolveUncachedNodesForType(builder, context, info, ids, typename);

@@ -40,4 +40,4 @@ resultsForType.forEach((val, i) => {

}));
var _globalID;
return globalIDs.map((globalID) => globalID == null ? null : (_globalID = results[globalID]) !== null && _globalID !== void 0 ? _globalID : null);
var _results_globalID;
return globalIDs.map((globalID) => globalID == null ? null : (_results_globalID = results[globalID]) !== null && _results_globalID !== void 0 ? _results_globalID : null);
}

@@ -44,0 +44,0 @@ export async function resolveUncachedNodesForType(builder, context, info, ids, type) {

@@ -84,6 +84,6 @@ "use strict";

fieldBuilderProto.connection = function connection({ type , edgesNullable , nodeNullable , ...fieldOptions }, connectionOptionsOrRef = {}, edgeOptionsOrRef = {}) {
var ref;
var _this_builder_options_relayOptions;
const connectionRef = connectionOptionsOrRef instanceof _core.ObjectRef ? connectionOptionsOrRef : this.builder.objectRef('Unnamed connection');
const fieldRef = this.field({
...(ref = this.builder.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultConnectionFieldOptions,
...(_this_builder_options_relayOptions = this.builder.options.relayOptions) === null || _this_builder_options_relayOptions === void 0 ? void 0 : _this_builder_options_relayOptions.defaultConnectionFieldOptions,
...fieldOptions,

@@ -99,4 +99,4 @@ type: connectionRef,

this.builder.configStore.onFieldUse(fieldRef, (fieldConfig)=>{
var _name;
const connectionName = (_name = connectionOptionsOrRef.name) !== null && _name !== void 0 ? _name : `${this.typename}${(0, _utils.capitalize)(fieldConfig.name)}${fieldConfig.name.toLowerCase().endsWith('connection') ? '' : 'Connection'}`;
var _connectionOptionsOrRef_name;
const connectionName = (_connectionOptionsOrRef_name = connectionOptionsOrRef.name) !== null && _connectionOptionsOrRef_name !== void 0 ? _connectionOptionsOrRef_name : `${this.typename}${(0, _utils.capitalize)(fieldConfig.name)}${fieldConfig.name.toLowerCase().endsWith('connection') ? '' : 'Connection'}`;
this.builder.connectionObject({

@@ -103,0 +103,0 @@ type,

@@ -78,4 +78,4 @@ "use strict";

const argMappings = (0, _core.mapInputFields)(fieldConfig.args, this.buildCache, (inputField)=>{
var ref;
if ((ref = inputField.extensions) === null || ref === void 0 ? void 0 : ref.isRelayGlobalID) {
var _inputField_extensions;
if ((_inputField_extensions = inputField.extensions) === null || _inputField_extensions === void 0 ? void 0 : _inputField_extensions.isRelayGlobalID) {
return true;

@@ -93,4 +93,4 @@ }

const argMappings = (0, _core.mapInputFields)(fieldConfig.args, this.buildCache, (inputField)=>{
var ref;
if ((ref = inputField.extensions) === null || ref === void 0 ? void 0 : ref.isRelayGlobalID) {
var _inputField_extensions;
if ((_inputField_extensions = inputField.extensions) === null || _inputField_extensions === void 0 ? void 0 : _inputField_extensions.isRelayGlobalID) {
return true;

@@ -97,0 +97,0 @@ }

@@ -100,3 +100,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ "use strict";

nodeInterfaceRefMap.set(this, ref);
var ref1;
var _this_options_relayOptions_idFieldName;
ref.implement({

@@ -135,5 +135,5 @@ resolveType: (value, context, info, graphQLType)=>{

fields: (t)=>{
var ref;
var _this_options_relayOptions;
return {
[(ref1 = (ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.idFieldName) !== null && ref1 !== void 0 ? ref1 : 'id']: t.globalID({
[(_this_options_relayOptions_idFieldName = (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.idFieldName) !== null && _this_options_relayOptions_idFieldName !== void 0 ? _this_options_relayOptions_idFieldName : 'id']: t.globalID({
nullable: false,

@@ -185,6 +185,6 @@ resolve: (parent)=>{

let nodeName;
var _isTypeOf;
var _options_isTypeOf;
const ref = this.objectType(param, {
...options,
isTypeOf: (_isTypeOf = options.isTypeOf) !== null && _isTypeOf !== void 0 ? _isTypeOf : typeof param === 'function' ? (maybeNode, context, info)=>{
isTypeOf: (_options_isTypeOf = options.isTypeOf) !== null && _options_isTypeOf !== void 0 ? _options_isTypeOf : typeof param === 'function' ? (maybeNode, context, info)=>{
if (!maybeNode) {

@@ -211,4 +211,4 @@ return false;

nodeName = nodeConfig.name;
var _idFieldName;
this.objectField(ref, (_idFieldName = this.options.relayOptions.idFieldName) !== null && _idFieldName !== void 0 ? _idFieldName : 'id', (t)=>t.globalID({
var _this_options_relayOptions_idFieldName;
this.objectField(ref, (_this_options_relayOptions_idFieldName = this.options.relayOptions.idFieldName) !== null && _this_options_relayOptions_idFieldName !== void 0 ? _this_options_relayOptions_idFieldName : 'id', (t)=>t.globalID({
nullable: false,

@@ -228,7 +228,7 @@ ...this.options.relayOptions.idFieldOptions,

schemaBuilderProto.globalConnectionField = function globalConnectionField(name, field) {
var ref;
var _connectionRefs_get;
const onRef = (ref)=>{
this.objectField(ref, name, field);
};
(ref = connectionRefs.get(this)) === null || ref === void 0 ? void 0 : ref.forEach((ref)=>void onRef(ref));
(_connectionRefs_get = connectionRefs.get(this)) === null || _connectionRefs_get === void 0 ? void 0 : _connectionRefs_get.forEach((ref)=>void onRef(ref));
if (!globalConnectionFieldsMap.has(this)) {

@@ -240,7 +240,7 @@ globalConnectionFieldsMap.set(this, []);

schemaBuilderProto.globalConnectionFields = function globalConnectionFields(fields) {
var ref;
var _connectionRefs_get;
const onRef = (ref)=>{
this.objectFields(ref, fields);
};
(ref = connectionRefs.get(this)) === null || ref === void 0 ? void 0 : ref.forEach((ref)=>void onRef(ref));
(_connectionRefs_get = connectionRefs.get(this)) === null || _connectionRefs_get === void 0 ? void 0 : _connectionRefs_get.forEach((ref)=>void onRef(ref));
if (!globalConnectionFieldsMap.has(this)) {

@@ -253,3 +253,3 @@ globalConnectionFieldsMap.set(this, []);

schemaBuilderProto.relayMutationField = function relayMutationField(fieldName, inputOptionsOrRef, { resolve , ...fieldOptions }, { name: payloadName = `${(0, _utils.capitalize)(fieldName)}Payload` , outputFields , interfaces , ...paylaodOptions }) {
var ref;
var _this_options_relayOptions;
const { relayOptions: { clientMutationIdInputOptions ={} , clientMutationIdFieldOptions ={} , mutationInputArgOptions ={} } } = this.options;

@@ -262,7 +262,7 @@ const includeClientMutationId = this.options.relayOptions.clientMutationId !== 'omit';

} else {
var ref1;
var _this_options_relayOptions1;
const { name: inputName = `${(0, _utils.capitalize)(fieldName)}Input` , argName: argNameFromOptions = 'input' , inputFields , ...inputOptions } = inputOptionsOrRef;
argName = argNameFromOptions;
inputRef = this.inputType(inputName, {
...(ref1 = this.options.relayOptions) === null || ref1 === void 0 ? void 0 : ref1.defaultMutationInputTypeOptions,
...(_this_options_relayOptions1 = this.options.relayOptions) === null || _this_options_relayOptions1 === void 0 ? void 0 : _this_options_relayOptions1.defaultMutationInputTypeOptions,
...inputOptions,

@@ -281,3 +281,3 @@ fields: (t)=>({

const payloadRef = this.objectRef(payloadName).implement({
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultPayloadTypeOptions,
...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultPayloadTypeOptions,
...paylaodOptions,

@@ -318,3 +318,3 @@ interfaces: interfaces,

schemaBuilderProto.connectionObject = function connectionObject({ type , name: connectionName , edgesNullable: edgesNullableField , nodeNullable , ...connectionOptions }, edgeOptionsOrRef) {
var ref, ref1;
var _this_options_relayOptions, _globalConnectionFieldsMap_get;
(0, _core.verifyRef)(type);

@@ -337,8 +337,8 @@ const { edgesFieldOptions: { nullable: edgesNullable = {

const edgeItemsNullable = typeof edgesNullableOption === 'object' && 'items' in edgesNullableOption ? edgesNullableOption.items : false;
var ref2, ref3, ref4;
var _ref, _ref1, _con_edges_map;
this.objectType(connectionRef, {
...(ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : ref.defaultConnectionTypeOptions,
...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultConnectionTypeOptions,
...connectionOptions,
fields: (t)=>{
var ref, ref1;
var _this_options_relayOptions, _this_options_relayOptions_nodeFieldOptions;
return {

@@ -367,10 +367,10 @@ pageInfo: t.field({

list: edgeListNullable,
items: (ref3 = (ref2 = edgeItemsNullable !== null && edgeItemsNullable !== void 0 ? edgeItemsNullable : nodeNullable) !== null && ref2 !== void 0 ? ref2 : (ref = this.options.relayOptions) === null || ref === void 0 ? void 0 : (ref1 = ref.nodeFieldOptions) === null || ref1 === void 0 ? void 0 : ref1.nullable) !== null && ref3 !== void 0 ? ref3 : false
items: (_ref1 = (_ref = edgeItemsNullable !== null && edgeItemsNullable !== void 0 ? edgeItemsNullable : nodeNullable) !== null && _ref !== void 0 ? _ref : (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : (_this_options_relayOptions_nodeFieldOptions = _this_options_relayOptions.nodeFieldOptions) === null || _this_options_relayOptions_nodeFieldOptions === void 0 ? void 0 : _this_options_relayOptions_nodeFieldOptions.nullable) !== null && _ref1 !== void 0 ? _ref1 : false
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
resolve: (con)=>{
var ref;
return (ref4 = (ref = con.edges) === null || ref === void 0 ? void 0 : ref.map((edge)=>{
var _con_edges;
return (_con_edges_map = (_con_edges = con.edges) === null || _con_edges === void 0 ? void 0 : _con_edges.map((edge)=>{
return edge === null || edge === void 0 ? void 0 : edge.node;
})) !== null && ref4 !== void 0 ? ref4 : [];
})) !== null && _con_edges_map !== void 0 ? _con_edges_map : [];
}

@@ -387,7 +387,7 @@ })

connectionRefs.get(this).push(connectionRef);
(ref1 = globalConnectionFieldsMap.get(this)) === null || ref1 === void 0 ? void 0 : ref1.forEach((fieldFn)=>void fieldFn(connectionRef));
(_globalConnectionFieldsMap_get = globalConnectionFieldsMap.get(this)) === null || _globalConnectionFieldsMap_get === void 0 ? void 0 : _globalConnectionFieldsMap_get.forEach((fieldFn)=>void fieldFn(connectionRef));
return connectionRef;
};
schemaBuilderProto.edgeObject = function edgeObject({ type , name: edgeName , nodeNullable: nodeFieldNullable , ...edgeOptions }) {
var ref;
var _this_options_relayOptions;
(0, _core.verifyRef)(type);

@@ -398,3 +398,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,
...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultEdgeTypeOptions,
...edgeOptions,

@@ -401,0 +401,0 @@ fields: (t)=>{

@@ -24,6 +24,6 @@ "use strict";

const { before , after , first , last } = options.args;
var _defaultSize;
const defaultSize = (_defaultSize = options.defaultSize) !== null && _defaultSize !== void 0 ? _defaultSize : DEFAULT_SIZE;
var _maxSize;
const maxSize = (_maxSize = options.maxSize) !== null && _maxSize !== void 0 ? _maxSize : DEFAULT_MAX_SIZE;
var _options_defaultSize;
const defaultSize = (_options_defaultSize = options.defaultSize) !== null && _options_defaultSize !== void 0 ? _options_defaultSize : DEFAULT_SIZE;
var _options_maxSize;
const maxSize = (_options_maxSize = options.maxSize) !== null && _options_maxSize !== void 0 ? _options_maxSize : DEFAULT_MAX_SIZE;
const beforeOffset = before ? cursorToOffset(before) : Number.POSITIVE_INFINITY;

@@ -50,16 +50,9 @@ const afterOffset = after ? cursorToOffset(after) : 0;

endOffset = Math.min(endOffset, startOffset + Math.min(size, maxSize));
// Get one extra to check for next page
endOffset += 1;
const totalSize = endOffset - startOffset;
const lowerBound = after == null ? 0 : afterOffset;
const hasPreviousPage = last == null ? startOffset > 0 : startOffset > lowerBound;
return {
offset: startOffset,
limit: endOffset - startOffset,
hasPreviousPage,
expectedSize: totalSize - 1,
hasNextPage: (resultSize)=>{
const upperBound = before == null ? startOffset + resultSize : beforeOffset;
return last == null ? resultSize >= totalSize : upperBound > endOffset;
}
limit: totalSize + 1,
hasPreviousPage: startOffset > 0,
expectedSize: totalSize,
hasNextPage: (resultSize)=>resultSize > totalSize
};

@@ -121,6 +114,6 @@ }

const { before , after , first , last } = options.args;
var _defaultSize;
const defaultSize = (_defaultSize = options.defaultSize) !== null && _defaultSize !== void 0 ? _defaultSize : DEFAULT_SIZE;
var _maxSize;
const maxSize = (_maxSize = options.maxSize) !== null && _maxSize !== void 0 ? _maxSize : DEFAULT_MAX_SIZE;
var _options_defaultSize;
const defaultSize = (_options_defaultSize = options.defaultSize) !== null && _options_defaultSize !== void 0 ? _options_defaultSize : DEFAULT_SIZE;
var _options_maxSize;
const maxSize = (_options_maxSize = options.maxSize) !== null && _options_maxSize !== void 0 ? _options_maxSize : DEFAULT_MAX_SIZE;
if (first != null && first < 0) {

@@ -132,4 +125,4 @@ throw new TypeError('Argument "first" must be a non-negative integer');

}
var ref;
const limit = Math.min((ref = first !== null && first !== void 0 ? first : last) !== null && ref !== void 0 ? ref : defaultSize, maxSize) + 1;
var _ref;
const limit = Math.min((_ref = first !== null && first !== void 0 ? first : last) !== null && _ref !== void 0 ? _ref : defaultSize, maxSize) + 1;
const inverted = after ? !!last && !first : !!before && !first || !first && !!last;

@@ -147,3 +140,3 @@ return {

async function resolveCursorConnection(options, resolve) {
var ref, ref1;
var _edges_, _edges_1;
const { before , after , limit , inverted , expectedSize , hasPreviousPage , hasNextPage } = parseCurserArgs(options);

@@ -167,6 +160,6 @@ const nodes = await resolve({

});
var _after, ref2;
const startCursor = edges.length > 0 ? (ref = edges[0]) === null || ref === void 0 ? void 0 : ref.cursor : (ref2 = (_after = options.args.after) !== null && _after !== void 0 ? _after : options.args.before) !== null && ref2 !== void 0 ? ref2 : '';
var _after1, ref3;
const endCursor = edges.length > 0 ? (ref1 = edges[edges.length - 1]) === null || ref1 === void 0 ? void 0 : ref1.cursor : (ref3 = (_after1 = options.args.after) !== null && _after1 !== void 0 ? _after1 : options.args.before) !== null && ref3 !== void 0 ? ref3 : '';
var _options_args_after, _ref;
const startCursor = edges.length > 0 ? (_edges_ = edges[0]) === null || _edges_ === void 0 ? void 0 : _edges_.cursor : (_ref = (_options_args_after = options.args.after) !== null && _options_args_after !== void 0 ? _options_args_after : options.args.before) !== null && _ref !== void 0 ? _ref : '';
var _options_args_after1, _ref1;
const endCursor = edges.length > 0 ? (_edges_1 = edges[edges.length - 1]) === null || _edges_1 === void 0 ? void 0 : _edges_1.cursor : (_ref1 = (_options_args_after1 = options.args.after) !== null && _options_args_after1 !== void 0 ? _options_args_after1 : options.args.before) !== null && _ref1 !== void 0 ? _ref1 : '';
return {

@@ -173,0 +166,0 @@ edges: edges,

@@ -43,4 +43,4 @@ "use strict";

const options = config.pothosOptions;
var _brandLoadedObjects, ref;
const shouldBrandObjects = (ref = (_brandLoadedObjects = options.brandLoadedObjects) !== null && _brandLoadedObjects !== void 0 ? _brandLoadedObjects : builder.options.relayOptions.brandLoadedObjects) !== null && ref !== void 0 ? ref : false;
var _options_brandLoadedObjects, _ref;
const shouldBrandObjects = (_ref = (_options_brandLoadedObjects = options.brandLoadedObjects) !== null && _options_brandLoadedObjects !== void 0 ? _options_brandLoadedObjects : builder.options.relayOptions.brandLoadedObjects) !== null && _ref !== void 0 ? _ref : false;
const resultsForType = await resolveUncachedNodesForType(builder, context, info, ids, typename);

@@ -54,4 +54,4 @@ resultsForType.forEach((val, i)=>{

}));
var _globalID;
return globalIDs.map((globalID)=>globalID == null ? null : (_globalID = results[globalID]) !== null && _globalID !== void 0 ? _globalID : null);
var _results_globalID;
return globalIDs.map((globalID)=>globalID == null ? null : (_results_globalID = results[globalID]) !== null && _results_globalID !== void 0 ? _results_globalID : null);
}

@@ -58,0 +58,0 @@ async function resolveUncachedNodesForType(builder, context, info, ids, type) {

{
"name": "@pothos/plugin-relay",
"version": "3.29.0",
"version": "3.29.1",
"description": "A Pothos plugin for adding relay style connections, nodes, and cursor based pagination to your GraphQL schema",

@@ -43,8 +43,8 @@ "main": "./lib/index.js",

"devDependencies": {
"@pothos/core": "3.23.0",
"@pothos/plugin-complexity": "3.11.7",
"@pothos/test-utils": "1.4.7",
"graphql": "16.6.0",
"graphql-subscriptions": "^2.0.0",
"graphql-tag": "^2.12.6",
"@pothos/core": "3.23.0",
"@pothos/plugin-complexity": "3.11.7",
"@pothos/test-utils": "1.4.7"
"graphql-tag": "^2.12.6"
},

@@ -51,0 +51,0 @@ "gitHead": "9dfe52f1975f41a111e01bf96a20033a914e2acc",

@@ -67,20 +67,10 @@ import { decodeBase64, encodeBase64, MaybePromise, SchemaTypes } from '@pothos/core';

// Get one extra to check for next page
endOffset += 1;
const totalSize = endOffset - startOffset;
const lowerBound = after == null ? 0 : afterOffset;
const hasPreviousPage = last == null ? startOffset > 0 : startOffset > lowerBound;
return {
offset: startOffset,
limit: endOffset - startOffset,
hasPreviousPage,
expectedSize: totalSize - 1,
hasNextPage: (resultSize: number) => {
const upperBound = before == null ? startOffset + resultSize : beforeOffset;
return last == null ? resultSize >= totalSize : upperBound > endOffset;
},
limit: totalSize + 1,
hasPreviousPage: startOffset > 0,
expectedSize: totalSize,
hasNextPage: (resultSize: number) => resultSize > totalSize,
};

@@ -114,3 +104,3 @@ }

cursor: offsetToCursor(offset + index),
node: value as NonNullable<T>,
node: value,
},

@@ -165,3 +155,3 @@ );

cursor: offsetToCursor(offset + index),
node: value as NonNullable<T>,
node: value,
},

@@ -168,0 +158,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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc