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.22.0 to 3.23.0

6

CHANGELOG.md
# Change Log
## 3.23.0
### Minor Changes
- c9b02338: Support context when using custom gloablID encoding or decoding
## 3.22.0

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

4

dts/types.d.ts

@@ -42,4 +42,4 @@ import { GraphQLResolveInfo } from 'graphql';

lastArgOptions: Omit<PothosSchemaTypes.InputObjectFieldOptions<Types, 'Int', boolean>, 'required' | 'type'>;
encodeGlobalID?: (typename: string, id: bigint | number | string) => string;
decodeGlobalID?: (globalID: string) => {
encodeGlobalID?: (typename: string, id: bigint | number | string, ctx: Types['Context']) => string;
decodeGlobalID?: (globalID: string, ctx: Types['Context']) => {
typename: string;

@@ -46,0 +46,0 @@ id: string;

import { SchemaTypes } from '@pothos/core';
export declare function internalEncodeGlobalID<Types extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<Types>, typename: string, id: bigint | number | string): string;
export declare function internalDecodeGlobalID<Types extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<Types>, globalID: string): {
export declare function internalEncodeGlobalID<Types extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<Types>, typename: string, id: bigint | number | string, ctx: object): string;
export declare function internalDecodeGlobalID<Types extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<Types>, globalID: string, ctx: object): {
typename: string;

@@ -5,0 +5,0 @@ id: string;

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

if (Array.isArray(result)) {
return (await Promise.all(result)).map((item) => item == null || typeof item === "string" ? item : internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id)));
return (await Promise.all(result)).map((item) => item == null || typeof item === "string" ? item : internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id), context));
}

@@ -33,3 +33,3 @@ return null;

const item = result;
return internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id));
return internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id), context);
};

@@ -52,3 +52,3 @@ return this.field({

}
const globalID = typeof rawID === "string" ? rawID : internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(rawID.type).name, String(rawID.id));
const globalID = typeof rawID === "string" ? rawID : internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(rawID.type).name, String(rawID.id), context);
return (await resolveNodes(this.builder, context, info, [

@@ -77,3 +77,3 @@ globalID

const rawIds = await Promise.all(rawIDList);
const globalIds = rawIds.map((id) => !id || typeof id === "string" ? id : internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(id.type).name, String(id.id)));
const globalIds = rawIds.map((id) => !id || typeof id === "string" ? id : internalEncodeGlobalID(this.builder, this.builder.configStore.getTypeConfig(id.type).name, String(id.id), context));
return resolveNodes(this.builder, context, info, globalIds);

@@ -80,0 +80,0 @@ }

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

}
const argMapper = createInputValueMapper(argMappings, (globalID) => internalDecodeGlobalID(this.builder, String(globalID)));
return (parent, args, context, info) => resolver(parent, argMapper(args), context, info);
const argMapper = createInputValueMapper(argMappings, (globalID, mappings, ctx) => internalDecodeGlobalID(this.builder, String(globalID), ctx));
return (parent, args, context, info) => resolver(parent, argMapper(args, undefined, context), context, info);
}

@@ -38,4 +38,4 @@ wrapSubscribe(subscribe, fieldConfig) {

}
const argMapper = createInputValueMapper(argMappings, (globalID) => internalDecodeGlobalID(this.builder, String(globalID)));
return (parent, args, context, info) => subscribe(parent, argMapper(args), context, info);
const argMapper = createInputValueMapper(argMappings, (globalID, mappings, ctx) => internalDecodeGlobalID(this.builder, String(globalID), ctx));
return (parent, args, context, info) => subscribe(parent, argMapper(args, undefined, context), context, info);
}

@@ -42,0 +42,0 @@ }

import { decodeGlobalID, encodeGlobalID } from './global-ids.js';
export function internalEncodeGlobalID(builder, typename, id) {
export function internalEncodeGlobalID(builder, typename, id, ctx) {
if (builder.options.relayOptions.encodeGlobalID) {
return builder.options.relayOptions.encodeGlobalID(typename, id);
return builder.options.relayOptions.encodeGlobalID(typename, id, ctx);
}
return encodeGlobalID(typename, id);
}
export function internalDecodeGlobalID(builder, globalID) {
export function internalDecodeGlobalID(builder, globalID, ctx) {
if (builder.options.relayOptions.decodeGlobalID) {
return builder.options.relayOptions.decodeGlobalID(globalID);
return builder.options.relayOptions.decodeGlobalID(globalID, ctx);
}

@@ -12,0 +12,0 @@ return decodeGlobalID(globalID);

@@ -16,3 +16,3 @@ import { brandWithType, createContextCache } from '@pothos/core';

}
const { id, typename } = internalDecodeGlobalID(builder, globalID);
const { id, typename } = internalDecodeGlobalID(builder, globalID, context);
idsByType[typename] = idsByType[typename] || new Map();

@@ -50,3 +50,3 @@ idsByType[typename].set(id, globalID);

return Promise.all(ids.map((id, i) => {
const globalID = internalEncodeGlobalID(builder, config.name, id);
const globalID = internalEncodeGlobalID(builder, config.name, id, context);
const entryPromise = loadManyPromise.then((results) => results[i]).then((result) => {

@@ -62,3 +62,3 @@ requestCache.set(globalID, result);

return Promise.all(ids.map((id) => {
const globalID = internalEncodeGlobalID(builder, config.name, id);
const globalID = internalEncodeGlobalID(builder, config.name, id, context);
const entryPromise = Promise.resolve(options.loadOne(id, context)).then((result) => {

@@ -65,0 +65,0 @@ requestCache.set(globalID, result);

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

if (Array.isArray(result)) {
return (await Promise.all(result)).map((item)=>item == null || typeof item === 'string' ? item : (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id)));
return (await Promise.all(result)).map((item)=>item == null || typeof item === 'string' ? item : (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id), context));
}

@@ -37,3 +37,3 @@ return null;

const item = result;
return (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id));
return (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(item.type).name, String(item.id), context);
};

@@ -56,3 +56,3 @@ return this.field({

}
const globalID = typeof rawID === 'string' ? rawID : (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(rawID.type).name, String(rawID.id));
const globalID = typeof rawID === 'string' ? rawID : (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(rawID.type).name, String(rawID.id), context);
return (await (0, _utils.resolveNodes)(this.builder, context, info, [

@@ -81,3 +81,3 @@ globalID

const rawIds = await Promise.all(rawIDList);
const globalIds = rawIds.map((id)=>!id || typeof id === 'string' ? id : (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(id.type).name, String(id.id)));
const globalIds = rawIds.map((id)=>!id || typeof id === 'string' ? id : (0, _internal.internalEncodeGlobalID)(this.builder, this.builder.configStore.getTypeConfig(id.type).name, String(id.id), context));
return (0, _utils.resolveNodes)(this.builder, context, info, globalIds);

@@ -84,0 +84,0 @@ }

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

}
const argMapper = (0, _core.createInputValueMapper)(argMappings, (globalID)=>(0, _internal.internalDecodeGlobalID)(this.builder, String(globalID)));
return (parent, args, context, info)=>resolver(parent, argMapper(args), context, info);
const argMapper = (0, _core.createInputValueMapper)(argMappings, (globalID, mappings, ctx)=>(0, _internal.internalDecodeGlobalID)(this.builder, String(globalID), ctx));
return (parent, args, context, info)=>resolver(parent, argMapper(args, undefined, context), context, info);
}

@@ -102,4 +102,4 @@ wrapSubscribe(subscribe, fieldConfig) {

}
const argMapper = (0, _core.createInputValueMapper)(argMappings, (globalID)=>(0, _internal.internalDecodeGlobalID)(this.builder, String(globalID)));
return (parent, args, context, info)=>subscribe(parent, argMapper(args), context, info);
const argMapper = (0, _core.createInputValueMapper)(argMappings, (globalID, mappings, ctx)=>(0, _internal.internalDecodeGlobalID)(this.builder, String(globalID), ctx));
return (parent, args, context, info)=>subscribe(parent, argMapper(args, undefined, context), context, info);
}

@@ -106,0 +106,0 @@ }

@@ -16,11 +16,11 @@ "use strict";

const _globalIds = require("./global-ids");
function internalEncodeGlobalID(builder, typename, id) {
function internalEncodeGlobalID(builder, typename, id, ctx) {
if (builder.options.relayOptions.encodeGlobalID) {
return builder.options.relayOptions.encodeGlobalID(typename, id);
return builder.options.relayOptions.encodeGlobalID(typename, id, ctx);
}
return (0, _globalIds.encodeGlobalID)(typename, id);
}
function internalDecodeGlobalID(builder, globalID) {
function internalDecodeGlobalID(builder, globalID, ctx) {
if (builder.options.relayOptions.decodeGlobalID) {
return builder.options.relayOptions.decodeGlobalID(globalID);
return builder.options.relayOptions.decodeGlobalID(globalID, ctx);
}

@@ -27,0 +27,0 @@ return (0, _globalIds.decodeGlobalID)(globalID);

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

}
const { id , typename } = (0, _internal.internalDecodeGlobalID)(builder, globalID);
const { id , typename } = (0, _internal.internalDecodeGlobalID)(builder, globalID, context);
idsByType[typename] = idsByType[typename] || new Map();

@@ -64,3 +64,3 @@ idsByType[typename].set(id, globalID);

return Promise.all(ids.map((id, i)=>{
const globalID = (0, _internal.internalEncodeGlobalID)(builder, config.name, id);
const globalID = (0, _internal.internalEncodeGlobalID)(builder, config.name, id, context);
const entryPromise = loadManyPromise.then((results)=>results[i]).then((result)=>{

@@ -76,3 +76,3 @@ requestCache.set(globalID, result);

return Promise.all(ids.map((id)=>{
const globalID = (0, _internal.internalEncodeGlobalID)(builder, config.name, id);
const globalID = (0, _internal.internalEncodeGlobalID)(builder, config.name, id, context);
const entryPromise = Promise.resolve(options.loadOne(id, context)).then((result)=>{

@@ -79,0 +79,0 @@ requestCache.set(globalID, result);

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

@@ -39,3 +39,3 @@ "main": "./lib/index.js",

"devDependencies": {
"@pothos/core": "3.18.0",
"@pothos/core": "3.19.0",
"@pothos/plugin-complexity": "3.6.1",

@@ -42,0 +42,0 @@ "@pothos/test-utils": "1.3.0",

@@ -59,2 +59,3 @@ import { GraphQLResolveInfo } from 'graphql';

String(item.id),
context,
),

@@ -100,2 +101,3 @@ );

String(item.id),
context,
);

@@ -134,2 +136,3 @@ };

String(rawID.id),
context,
);

@@ -173,2 +176,3 @@

String(id.id),
context,
),

@@ -175,0 +179,0 @@ );

@@ -39,7 +39,10 @@ import './global-types';

const argMapper = createInputValueMapper(argMappings, (globalID) =>
internalDecodeGlobalID(this.builder, String(globalID)),
const argMapper = createInputValueMapper(
argMappings,
(globalID, mappings, ctx: Types['Context']) =>
internalDecodeGlobalID(this.builder, String(globalID), ctx),
);
return (parent, args, context, info) => resolver(parent, argMapper(args), context, info);
return (parent, args, context, info) =>
resolver(parent, argMapper(args, undefined, context), context, info);
}

@@ -63,7 +66,10 @@

const argMapper = createInputValueMapper(argMappings, (globalID) =>
internalDecodeGlobalID(this.builder, String(globalID)),
const argMapper = createInputValueMapper(
argMappings,
(globalID, mappings, ctx: Types['Context']) =>
internalDecodeGlobalID(this.builder, String(globalID), ctx),
);
return (parent, args, context, info) => subscribe(parent, argMapper(args), context, info);
return (parent, args, context, info) =>
subscribe(parent, argMapper(args, undefined, context), context, info);
}

@@ -70,0 +76,0 @@ }

@@ -182,4 +182,11 @@ import { GraphQLResolveInfo } from 'graphql';

>;
encodeGlobalID?: (typename: string, id: bigint | number | string) => string;
decodeGlobalID?: (globalID: string) => {
encodeGlobalID?: (
typename: string,
id: bigint | number | string,
ctx: Types['Context'],
) => string;
decodeGlobalID?: (
globalID: string,
ctx: Types['Context'],
) => {
typename: string;

@@ -186,0 +193,0 @@ id: string;

@@ -8,5 +8,6 @@ import { SchemaTypes } from '@pothos/core';

id: bigint | number | string,
ctx: object,
) {
if (builder.options.relayOptions.encodeGlobalID) {
return builder.options.relayOptions.encodeGlobalID(typename, id);
return builder.options.relayOptions.encodeGlobalID(typename, id, ctx);
}

@@ -20,5 +21,6 @@

globalID: string,
ctx: object,
) {
if (builder.options.relayOptions.decodeGlobalID) {
return builder.options.relayOptions.decodeGlobalID(globalID);
return builder.options.relayOptions.decodeGlobalID(globalID, ctx);
}

@@ -25,0 +27,0 @@

@@ -35,3 +35,3 @@ import { GraphQLResolveInfo } from 'graphql';

const { id, typename } = internalDecodeGlobalID(builder, globalID);
const { id, typename } = internalDecodeGlobalID(builder, globalID, context);

@@ -89,3 +89,3 @@ idsByType[typename] = idsByType[typename] || new Map();

ids.map((id, i) => {
const globalID = internalEncodeGlobalID(builder, config.name, id);
const globalID = internalEncodeGlobalID(builder, config.name, id, context);
const entryPromise = loadManyPromise

@@ -109,3 +109,3 @@ .then((results: unknown[]) => results[i])

ids.map((id) => {
const globalID = internalEncodeGlobalID(builder, config.name, id);
const globalID = internalEncodeGlobalID(builder, config.name, id, context);
const entryPromise = Promise.resolve(options.loadOne!(id, context)).then(

@@ -112,0 +112,0 @@ (result: unknown) => {

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