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.45.1 to 3.46.0

6

CHANGELOG.md
# Change Log
## 3.46.0
### Minor Changes
- 2a1843d: Allow inputOptions on relayMutationField to be set to null to remove input argument
## 3.45.1

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

2

dts/global-types.d.ts

@@ -31,3 +31,3 @@ import { FieldKind, FieldNullability, FieldOptionsFromKind, FieldRef, FieldRequiredness, InputFieldMap, InputFieldRef, InputFieldsFromShape, InputShapeFromFields, InputShapeFromTypeParam, inputShapeKey, InterfaceParam, NormalizeArgs, ObjectFieldsShape, ObjectFieldThunk, ObjectParam, OutputShape, OutputType, ParentShape, Resolver, SchemaTypes, ShapeFromTypeParam } from '@pothos/core';

globalConnectionField: (name: string, field: ObjectFieldThunk<Types, ConnectionShape<Types, {}, false>>) => void;
relayMutationField: <Fields extends InputFieldMap, Nullable extends boolean, ResolveShape, ResolveReturnShape, Interfaces extends InterfaceParam<Types>[], InputName extends string = 'input'>(name: string, inputOptions: InputObjectRef<unknown> | RelayMutationInputOptions<Types, Fields, InputName>, fieldOptions: RelayMutationFieldOptions<Types, Fields, Nullable, InputName, ResolveShape, ResolveReturnShape>, payloadOptions: RelayMutationPayloadOptions<Types, ResolveShape, Interfaces>) => {
relayMutationField: <Fields extends InputFieldMap, Nullable extends boolean, ResolveShape, ResolveReturnShape, Interfaces extends InterfaceParam<Types>[], InputName extends string = 'input', Args extends InputFieldMap = {}>(name: string, inputOptions: InputObjectRef<unknown> | RelayMutationInputOptions<Types, Fields, InputName> | null, fieldOptions: RelayMutationFieldOptions<Types, Fields, Nullable, InputName, ResolveShape, ResolveReturnShape, Args>, payloadOptions: RelayMutationPayloadOptions<Types, ResolveShape, Interfaces>) => {
inputType: InputObjectRef<InputShapeWithClientMutationId<Types, Fields>>;

@@ -34,0 +34,0 @@ payloadType: ObjectRef<ResolveShape>;

@@ -184,5 +184,7 @@ import { GraphQLResolveInfo } from 'graphql';

};
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, {
export type RelayMutationFieldOptions<Types extends SchemaTypes, Fields extends InputFieldMap, Nullable extends boolean, InputName extends string, ResolveShape, ResolveReturnShape, Args extends InputFieldMap = {}> = Omit<FieldOptionsFromKind<Types, Types['Root'], OutputRef<ResolveShape>, Nullable, Args & {
[K in InputName]: InputFieldRef<InputShapeWithClientMutationId<Types, Fields>>;
}, 'Mutation', ResolveShape, ResolveReturnShape>, 'args' | 'type'>;
}, 'Mutation', ResolveShape, ResolveReturnShape>, 'args' | 'type'> & {
args?: Args;
};
export type RelayMutationPayloadOptions<Types extends SchemaTypes, Shape, Interfaces extends InterfaceParam<Types>[]> = Omit<PothosSchemaTypes.ObjectTypeOptions<Types, Shape> | PothosSchemaTypes.ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, 'fields'> & {

@@ -189,0 +191,0 @@ name?: string;

@@ -35,3 +35,3 @@ import { FieldKind, FieldNullability, FieldOptionsFromKind, FieldRef, FieldRequiredness, InputFieldMap, InputFieldRef, InputFieldsFromShape, InputShapeFromFields, InputShapeFromTypeParam, inputShapeKey, InterfaceParam, NormalizeArgs, ObjectFieldsShape, ObjectFieldThunk, ObjectParam, OutputShape, OutputType, ParentShape, Resolver, SchemaTypes, ShapeFromTypeParam } from '@pothos/core';

globalConnectionField: (name: string, field: ObjectFieldThunk<Types, ConnectionShape<Types, {}, false>>) => void;
relayMutationField: <Fields extends InputFieldMap, Nullable extends boolean, ResolveShape, ResolveReturnShape, Interfaces extends InterfaceParam<Types>[], InputName extends string = "input">(name: string, inputOptions: InputObjectRef<unknown> | RelayMutationInputOptions<Types, Fields, InputName>, fieldOptions: RelayMutationFieldOptions<Types, Fields, Nullable, InputName, ResolveShape, ResolveReturnShape>, payloadOptions: RelayMutationPayloadOptions<Types, ResolveShape, Interfaces>) => {
relayMutationField: <Fields extends InputFieldMap, Nullable extends boolean, ResolveShape, ResolveReturnShape, Interfaces extends InterfaceParam<Types>[], InputName extends string = "input", Args extends InputFieldMap = {}>(name: string, inputOptions: InputObjectRef<unknown> | RelayMutationInputOptions<Types, Fields, InputName> | null, fieldOptions: RelayMutationFieldOptions<Types, Fields, Nullable, InputName, ResolveShape, ResolveReturnShape, Args>, payloadOptions: RelayMutationPayloadOptions<Types, ResolveShape, Interfaces>) => {
inputType: InputObjectRef<InputShapeWithClientMutationId<Types, Fields>>;

@@ -38,0 +38,0 @@ payloadType: ObjectRef<ResolveShape>;

@@ -238,3 +238,3 @@ import { defaultTypeResolver } from 'graphql';

const mutationIdCache = createContextCache(() => new Map());
schemaBuilderProto.relayMutationField = function relayMutationField(fieldName, inputOptionsOrRef, { resolve, ...fieldOptions }, { name: payloadName = `${capitalize(fieldName)}Payload`, outputFields, interfaces, ...paylaodOptions }) {
schemaBuilderProto.relayMutationField = function relayMutationField(fieldName, inputOptionsOrRef, { resolve, args, ...fieldOptions }, { name: payloadName = `${capitalize(fieldName)}Payload`, outputFields, interfaces, ...payloadOptions }) {
var _this_options_relayOptions;

@@ -245,3 +245,3 @@ const { relayOptions: { clientMutationIdInputOptions = {}, clientMutationIdFieldOptions = {}, mutationInputArgOptions = {} } } = this.options;

let argName = "input";
if (inputOptionsOrRef instanceof InputObjectRef) {
if (!inputOptionsOrRef || inputOptionsOrRef instanceof InputObjectRef) {
inputRef = inputOptionsOrRef;

@@ -269,3 +269,3 @@ }

...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultPayloadTypeOptions,
...paylaodOptions,
...payloadOptions,
interfaces: interfaces,

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

...clientMutationIdFieldOptions,
resolve: (parent, args, context, info) => mutationIdCache(context).get(String(info.path.prev.key))
resolve: (parent, _args, context, info) => mutationIdCache(context).get(String(info.path.prev.key))
})

@@ -288,11 +288,16 @@ } : {}

args: {
[argName]: t.arg({
...mutationInputArgOptions,
type: inputRef,
required: true
})
...args,
...inputRef ? {
[argName]: t.arg({
...mutationInputArgOptions,
type: inputRef,
required: true
})
} : {}
},
resolve: (root, args, context, info) => {
mutationIdCache(context).set(String(info.path.key), args[argName].clientMutationId);
return resolve(root, args, context, info);
resolve: (root, fieldArgs, context, info) => {
if (inputRef) {
mutationIdCache(context).set(String(info.path.key), fieldArgs[argName].clientMutationId);
}
return resolve(root, fieldArgs, context, info);
}

@@ -299,0 +304,0 @@ }));

@@ -202,5 +202,7 @@ import { GraphQLResolveInfo } from 'graphql';

};
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, {
export type RelayMutationFieldOptions<Types extends SchemaTypes, Fields extends InputFieldMap, Nullable extends boolean, InputName extends string, ResolveShape, ResolveReturnShape, Args extends InputFieldMap = {}> = Omit<FieldOptionsFromKind<Types, Types["Root"], OutputRef<ResolveShape>, Nullable, Args & {
[K in InputName]: InputFieldRef<InputShapeWithClientMutationId<Types, Fields>>;
}, "Mutation", ResolveShape, ResolveReturnShape>, "args" | "type">;
}, "Mutation", ResolveShape, ResolveReturnShape>, "args" | "type"> & {
args?: Args;
};
export type RelayMutationPayloadOptions<Types extends SchemaTypes, Shape, Interfaces extends InterfaceParam<Types>[]> = Omit<PothosSchemaTypes.ObjectTypeOptions<Types, Shape> | PothosSchemaTypes.ObjectTypeWithInterfaceOptions<Types, Shape, Interfaces>, "fields"> & {

@@ -207,0 +209,0 @@ name?: string;

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

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, args, ...fieldOptions }, { name: payloadName = `${(0, _utils.capitalize)(fieldName)}Payload`, outputFields, interfaces, ...payloadOptions }) {
var _this_options_relayOptions;

@@ -302,3 +302,3 @@ const { relayOptions: { clientMutationIdInputOptions = {}, clientMutationIdFieldOptions = {}, mutationInputArgOptions = {} } } = this.options;

let argName = 'input';
if (inputOptionsOrRef instanceof _core.InputObjectRef) {
if (!inputOptionsOrRef || inputOptionsOrRef instanceof _core.InputObjectRef) {
inputRef = inputOptionsOrRef;

@@ -325,3 +325,3 @@ } else {

...(_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.defaultPayloadTypeOptions,
...paylaodOptions,
...payloadOptions,
interfaces: interfaces,

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

...clientMutationIdFieldOptions,
resolve: (parent, args, context, info)=>mutationIdCache(context).get(String(info.path.prev.key))
resolve: (parent, _args, context, info)=>mutationIdCache(context).get(String(info.path.prev.key))
})

@@ -344,11 +344,16 @@ } : {}

args: {
[argName]: t.arg({
...mutationInputArgOptions,
type: inputRef,
required: true
})
...args,
...inputRef ? {
[argName]: t.arg({
...mutationInputArgOptions,
type: inputRef,
required: true
})
} : {}
},
resolve: (root, args, context, info)=>{
mutationIdCache(context).set(String(info.path.key), args[argName].clientMutationId);
return resolve(root, args, context, info);
resolve: (root, fieldArgs, context, info)=>{
if (inputRef) {
mutationIdCache(context).set(String(info.path.key), fieldArgs[argName].clientMutationId);
}
return resolve(root, fieldArgs, context, info);
}

@@ -355,0 +360,0 @@ }));

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

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

"graphql-tag": "^2.12.6",
"@pothos/core": "3.40.1",
"@pothos/core": "3.41.0",
"@pothos/plugin-complexity": "3.13.0",

@@ -51,0 +51,0 @@ "@pothos/test-utils": "1.4.8"

@@ -242,3 +242,3 @@ # Relay Plugin

}
}),
},
},

@@ -245,0 +245,0 @@ {

@@ -108,5 +108,9 @@ import {

InputName extends string = 'input',
Args extends InputFieldMap = {},
>(
name: string,
inputOptions: InputObjectRef<unknown> | RelayMutationInputOptions<Types, Fields, InputName>,
inputOptions:
| InputObjectRef<unknown>
| RelayMutationInputOptions<Types, Fields, InputName>
| null,
fieldOptions: RelayMutationFieldOptions<

@@ -118,3 +122,4 @@ Types,

ResolveShape,
ResolveReturnShape
ResolveReturnShape,
Args
>,

@@ -121,0 +126,0 @@ payloadOptions: RelayMutationPayloadOptions<Types, ResolveShape, Interfaces>,

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

inputOptionsOrRef,
{ resolve, ...fieldOptions },
{ resolve, args, ...fieldOptions },
{

@@ -352,3 +352,3 @@ name: payloadName = `${capitalize(fieldName)}Payload`,

interfaces,
...paylaodOptions
...payloadOptions
},

@@ -366,6 +366,6 @@ ) {

let inputRef: InputObjectRef<unknown>;
let inputRef: InputObjectRef<unknown> | null;
let argName = 'input';
if (inputOptionsOrRef instanceof InputObjectRef) {
if (!inputOptionsOrRef || inputOptionsOrRef instanceof InputObjectRef) {
inputRef = inputOptionsOrRef;

@@ -400,3 +400,3 @@ } else {

...this.options.relayOptions?.defaultPayloadTypeOptions,
...paylaodOptions,
...payloadOptions,
interfaces: interfaces as never,

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

...clientMutationIdFieldOptions,
resolve: (parent, args, context, info) =>
resolve: (parent, _args, context, info) =>
mutationIdCache(context).get(String(info.path.prev!.key))!,

@@ -424,12 +424,23 @@ }),

args: {
[argName]: t.arg({ ...(mutationInputArgOptions as {}), type: inputRef, required: true }),
...args,
...(inputRef
? {
[argName]: t.arg({
...(mutationInputArgOptions as {}),
type: inputRef,
required: true,
}),
}
: {}),
},
resolve: (root, args, context, info) => {
mutationIdCache(context).set(
String(info.path.key),
(args as unknown as Record<string, { clientMutationId: string }>)[argName]
.clientMutationId,
);
resolve: (root, fieldArgs, context, info) => {
if (inputRef) {
mutationIdCache(context).set(
String(info.path.key),
(fieldArgs as unknown as Record<string, { clientMutationId: string }>)[argName]
.clientMutationId,
);
}
return resolve(root, args as never, context, info);
return resolve(root, fieldArgs as never, context, info);
},

@@ -436,0 +447,0 @@ }),

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

ResolveReturnShape,
Args extends InputFieldMap = {},
> = Omit<

@@ -669,3 +670,3 @@ FieldOptionsFromKind<

Nullable,
{
Args & {
[K in InputName]: InputFieldRef<InputShapeWithClientMutationId<Types, Fields>>;

@@ -678,3 +679,5 @@ },

'args' | 'type'
>;
> & {
args?: Args;
};

@@ -681,0 +684,0 @@ export type RelayMutationPayloadOptions<

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