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.32.0 to 3.33.0

6

CHANGELOG.md
# Change Log
## 3.33.0
### Minor Changes
- 5c6e0abb: Add option for disabling node and nodes fields
## 3.32.0

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

8

dts/types.d.ts

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

pageInfoTypeOptions: Omit<PothosSchemaTypes.ObjectTypeOptions<Types, PageInfoShape>, 'fields'>;
nodeQueryOptions: Omit<PothosSchemaTypes.QueryFieldOptions<Types, OutputRefShape<GlobalIDShape<Types> | string>, boolean, {
nodeQueryOptions: false | (Omit<PothosSchemaTypes.QueryFieldOptions<Types, OutputRefShape<GlobalIDShape<Types> | string>, boolean, {
id: InputFieldRef<InputShape<Types, 'ID'>>;

@@ -24,4 +24,4 @@ }, Promise<unknown>>, 'args' | 'resolve' | 'type'> & {

}) => Promise<unknown>) => MaybePromise<unknown>;
};
nodesQueryOptions: Omit<PothosSchemaTypes.QueryFieldOptions<Types, [
});
nodesQueryOptions: false | (Omit<PothosSchemaTypes.QueryFieldOptions<Types, [
OutputRefShape<GlobalIDShape<Types> | string>

@@ -40,3 +40,3 @@ ], FieldNullability<[unknown]>, {

}[]) => Promise<unknown[]>) => MaybePromise<MaybePromise<unknown>[]>;
};
});
mutationInputArgOptions: Omit<PothosSchemaTypes.ArgFieldOptions<Types, InputRef<{}>, boolean>, 'fields' | 'type'>;

@@ -43,0 +43,0 @@ clientMutationIdInputOptions: Omit<PothosSchemaTypes.InputObjectFieldOptions<Types, 'ID', boolean>, 'type'>;

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

schemaBuilderProto.nodeInterfaceRef = function nodeInterfaceRef() {
var _this_options_relayOptions, _this_options_relayOptions_nodeQueryOptions, _this_options_relayOptions1, _this_options_relayOptions_nodesQueryOptions;
var _this_options_relayOptions, _this_options_relayOptions1;
if (nodeInterfaceRefMap.has(this)) {

@@ -95,35 +95,41 @@ return nodeInterfaceRefMap.get(this);

});
const resolveNodeFn = (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : (_this_options_relayOptions_nodeQueryOptions = _this_options_relayOptions.nodeQueryOptions) === null || _this_options_relayOptions_nodeQueryOptions === void 0 ? void 0 : _this_options_relayOptions_nodeQueryOptions.resolve;
this.queryField("node", (t) => t.field({
nullable: true,
...this.options.relayOptions.nodeQueryOptions,
type: ref,
args: {
id: t.arg.globalID({
required: true
})
},
resolve: resolveNodeFn ? (root, args, context, info) => resolveNodeFn(root, args, context, info, async (ids) => (await resolveNodes(this, context, info, [
args.id
]))[0]) : async (root, args, context, info) => (await resolveNodes(this, context, info, [
args.id
]))[0]
}));
const resolveNodesFn = (_this_options_relayOptions1 = this.options.relayOptions) === null || _this_options_relayOptions1 === void 0 ? void 0 : (_this_options_relayOptions_nodesQueryOptions = _this_options_relayOptions1.nodesQueryOptions) === null || _this_options_relayOptions_nodesQueryOptions === void 0 ? void 0 : _this_options_relayOptions_nodesQueryOptions.resolve;
this.queryField("nodes", (t) => t.field({
nullable: {
list: false,
items: true
},
...this.options.relayOptions.nodesQueryOptions,
type: [
ref
],
args: {
ids: t.arg.globalIDList({
required: true
})
},
resolve: resolveNodesFn ? (root, args, context, info) => resolveNodesFn(root, args, context, info, (ids) => resolveNodes(this, context, info, args.ids)) : (root, args, context, info) => resolveNodes(this, context, info, args.ids)
}));
const nodeQueryOptions = (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.nodeQueryOptions;
if (nodeQueryOptions !== false) {
const resolveNodeFn = nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : nodeQueryOptions.resolve;
this.queryField("node", (t) => t.field({
nullable: true,
...this.options.relayOptions.nodeQueryOptions,
type: ref,
args: {
id: t.arg.globalID({
required: true
})
},
resolve: resolveNodeFn ? (root, args, context, info) => resolveNodeFn(root, args, context, info, async (ids) => (await resolveNodes(this, context, info, [
args.id
]))[0]) : async (root, args, context, info) => (await resolveNodes(this, context, info, [
args.id
]))[0]
}));
}
const nodesQueryOptions = (_this_options_relayOptions1 = this.options.relayOptions) === null || _this_options_relayOptions1 === void 0 ? void 0 : _this_options_relayOptions1.nodesQueryOptions;
if (nodesQueryOptions !== false) {
const resolveNodesFn = nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : nodesQueryOptions.resolve;
this.queryField("nodes", (t) => t.field({
nullable: {
list: false,
items: true
},
...this.options.relayOptions.nodesQueryOptions,
type: [
ref
],
args: {
ids: t.arg.globalIDList({
required: true
})
},
resolve: resolveNodesFn ? (root, args, context, info) => resolveNodesFn(root, args, context, info, (ids) => resolveNodes(this, context, info, args.ids)) : (root, args, context, info) => resolveNodes(this, context, info, args.ids)
}));
}
return ref;

@@ -130,0 +136,0 @@ };

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

pageInfoTypeOptions: Omit<PothosSchemaTypes.ObjectTypeOptions<Types, PageInfoShape>, "fields">;
nodeQueryOptions: Omit<PothosSchemaTypes.QueryFieldOptions<Types, OutputRefShape<GlobalIDShape<Types> | string>, boolean, {
nodeQueryOptions: false | (Omit<PothosSchemaTypes.QueryFieldOptions<Types, OutputRefShape<GlobalIDShape<Types> | string>, boolean, {
id: InputFieldRef<InputShape<Types, "ID">>;

@@ -24,4 +24,4 @@ }, Promise<unknown>>, "args" | "resolve" | "type"> & {

}) => Promise<unknown>) => MaybePromise<unknown>;
};
nodesQueryOptions: Omit<PothosSchemaTypes.QueryFieldOptions<Types, [
});
nodesQueryOptions: false | (Omit<PothosSchemaTypes.QueryFieldOptions<Types, [
OutputRefShape<GlobalIDShape<Types> | string>

@@ -42,3 +42,3 @@ ], FieldNullability<[

}[]) => Promise<unknown[]>) => MaybePromise<MaybePromise<unknown>[]>;
};
});
mutationInputArgOptions: Omit<PothosSchemaTypes.ArgFieldOptions<Types, InputRef<{}>, boolean>, "fields" | "type">;

@@ -45,0 +45,0 @@ clientMutationIdInputOptions: Omit<PothosSchemaTypes.InputObjectFieldOptions<Types, "ID", boolean>, "type">;

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

schemaBuilderProto.nodeInterfaceRef = function nodeInterfaceRef() {
var _this_options_relayOptions, _this_options_relayOptions_nodeQueryOptions, _this_options_relayOptions1, _this_options_relayOptions_nodesQueryOptions;
var _this_options_relayOptions, _this_options_relayOptions1;
if (nodeInterfaceRefMap.has(this)) {

@@ -147,35 +147,41 @@ return nodeInterfaceRefMap.get(this);

});
const resolveNodeFn = (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : (_this_options_relayOptions_nodeQueryOptions = _this_options_relayOptions.nodeQueryOptions) === null || _this_options_relayOptions_nodeQueryOptions === void 0 ? void 0 : _this_options_relayOptions_nodeQueryOptions.resolve;
this.queryField('node', (t)=>t.field({
nullable: true,
...this.options.relayOptions.nodeQueryOptions,
type: ref,
args: {
id: t.arg.globalID({
required: true
})
},
resolve: resolveNodeFn ? (root, args, context, info)=>resolveNodeFn(root, args, context, info, async (ids)=>(await (0, _utils.resolveNodes)(this, context, info, [
const nodeQueryOptions = (_this_options_relayOptions = this.options.relayOptions) === null || _this_options_relayOptions === void 0 ? void 0 : _this_options_relayOptions.nodeQueryOptions;
if (nodeQueryOptions !== false) {
const resolveNodeFn = nodeQueryOptions === null || nodeQueryOptions === void 0 ? void 0 : nodeQueryOptions.resolve;
this.queryField('node', (t)=>t.field({
nullable: true,
...this.options.relayOptions.nodeQueryOptions,
type: ref,
args: {
id: t.arg.globalID({
required: true
})
},
resolve: resolveNodeFn ? (root, args, context, info)=>resolveNodeFn(root, args, context, info, async (ids)=>(await (0, _utils.resolveNodes)(this, context, info, [
args.id
]))[0]) : async (root, args, context, info)=>(await (0, _utils.resolveNodes)(this, context, info, [
args.id
]))[0]) : async (root, args, context, info)=>(await (0, _utils.resolveNodes)(this, context, info, [
args.id
]))[0]
}));
const resolveNodesFn = (_this_options_relayOptions1 = this.options.relayOptions) === null || _this_options_relayOptions1 === void 0 ? void 0 : (_this_options_relayOptions_nodesQueryOptions = _this_options_relayOptions1.nodesQueryOptions) === null || _this_options_relayOptions_nodesQueryOptions === void 0 ? void 0 : _this_options_relayOptions_nodesQueryOptions.resolve;
this.queryField('nodes', (t)=>t.field({
nullable: {
list: false,
items: true
},
...this.options.relayOptions.nodesQueryOptions,
type: [
ref
],
args: {
ids: t.arg.globalIDList({
required: true
})
},
resolve: resolveNodesFn ? (root, args, context, info)=>resolveNodesFn(root, args, context, info, (ids)=>(0, _utils.resolveNodes)(this, context, info, args.ids)) : (root, args, context, info)=>(0, _utils.resolveNodes)(this, context, info, args.ids)
}));
]))[0]
}));
}
const nodesQueryOptions = (_this_options_relayOptions1 = this.options.relayOptions) === null || _this_options_relayOptions1 === void 0 ? void 0 : _this_options_relayOptions1.nodesQueryOptions;
if (nodesQueryOptions !== false) {
const resolveNodesFn = nodesQueryOptions === null || nodesQueryOptions === void 0 ? void 0 : nodesQueryOptions.resolve;
this.queryField('nodes', (t)=>t.field({
nullable: {
list: false,
items: true
},
...this.options.relayOptions.nodesQueryOptions,
type: [
ref
],
args: {
ids: t.arg.globalIDList({
required: true
})
},
resolve: resolveNodesFn ? (root, args, context, info)=>resolveNodesFn(root, args, context, info, (ids)=>(0, _utils.resolveNodes)(this, context, info, args.ids)) : (root, args, context, info)=>(0, _utils.resolveNodes)(this, context, info, args.ids)
}));
}
return ref;

@@ -182,0 +188,0 @@ };

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

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -39,4 +39,6 @@ # Relay Plugin

Overwriting this default is highly encouraged.
- `nodeQueryOptions`: Options for the `node` field on the query object
- `nodesQueryOptions`: Options for the `nodes` field on the query object
- `nodeQueryOptions`: Options for the `node` field on the query object, set to false to omit the
field
- `nodesQueryOptions`: Options for the `nodes` field on the query object, set to false to omit the
field
- `nodeTypeOptions`: Options for the `Node` interface type

@@ -43,0 +45,0 @@ - `pageInfoTypeOptions`: Options for the `TypeInfo` object type

@@ -146,70 +146,78 @@ import { defaultTypeResolver, GraphQLResolveInfo } from 'graphql';

const resolveNodeFn = this.options.relayOptions?.nodeQueryOptions?.resolve;
const nodeQueryOptions = this.options.relayOptions?.nodeQueryOptions;
this.queryField(
'node',
(t) =>
if (nodeQueryOptions !== false) {
const resolveNodeFn = nodeQueryOptions?.resolve;
this.queryField(
'node',
(t) =>
t.field({
nullable: true,
...this.options.relayOptions.nodeQueryOptions,
type: ref as InterfaceRef<unknown>,
args: {
id: t.arg.globalID({ required: true }),
},
resolve: resolveNodeFn
? (root, args, context, info) =>
resolveNodeFn(
root,
args as { id: { id: string; typename: string } },
context,
info,
async (ids) =>
(
await resolveNodes(this, context, info, [
args.id as { id: string; typename: string },
])
)[0],
) as never
: async (root, args, context, info) =>
(
await resolveNodes(this, context, info, [
args.id as { id: string; typename: string },
])
)[0],
}) as FieldRef<unknown>,
);
}
const nodesQueryOptions = this.options.relayOptions?.nodesQueryOptions;
if (nodesQueryOptions !== false) {
const resolveNodesFn = nodesQueryOptions?.resolve;
this.queryField('nodes', (t) =>
t.field({
nullable: true,
...this.options.relayOptions.nodeQueryOptions,
type: ref as InterfaceRef<unknown>,
nullable: {
list: false,
items: true,
},
...this.options.relayOptions.nodesQueryOptions,
type: [ref],
args: {
id: t.arg.globalID({ required: true }),
ids: t.arg.globalIDList({ required: true }),
},
resolve: resolveNodeFn
resolve: resolveNodesFn
? (root, args, context, info) =>
resolveNodeFn(
resolveNodesFn(
root,
args as { id: { id: string; typename: string } },
args as { ids: { id: string; typename: string }[] },
context,
info,
async (ids) =>
(
await resolveNodes(this, context, info, [
args.id as { id: string; typename: string },
])
)[0],
(ids) =>
resolveNodes(this, context, info, args.ids as { id: string; typename: string }[]),
) as never
: async (root, args, context, info) =>
(
await resolveNodes(this, context, info, [
args.id as { id: string; typename: string },
])
)[0],
}) as FieldRef<unknown>,
);
: (root, args, context, info) =>
resolveNodes(
this,
context,
info,
args.ids as { id: string; typename: string }[],
) as never,
}),
);
}
const resolveNodesFn = this.options.relayOptions?.nodesQueryOptions?.resolve;
this.queryField('nodes', (t) =>
t.field({
nullable: {
list: false,
items: true,
},
...this.options.relayOptions.nodesQueryOptions,
type: [ref],
args: {
ids: t.arg.globalIDList({ required: true }),
},
resolve: resolveNodesFn
? (root, args, context, info) =>
resolveNodesFn(
root,
args as { ids: { id: string; typename: string }[] },
context,
info,
(ids) =>
resolveNodes(this, context, info, args.ids as { id: string; typename: string }[]),
) as never
: (root, args, context, info) =>
resolveNodes(
this,
context,
info,
args.ids as { id: string; typename: string }[],
) as never,
}),
);
return ref;

@@ -216,0 +224,0 @@ };

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

pageInfoTypeOptions: Omit<PothosSchemaTypes.ObjectTypeOptions<Types, PageInfoShape>, 'fields'>;
nodeQueryOptions: Omit<
PothosSchemaTypes.QueryFieldOptions<
Types,
OutputRefShape<GlobalIDShape<Types> | string>,
boolean,
{ id: InputFieldRef<InputShape<Types, 'ID'>> },
Promise<unknown>
>,
'args' | 'resolve' | 'type'
> & {
resolve?: (
parent: Types['Root'],
args: {
id: { typename: string; id: string };
},
context: Types['Context'],
info: GraphQLResolveInfo,
resolveNode: (id: { id: string; typename: string }) => Promise<unknown>,
) => MaybePromise<unknown>;
};
nodesQueryOptions: Omit<
PothosSchemaTypes.QueryFieldOptions<
Types,
[OutputRefShape<GlobalIDShape<Types> | string>],
FieldNullability<[unknown]>,
{ ids: InputFieldRef<InputShape<Types, 'ID'>[]> },
Promise<unknown>[]
>,
'args' | 'resolve' | 'type'
> & {
resolve?: (
parent: Types['Root'],
args: {
ids: { typename: string; id: string }[];
},
context: Types['Context'],
info: GraphQLResolveInfo,
resolveNodes: (ids: { id: string; typename: string }[]) => Promise<unknown[]>,
) => MaybePromise<MaybePromise<unknown>[]>;
};
nodeQueryOptions:
| false
| (Omit<
PothosSchemaTypes.QueryFieldOptions<
Types,
OutputRefShape<GlobalIDShape<Types> | string>,
boolean,
{ id: InputFieldRef<InputShape<Types, 'ID'>> },
Promise<unknown>
>,
'args' | 'resolve' | 'type'
> & {
resolve?: (
parent: Types['Root'],
args: {
id: { typename: string; id: string };
},
context: Types['Context'],
info: GraphQLResolveInfo,
resolveNode: (id: { id: string; typename: string }) => Promise<unknown>,
) => MaybePromise<unknown>;
});
nodesQueryOptions:
| false
| (Omit<
PothosSchemaTypes.QueryFieldOptions<
Types,
[OutputRefShape<GlobalIDShape<Types> | string>],
FieldNullability<[unknown]>,
{ ids: InputFieldRef<InputShape<Types, 'ID'>[]> },
Promise<unknown>[]
>,
'args' | 'resolve' | 'type'
> & {
resolve?: (
parent: Types['Root'],
args: {
ids: { typename: string; id: string }[];
},
context: Types['Context'],
info: GraphQLResolveInfo,
resolveNodes: (ids: { id: string; typename: string }[]) => Promise<unknown[]>,
) => MaybePromise<MaybePromise<unknown>[]>;
});
mutationInputArgOptions: Omit<

@@ -88,0 +92,0 @@ PothosSchemaTypes.ArgFieldOptions<Types, InputRef<{}>, boolean>,

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