Huge News!Announcing our $40M Series B led by Abstract Ventures.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.43.0 to 3.43.1

6

CHANGELOG.md
# Change Log
## 3.43.1
### Patch Changes
- b7954d40: Fix hasPreviousPage in resolveCursorConnection
## 3.43.0

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

12

esm/input-field-builder.js
import { InputFieldBuilder } from '@pothos/core';
const inputFieldBuilder = InputFieldBuilder.prototype;
inputFieldBuilder.globalIDList = function globalIDList({ for: forTypes, ...options } = {}) {
var _ref;
var _this;
var _map;

@@ -11,5 +11,5 @@ return this.idList({

isRelayGlobalID: true,
relayGlobalIDFor: (_map = (_ref = forTypes && (Array.isArray(forTypes) ? forTypes : [
relayGlobalIDFor: (_map = (_this = forTypes && (Array.isArray(forTypes) ? forTypes : [
forTypes
])) === null || _ref === void 0 ? void 0 : _ref.map((type) => ({
])) === null || _this === void 0 ? void 0 : _this.map((type) => ({
typename: this.builder.configStore.getTypeConfig(type).name,

@@ -22,3 +22,3 @@ parseId: "parseId" in type ? type.parseId : undefined

inputFieldBuilder.globalID = function globalID({ for: forTypes, ...options } = {}) {
var _ref;
var _this;
var _map;

@@ -30,5 +30,5 @@ return this.id({

isRelayGlobalID: true,
relayGlobalIDFor: (_map = (_ref = forTypes && (Array.isArray(forTypes) ? forTypes : [
relayGlobalIDFor: (_map = (_this = forTypes && (Array.isArray(forTypes) ? forTypes : [
forTypes
])) === null || _ref === void 0 ? void 0 : _ref.map((type) => ({
])) === null || _this === void 0 ? void 0 : _this.map((type) => ({
typename: this.builder.configStore.getTypeConfig(type).name,

@@ -35,0 +35,0 @@ parseId: "parseId" in type ? type.parseId : undefined

@@ -1,2 +0,2 @@

function _defineProperty(obj, key, value) {
function _define_property(obj, key, value) {
if (key in obj) {

@@ -21,4 +21,4 @@ Object.defineProperty(obj, key, {

super(name);
_defineProperty(this, _relayIDShapeKey, void 0);
_defineProperty(this, "parseId", void 0);
_define_property(this, _relayIDShapeKey, void 0);
_define_property(this, "parseId", void 0);
this.parseId = options.parseId;

@@ -25,0 +25,0 @@ }

@@ -98,5 +98,6 @@ import { defaultTypeResolver } from 'graphql';

if (nodeQueryOptions !== false) {
const resolveNodeFn = nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : nodeQueryOptions.resolve;
var _nodeQueryOptions;
const resolveNodeFn = (_nodeQueryOptions = nodeQueryOptions) === null || _nodeQueryOptions === void 0 ? void 0 : _nodeQueryOptions.resolve;
this.queryField("node", (t) => {
var _nodeQueryOptions_args, _nodeQueryOptions_args1, _nodeQueryOptions_args_id;
var _nodeQueryOptions_args, _nodeQueryOptions, _nodeQueryOptions_args_id, _nodeQueryOptions_args1, _nodeQueryOptions1;
return t.field({

@@ -108,7 +109,7 @@ nullable: true,

id: t.arg.globalID({
...nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : (_nodeQueryOptions_args = nodeQueryOptions.args) === null || _nodeQueryOptions_args === void 0 ? void 0 : _nodeQueryOptions_args.id,
...(_nodeQueryOptions = nodeQueryOptions) === null || _nodeQueryOptions === void 0 ? void 0 : (_nodeQueryOptions_args = _nodeQueryOptions.args) === null || _nodeQueryOptions_args === void 0 ? void 0 : _nodeQueryOptions_args.id,
required: true,
extensions: {
relayGlobalIDAlwaysParse: true,
...nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : (_nodeQueryOptions_args1 = nodeQueryOptions.args) === null || _nodeQueryOptions_args1 === void 0 ? void 0 : (_nodeQueryOptions_args_id = _nodeQueryOptions_args1.id) === null || _nodeQueryOptions_args_id === void 0 ? void 0 : _nodeQueryOptions_args_id.extensions
...(_nodeQueryOptions1 = nodeQueryOptions) === null || _nodeQueryOptions1 === void 0 ? void 0 : (_nodeQueryOptions_args1 = _nodeQueryOptions1.args) === null || _nodeQueryOptions_args1 === void 0 ? void 0 : (_nodeQueryOptions_args_id = _nodeQueryOptions_args1.id) === null || _nodeQueryOptions_args_id === void 0 ? void 0 : _nodeQueryOptions_args_id.extensions
}

@@ -127,5 +128,6 @@ })

if (nodesQueryOptions !== false) {
const resolveNodesFn = nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : nodesQueryOptions.resolve;
var _nodesQueryOptions;
const resolveNodesFn = (_nodesQueryOptions = nodesQueryOptions) === null || _nodesQueryOptions === void 0 ? void 0 : _nodesQueryOptions.resolve;
this.queryField("nodes", (t) => {
var _nodesQueryOptions_args, _nodesQueryOptions_args1, _nodesQueryOptions_args_ids;
var _nodesQueryOptions_args, _nodesQueryOptions, _nodesQueryOptions_args_ids, _nodesQueryOptions_args1, _nodesQueryOptions1;
return t.field({

@@ -142,7 +144,7 @@ nullable: {

ids: t.arg.globalIDList({
...nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : (_nodesQueryOptions_args = nodesQueryOptions.args) === null || _nodesQueryOptions_args === void 0 ? void 0 : _nodesQueryOptions_args.ids,
...(_nodesQueryOptions = nodesQueryOptions) === null || _nodesQueryOptions === void 0 ? void 0 : (_nodesQueryOptions_args = _nodesQueryOptions.args) === null || _nodesQueryOptions_args === void 0 ? void 0 : _nodesQueryOptions_args.ids,
required: true,
extensions: {
relayGlobalIDAlwaysParse: true,
...nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : (_nodesQueryOptions_args1 = nodesQueryOptions.args) === null || _nodesQueryOptions_args1 === void 0 ? void 0 : (_nodesQueryOptions_args_ids = _nodesQueryOptions_args1.ids) === null || _nodesQueryOptions_args_ids === void 0 ? void 0 : _nodesQueryOptions_args_ids.extensions
...(_nodesQueryOptions1 = nodesQueryOptions) === null || _nodesQueryOptions1 === void 0 ? void 0 : (_nodesQueryOptions_args1 = _nodesQueryOptions1.args) === null || _nodesQueryOptions_args1 === void 0 ? void 0 : (_nodesQueryOptions_args_ids = _nodesQueryOptions_args1.ids) === null || _nodesQueryOptions_args_ids === void 0 ? void 0 : _nodesQueryOptions_args_ids.extensions
}

@@ -180,3 +182,4 @@ })

try {
if (proto === null || proto === void 0 ? void 0 : proto.constructor) {
var _proto;
if ((_proto = proto) === null || _proto === void 0 ? void 0 : _proto.constructor) {
const config = this.configStore.getTypeConfig(proto.constructor);

@@ -330,3 +333,3 @@ return config.name === nodeName;

fields: (t) => {
var _this_options_relayOptions, _this_options_relayOptions_nodeFieldOptions;
var _this_options_relayOptions_nodeFieldOptions, _this_options_relayOptions, _connectionFields;
return {

@@ -358,12 +361,12 @@ pageInfo: t.field({

},
resolve: (con) => {
return completeValue(con.edges, (edges) => {
return (_edges_map = edges === null || edges === void 0 ? void 0 : edges.map((e) => {
return e === null || e === void 0 ? void 0 : e.node;
})) !== null && _edges_map !== void 0 ? _edges_map : edgeListNullable ? null : [];
});
}
resolve: (con) => completeValue(con.edges, (edges) => {
var _edges;
return (_edges_map = (_edges = edges) === null || _edges === void 0 ? void 0 : _edges.map((e) => {
var _e;
return (_e = e) === null || _e === void 0 ? void 0 : _e.node;
})) !== null && _edges_map !== void 0 ? _edges_map : edgeListNullable ? null : [];
})
})
} : {},
...connectionFields === null || connectionFields === void 0 ? void 0 : connectionFields(t)
...(_connectionFields = connectionFields) === null || _connectionFields === void 0 ? void 0 : _connectionFields(t)
};

@@ -389,2 +392,3 @@ }

fields: (t) => {
var _edgeFields;
return {

@@ -403,3 +407,3 @@ node: t.field({

}),
...edgeFields === null || edgeFields === void 0 ? void 0 : edgeFields(t)
...(_edgeFields = edgeFields) === null || _edgeFields === void 0 ? void 0 : _edgeFields(t)
};

@@ -406,0 +410,0 @@ }

@@ -114,4 +114,4 @@ import { decodeBase64, encodeBase64, PothosValidationError } from '@pothos/core';

inverted,
hasPreviousPage: (resultSize) => !!after || resultSize >= limit && !first,
hasNextPage: (resultSize) => !!before || !last && resultSize >= limit
hasPreviousPage: (resultSize) => inverted ? resultSize >= limit : !!after,
hasNextPage: (resultSize) => inverted ? !!before : resultSize >= limit
};

@@ -118,0 +118,0 @@ }

@@ -25,3 +25,3 @@ import { PothosValidationError } from '@pothos/core';

if (parseIdsForTypes) {
var _info_schema_getType, _info_schema_getType_extensions;
var _info_schema_getType_extensions, _info_schema_getType;
const parseID = (_info_schema_getType = info.schema.getType(decoded.typename)) === null || _info_schema_getType === void 0 ? void 0 : (_info_schema_getType_extensions = _info_schema_getType.extensions) === null || _info_schema_getType_extensions === void 0 ? void 0 : _info_schema_getType_extensions.pothosParseGlobalID;

@@ -28,0 +28,0 @@ if (parseID) {

@@ -9,3 +9,3 @@ "use strict";

const fieldBuilderProto = _core.RootFieldBuilder.prototype;
fieldBuilderProto.globalIDList = function globalIDList({ resolve , ...options }) {
fieldBuilderProto.globalIDList = function globalIDList({ resolve, ...options }) {
const wrappedResolve = async (parent, args, context, info)=>{

@@ -30,3 +30,3 @@ const result = await resolve(parent, args, context, info);

};
fieldBuilderProto.globalID = function globalID({ resolve , ...options }) {
fieldBuilderProto.globalID = function globalID({ resolve, ...options }) {
const wrappedResolve = async (parent, args, context, info)=>{

@@ -46,3 +46,3 @@ const result = await resolve(parent, args, context, info);

};
fieldBuilderProto.node = function node({ id , ...options }) {
fieldBuilderProto.node = function node({ id, ...options }) {
return this.field({

@@ -67,3 +67,3 @@ ...options,

};
fieldBuilderProto.nodeList = function nodeList({ ids , ...options }) {
fieldBuilderProto.nodeList = function nodeList({ ids, ...options }) {
return this.field({

@@ -93,3 +93,3 @@ ...options,

};
fieldBuilderProto.connection = function connection({ type , edgesNullable , nodeNullable , ...fieldOptions }, connectionOptionsOrRef = {}, edgeOptionsOrRef = {}) {
fieldBuilderProto.connection = function connection({ type, edgesNullable, nodeNullable, ...fieldOptions }, connectionOptionsOrRef = {}, edgeOptionsOrRef = {}) {
var _this_builder_options_relayOptions;

@@ -96,0 +96,0 @@ const connectionRef = connectionOptionsOrRef instanceof _core.ObjectRef ? connectionOptionsOrRef : this.builder.objectRef('Unnamed connection');

@@ -12,4 +12,8 @@ "use strict";

_export(exports, {
default: ()=>_default,
PothosRelayPlugin: ()=>PothosRelayPlugin
default: function() {
return _default;
},
PothosRelayPlugin: function() {
return PothosRelayPlugin;
}
});

@@ -20,15 +24,17 @@ require("./global-types");

require("./schema-builder");
const _core = /*#__PURE__*/ _interopRequireWildcard(require("@pothos/core"));
const _core = /*#__PURE__*/ _interop_require_wildcard(require("@pothos/core"));
const _internal = require("./utils/internal");
_exportStar(require("./node-ref"), exports);
_exportStar(require("./types"), exports);
_exportStar(require("./utils"), exports);
function _exportStar(from, to) {
_export_star(require("./node-ref"), exports);
_export_star(require("./types"), exports);
_export_star(require("./utils"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});

@@ -45,3 +51,3 @@ return from;

}
function _interopRequireWildcard(obj, nodeInterop) {
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {

@@ -48,0 +54,0 @@ return obj;

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

const inputFieldBuilder = _core.InputFieldBuilder.prototype;
inputFieldBuilder.globalIDList = function globalIDList({ for: forTypes , ...options } = {}) {
var _ref;
inputFieldBuilder.globalIDList = function globalIDList({ for: forTypes, ...options } = {}) {
var _this;
var _map;

@@ -16,5 +16,5 @@ return this.idList({

isRelayGlobalID: true,
relayGlobalIDFor: (_map = (_ref = forTypes && (Array.isArray(forTypes) ? forTypes : [
relayGlobalIDFor: (_map = (_this = forTypes && (Array.isArray(forTypes) ? forTypes : [
forTypes
])) === null || _ref === void 0 ? void 0 : _ref.map((type)=>({
])) === null || _this === void 0 ? void 0 : _this.map((type)=>({
typename: this.builder.configStore.getTypeConfig(type).name,

@@ -26,4 +26,4 @@ parseId: 'parseId' in type ? type.parseId : undefined

};
inputFieldBuilder.globalID = function globalID({ for: forTypes , ...options } = {}) {
var _ref;
inputFieldBuilder.globalID = function globalID({ for: forTypes, ...options } = {}) {
var _this;
var _map;

@@ -35,5 +35,5 @@ return this.id({

isRelayGlobalID: true,
relayGlobalIDFor: (_map = (_ref = forTypes && (Array.isArray(forTypes) ? forTypes : [
relayGlobalIDFor: (_map = (_this = forTypes && (Array.isArray(forTypes) ? forTypes : [
forTypes
])) === null || _ref === void 0 ? void 0 : _ref.map((type)=>({
])) === null || _this === void 0 ? void 0 : _this.map((type)=>({
typename: this.builder.configStore.getTypeConfig(type).name,

@@ -47,3 +47,3 @@ parseId: 'parseId' in type ? type.parseId : undefined

const { // TODO(breaking) make this default match other cursor fields
cursorType ='ID' , beforeArgOptions ={} , afterArgOptions ={} , firstArgOptions ={} , lastArgOptions ={} } = this.builder.options.relayOptions;
cursorType = 'ID', beforeArgOptions = {}, afterArgOptions = {}, firstArgOptions = {}, lastArgOptions = {} } = this.builder.options.relayOptions;
return {

@@ -50,0 +50,0 @@ before: this.field({

@@ -12,7 +12,11 @@ "use strict";

_export(exports, {
relayIDShapeKey: ()=>relayIDShapeKey,
NodeRef: ()=>NodeRef
relayIDShapeKey: function() {
return relayIDShapeKey;
},
NodeRef: function() {
return NodeRef;
}
});
const _core = require("@pothos/core");
function _defineProperty(obj, key, value) {
function _define_property(obj, key, value) {
if (key in obj) {

@@ -35,4 +39,4 @@ Object.defineProperty(obj, key, {

super(name);
_defineProperty(this, _relayIDShapeKey, void 0);
_defineProperty(this, "parseId", void 0);
_define_property(this, _relayIDShapeKey, void 0);
_define_property(this, "parseId", void 0);
this.parseId = options.parseId;

@@ -39,0 +43,0 @@ }

@@ -12,8 +12,12 @@ "use strict";

_export(exports, {
connectionRefs: ()=>connectionRefs,
globalConnectionFieldsMap: ()=>globalConnectionFieldsMap
connectionRefs: function() {
return connectionRefs;
},
globalConnectionFieldsMap: function() {
return globalConnectionFieldsMap;
}
});
const _graphql = require("graphql");
const _core = /*#__PURE__*/ _interopRequireWildcard(require("@pothos/core"));
const _nodeRef = require("./node-ref");
const _core = /*#__PURE__*/ _interop_require_wildcard(require("@pothos/core"));
const _noderef = require("./node-ref");
const _utils = require("./utils");

@@ -28,3 +32,3 @@ function _getRequireWildcardCache(nodeInterop) {

}
function _interopRequireWildcard(obj, nodeInterop) {
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {

@@ -71,3 +75,3 @@ return obj;

pageInfoRefMap.set(this, ref);
const { cursorType ='String' , hasNextPageFieldOptions ={} , hasPreviousPageFieldOptions ={} , startCursorFieldOptions ={} , endCursorFieldOptions ={} } = this.options.relayOptions;
const { cursorType = 'String', hasNextPageFieldOptions = {}, hasPreviousPageFieldOptions = {}, startCursorFieldOptions = {}, endCursorFieldOptions = {} } = this.options.relayOptions;
ref.implement({

@@ -153,5 +157,6 @@ ...this.options.relayOptions.pageInfoTypeOptions,

if (nodeQueryOptions !== false) {
const resolveNodeFn = nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : nodeQueryOptions.resolve;
var _nodeQueryOptions;
const resolveNodeFn = (_nodeQueryOptions = nodeQueryOptions) === null || _nodeQueryOptions === void 0 ? void 0 : _nodeQueryOptions.resolve;
this.queryField('node', (t)=>{
var _nodeQueryOptions_args, _nodeQueryOptions_args1, _nodeQueryOptions_args_id;
var _nodeQueryOptions_args, _nodeQueryOptions, _nodeQueryOptions_args_id, _nodeQueryOptions_args1, _nodeQueryOptions1;
return t.field({

@@ -163,7 +168,7 @@ nullable: true,

id: t.arg.globalID({
...nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : (_nodeQueryOptions_args = nodeQueryOptions.args) === null || _nodeQueryOptions_args === void 0 ? void 0 : _nodeQueryOptions_args.id,
...(_nodeQueryOptions = nodeQueryOptions) === null || _nodeQueryOptions === void 0 ? void 0 : (_nodeQueryOptions_args = _nodeQueryOptions.args) === null || _nodeQueryOptions_args === void 0 ? void 0 : _nodeQueryOptions_args.id,
required: true,
extensions: {
relayGlobalIDAlwaysParse: true,
...nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : (_nodeQueryOptions_args1 = nodeQueryOptions.args) === null || _nodeQueryOptions_args1 === void 0 ? void 0 : (_nodeQueryOptions_args_id = _nodeQueryOptions_args1.id) === null || _nodeQueryOptions_args_id === void 0 ? void 0 : _nodeQueryOptions_args_id.extensions
...(_nodeQueryOptions1 = nodeQueryOptions) === null || _nodeQueryOptions1 === void 0 ? void 0 : (_nodeQueryOptions_args1 = _nodeQueryOptions1.args) === null || _nodeQueryOptions_args1 === void 0 ? void 0 : (_nodeQueryOptions_args_id = _nodeQueryOptions_args1.id) === null || _nodeQueryOptions_args_id === void 0 ? void 0 : _nodeQueryOptions_args_id.extensions
}

@@ -182,5 +187,6 @@ })

if (nodesQueryOptions !== false) {
const resolveNodesFn = nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : nodesQueryOptions.resolve;
var _nodesQueryOptions;
const resolveNodesFn = (_nodesQueryOptions = nodesQueryOptions) === null || _nodesQueryOptions === void 0 ? void 0 : _nodesQueryOptions.resolve;
this.queryField('nodes', (t)=>{
var _nodesQueryOptions_args, _nodesQueryOptions_args1, _nodesQueryOptions_args_ids;
var _nodesQueryOptions_args, _nodesQueryOptions, _nodesQueryOptions_args_ids, _nodesQueryOptions_args1, _nodesQueryOptions1;
return t.field({

@@ -197,7 +203,7 @@ nullable: {

ids: t.arg.globalIDList({
...nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : (_nodesQueryOptions_args = nodesQueryOptions.args) === null || _nodesQueryOptions_args === void 0 ? void 0 : _nodesQueryOptions_args.ids,
...(_nodesQueryOptions = nodesQueryOptions) === null || _nodesQueryOptions === void 0 ? void 0 : (_nodesQueryOptions_args = _nodesQueryOptions.args) === null || _nodesQueryOptions_args === void 0 ? void 0 : _nodesQueryOptions_args.ids,
required: true,
extensions: {
relayGlobalIDAlwaysParse: true,
...nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : (_nodesQueryOptions_args1 = nodesQueryOptions.args) === null || _nodesQueryOptions_args1 === void 0 ? void 0 : (_nodesQueryOptions_args_ids = _nodesQueryOptions_args1.ids) === null || _nodesQueryOptions_args_ids === void 0 ? void 0 : _nodesQueryOptions_args_ids.extensions
...(_nodesQueryOptions1 = nodesQueryOptions) === null || _nodesQueryOptions1 === void 0 ? void 0 : (_nodesQueryOptions_args1 = _nodesQueryOptions1.args) === null || _nodesQueryOptions_args1 === void 0 ? void 0 : (_nodesQueryOptions_args_ids = _nodesQueryOptions_args1.ids) === null || _nodesQueryOptions_args_ids === void 0 ? void 0 : _nodesQueryOptions_args_ids.extensions
}

@@ -212,3 +218,3 @@ })

};
schemaBuilderProto.node = function node(param, { interfaces , extensions , id , ...options }, fields) {
schemaBuilderProto.node = function node(param, { interfaces, extensions, id, ...options }, fields) {
(0, _core.verifyRef)(param);

@@ -236,3 +242,4 @@ const interfacesWithNode = ()=>[

try {
if (proto === null || proto === void 0 ? void 0 : proto.constructor) {
var _proto;
if ((_proto = proto) === null || _proto === void 0 ? void 0 : _proto.constructor) {
const config = this.configStore.getTypeConfig(proto.constructor);

@@ -263,3 +270,3 @@ return config.name === nodeName;

});
const nodeRef = new _nodeRef.NodeRef(ref.name, {
const nodeRef = new _noderef.NodeRef(ref.name, {
parseId: id.parse

@@ -299,5 +306,5 @@ });

const mutationIdCache = (0, _core.createContextCache)(()=>new Map());
schemaBuilderProto.relayMutationField = function relayMutationField(fieldName, inputOptionsOrRef, { resolve , ...fieldOptions }, { name: payloadName = `${(0, _utils.capitalize)(fieldName)}Payload` , outputFields , interfaces , ...paylaodOptions }) {
schemaBuilderProto.relayMutationField = function relayMutationField(fieldName, inputOptionsOrRef, { resolve, ...fieldOptions }, { name: payloadName = `${(0, _utils.capitalize)(fieldName)}Payload`, outputFields, interfaces, ...paylaodOptions }) {
var _this_options_relayOptions;
const { relayOptions: { clientMutationIdInputOptions ={} , clientMutationIdFieldOptions ={} , mutationInputArgOptions ={} } } = this.options;
const { relayOptions: { clientMutationIdInputOptions = {}, clientMutationIdFieldOptions = {}, mutationInputArgOptions = {} } } = this.options;
const includeClientMutationId = this.options.relayOptions.clientMutationId !== 'omit';

@@ -310,3 +317,3 @@ let inputRef;

var _this_options_relayOptions1;
const { name: inputName = `${(0, _utils.capitalize)(fieldName)}Input` , argName: argNameFromOptions = 'input' , inputFields , ...inputOptions } = inputOptionsOrRef;
const { name: inputName = `${(0, _utils.capitalize)(fieldName)}Input`, argName: argNameFromOptions = 'input', inputFields, ...inputOptions } = inputOptionsOrRef;
argName = argNameFromOptions;

@@ -363,3 +370,3 @@ inputRef = this.inputType(inputName, {

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

@@ -370,3 +377,3 @@ (0, _core.verifyRef)(type);

list: false
} , ...edgesFieldOptions } = {} , pageInfoFieldOptions ={} } = this.options.relayOptions;
}, ...edgesFieldOptions } = {}, pageInfoFieldOptions = {} } = this.options.relayOptions;
const connectionRef = this.objectRef(connectionName);

@@ -380,3 +387,3 @@ const edgeRef = edgeOptionsOrRef instanceof _core.ObjectRef ? edgeOptionsOrRef : this.edgeObject({

const connectionFields = connectionOptions.fields;
const { nodesOnConnection } = this.options.relayOptions;
const { nodesOnConnection } = this.options.relayOptions;
const edgesNullableOption = edgesNullableField !== null && edgesNullableField !== void 0 ? edgesNullableField : edgesNullable;

@@ -390,3 +397,3 @@ const edgeListNullable = typeof edgesNullableOption === 'object' ? edgesNullableOption.list : !!edgesNullableOption;

fields: (t)=>{
var _this_options_relayOptions, _this_options_relayOptions_nodeFieldOptions;
var _this_options_relayOptions_nodeFieldOptions, _this_options_relayOptions, _connectionFields;
return {

@@ -418,12 +425,12 @@ pageInfo: t.field({

},
resolve: (con)=>{
return (0, _core.completeValue)(con.edges, (edges)=>{
return (_edges_map = edges === null || edges === void 0 ? void 0 : edges.map((e)=>{
return e === null || e === void 0 ? void 0 : e.node;
resolve: (con)=>(0, _core.completeValue)(con.edges, (edges)=>{
var _edges;
return (_edges_map = (_edges = edges) === null || _edges === void 0 ? void 0 : _edges.map((e)=>{
var _e;
return (_e = e) === null || _e === void 0 ? void 0 : _e.node;
})) !== null && _edges_map !== void 0 ? _edges_map : edgeListNullable ? null : [];
});
}
})
})
} : {},
...connectionFields === null || connectionFields === void 0 ? void 0 : connectionFields(t)
...(_connectionFields = connectionFields) === null || _connectionFields === void 0 ? void 0 : _connectionFields(t)
};

@@ -439,6 +446,6 @@ }

};
schemaBuilderProto.edgeObject = function edgeObject({ type , name: edgeName , nodeNullable: nodeFieldNullable , nodeField , ...edgeOptions }) {
schemaBuilderProto.edgeObject = function edgeObject({ type, name: edgeName, nodeNullable: nodeFieldNullable, nodeField, ...edgeOptions }) {
var _this_options_relayOptions;
(0, _core.verifyRef)(type);
const { cursorType ='String' , cursorFieldOptions ={} , nodeFieldOptions: { nullable: nodeNullable = false , ...nodeFieldOptions } = {} } = this.options.relayOptions;
const { cursorType = 'String', cursorFieldOptions = {}, nodeFieldOptions: { nullable: nodeNullable = false, ...nodeFieldOptions } = {} } = this.options.relayOptions;
const edgeRef = this.objectRef(edgeName);

@@ -450,2 +457,3 @@ const edgeFields = edgeOptions.fields;

fields: (t)=>{
var _edgeFields;
return {

@@ -464,3 +472,3 @@ node: t.field({

}),
...edgeFields === null || edgeFields === void 0 ? void 0 : edgeFields(t)
...(_edgeFields = edgeFields) === null || _edgeFields === void 0 ? void 0 : _edgeFields(t)
};

@@ -467,0 +475,0 @@ }

@@ -12,8 +12,20 @@ "use strict";

_export(exports, {
offsetForArgs: ()=>offsetForArgs,
resolveOffsetConnection: ()=>resolveOffsetConnection,
cursorToOffset: ()=>cursorToOffset,
offsetToCursor: ()=>offsetToCursor,
resolveArrayConnection: ()=>resolveArrayConnection,
resolveCursorConnection: ()=>resolveCursorConnection
offsetForArgs: function() {
return offsetForArgs;
},
resolveOffsetConnection: function() {
return resolveOffsetConnection;
},
cursorToOffset: function() {
return cursorToOffset;
},
offsetToCursor: function() {
return offsetToCursor;
},
resolveArrayConnection: function() {
return resolveArrayConnection;
},
resolveCursorConnection: function() {
return resolveCursorConnection;
}
});

@@ -25,3 +37,3 @@ const _core = require("@pothos/core");

function offsetForArgs(options) {
const { before , after , first , last } = options.args;
const { before, after, first, last } = options.args;
var _options_defaultSize;

@@ -62,3 +74,3 @@ const defaultSize = (_options_defaultSize = options.defaultSize) !== null && _options_defaultSize !== void 0 ? _options_defaultSize : DEFAULT_SIZE;

async function resolveOffsetConnection(options, resolve) {
const { limit , offset , expectedSize , hasPreviousPage , hasNextPage } = offsetForArgs(options);
const { limit, offset, expectedSize, hasPreviousPage, hasNextPage } = offsetForArgs(options);
const nodes = await resolve({

@@ -97,3 +109,3 @@ offset,

function resolveArrayConnection(options, array) {
const { limit , offset , expectedSize , hasPreviousPage , hasNextPage } = offsetForArgs(options);
const { limit, offset, expectedSize, hasPreviousPage, hasNextPage } = offsetForArgs(options);
const nodes = array.slice(offset, offset + limit);

@@ -116,3 +128,3 @@ const edges = nodes.map((value, index)=>value == null ? null : {

function parseCurserArgs(options) {
const { before , after , first , last } = options.args;
const { before, after, first, last } = options.args;
var _options_defaultSize;

@@ -137,4 +149,4 @@ const defaultSize = (_options_defaultSize = options.defaultSize) !== null && _options_defaultSize !== void 0 ? _options_defaultSize : DEFAULT_SIZE;

inverted,
hasPreviousPage: (resultSize)=>!!after || resultSize >= limit && !first,
hasNextPage: (resultSize)=>!!before || !last && resultSize >= limit
hasPreviousPage: (resultSize)=>inverted ? resultSize >= limit : !!after,
hasNextPage: (resultSize)=>inverted ? !!before : resultSize >= limit
};

@@ -144,3 +156,3 @@ }

var _edges_, _edges_1;
const { before , after , limit , inverted , expectedSize , hasPreviousPage , hasNextPage } = parseCurserArgs(options);
const { before, after, limit, inverted, expectedSize, hasPreviousPage, hasNextPage } = parseCurserArgs(options);
const nodes = await resolve({

@@ -147,0 +159,0 @@ before,

@@ -12,4 +12,8 @@ "use strict";

_export(exports, {
encodeGlobalID: ()=>encodeGlobalID,
decodeGlobalID: ()=>decodeGlobalID
encodeGlobalID: function() {
return encodeGlobalID;
},
decodeGlobalID: function() {
return decodeGlobalID;
}
});

@@ -16,0 +20,0 @@ const _core = require("@pothos/core");

@@ -7,15 +7,19 @@ "use strict";

enumerable: true,
get: ()=>capitalize
get: function() {
return capitalize;
}
});
_exportStar(require("./connections"), exports);
_exportStar(require("./global-ids"), exports);
_exportStar(require("./resolve-nodes"), exports);
function _exportStar(from, to) {
_export_star(require("./connections"), exports);
_export_star(require("./global-ids"), exports);
_export_star(require("./resolve-nodes"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});

@@ -22,0 +26,0 @@ return from;

@@ -12,7 +12,11 @@ "use strict";

_export(exports, {
internalEncodeGlobalID: ()=>internalEncodeGlobalID,
internalDecodeGlobalID: ()=>internalDecodeGlobalID
internalEncodeGlobalID: function() {
return internalEncodeGlobalID;
},
internalDecodeGlobalID: function() {
return internalDecodeGlobalID;
}
});
const _core = require("@pothos/core");
const _globalIds = require("./global-ids");
const _globalids = require("./global-ids");
function internalEncodeGlobalID(builder, typename, id, ctx) {

@@ -22,10 +26,10 @@ if (builder.options.relayOptions.encodeGlobalID) {

}
return (0, _globalIds.encodeGlobalID)(typename, id);
return (0, _globalids.encodeGlobalID)(typename, id);
}
function internalDecodeGlobalID(builder, globalID, ctx, info, parseIdsForTypes) {
const decoded = builder.options.relayOptions.decodeGlobalID ? builder.options.relayOptions.decodeGlobalID(globalID, ctx) : (0, _globalIds.decodeGlobalID)(globalID);
const decoded = builder.options.relayOptions.decodeGlobalID ? builder.options.relayOptions.decodeGlobalID(globalID, ctx) : (0, _globalids.decodeGlobalID)(globalID);
if (Array.isArray(parseIdsForTypes)) {
const entry = parseIdsForTypes.find(({ typename })=>typename === decoded.typename);
const entry = parseIdsForTypes.find(({ typename })=>typename === decoded.typename);
if (!entry) {
throw new _core.PothosValidationError(`ID: ${globalID} is not of type: ${parseIdsForTypes.map(({ typename })=>typename).join(', ')}`);
throw new _core.PothosValidationError(`ID: ${globalID} is not of type: ${parseIdsForTypes.map(({ typename })=>typename).join(', ')}`);
}

@@ -41,3 +45,3 @@ if (entry.parseId) {

if (parseIdsForTypes) {
var _info_schema_getType, _info_schema_getType_extensions;
var _info_schema_getType_extensions, _info_schema_getType;
const parseID = (_info_schema_getType = info.schema.getType(decoded.typename)) === null || _info_schema_getType === void 0 ? void 0 : (_info_schema_getType_extensions = _info_schema_getType.extensions) === null || _info_schema_getType_extensions === void 0 ? void 0 : _info_schema_getType_extensions.pothosParseGlobalID;

@@ -44,0 +48,0 @@ if (parseID) {

@@ -12,4 +12,8 @@ "use strict";

_export(exports, {
resolveNodes: ()=>resolveNodes,
resolveUncachedNodesForType: ()=>resolveUncachedNodesForType
resolveNodes: function() {
return resolveNodes;
},
resolveUncachedNodesForType: function() {
return resolveUncachedNodesForType;
}
});

@@ -26,3 +30,3 @@ const _core = require("@pothos/core");

}
const { id , typename } = globalID;
const { id, typename } = globalID;
const cacheKey = `${typename}:${id}`;

@@ -29,0 +33,0 @@ if (requestCache.has(cacheKey)) {

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

@@ -45,7 +45,7 @@ "main": "./lib/index.js",

"devDependencies": {
"graphql": "16.6.0",
"graphql": "16.7.1",
"graphql-subscriptions": "^2.0.0",
"graphql-tag": "^2.12.6",
"@pothos/core": "3.30.0",
"@pothos/plugin-complexity": "3.12.1",
"@pothos/core": "3.33.0",
"@pothos/plugin-complexity": "3.13.0",
"@pothos/test-utils": "1.4.8"

@@ -52,0 +52,0 @@ },

@@ -217,4 +217,4 @@ import {

inverted,
hasPreviousPage: (resultSize: number) => !!after || (resultSize >= limit && !first),
hasNextPage: (resultSize: number) => !!before || (!last && resultSize >= limit),
hasPreviousPage: (resultSize: number) => (inverted ? resultSize >= limit : !!after),
hasNextPage: (resultSize: number) => (inverted ? !!before : resultSize >= limit),
};

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

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