@pothos/plugin-relay
Advanced tools
Comparing version 3.36.0 to 3.37.0
# Change Log | ||
## 3.37.0 | ||
### Minor Changes | ||
- 68c94e4f: Support parsing globalIDs for loadableNode | ||
### Patch Changes | ||
- d2b02b79: Fix a few issues with globalID parsing | ||
## 3.36.0 | ||
@@ -4,0 +14,0 @@ |
@@ -59,3 +59,5 @@ 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'; | ||
}; | ||
globalID: <Req extends boolean, For extends ObjectParam<Types>>(...args: NormalizeArgs<[options: GlobalIDInputFieldOptions<Types, Req, Kind, For>]>) => InputFieldRef<InputShapeFromTypeParam<Types, GlobalIDInputShape<For extends NodeRef<unknown, unknown, infer T> ? T : string>, Req>, Kind>; | ||
globalID: <Req extends boolean, For extends ObjectParam<Types>>(...args: NormalizeArgs<[options: GlobalIDInputFieldOptions<Types, Req, Kind, For>]>) => InputFieldRef<InputShapeFromTypeParam<Types, GlobalIDInputShape<For extends { | ||
parseId?: (...args: any[]) => infer T; | ||
} ? T : string>, Req>, Kind>; | ||
globalIDList: <Req extends FieldRequiredness<['ID']>, For extends ObjectParam<Types>>(...args: NormalizeArgs<[options: GlobalIDListInputFieldOptions<Types, Req, Kind, For>]>) => InputFieldRef<InputShapeFromTypeParam<Types, [ | ||
@@ -65,3 +67,5 @@ { | ||
typename: string; | ||
id: For extends NodeRef<unknown, unknown, infer T> ? T : string; | ||
id: For extends { | ||
parseId?: (...args: any[]) => infer T; | ||
} ? T : string; | ||
}; | ||
@@ -68,0 +72,0 @@ } |
@@ -51,3 +51,3 @@ import { assertArray, ObjectRef, RootFieldBuilder } from '@pothos/core'; | ||
const globalID = typeof rawID === "string" ? internalDecodeGlobalID(this.builder, rawID, context, info, true) : rawID && { | ||
id: String(rawID.id), | ||
id: rawID.id, | ||
typename: this.builder.configStore.getTypeConfig(rawID.type).name | ||
@@ -79,3 +79,3 @@ }; | ||
const globalIds = rawIds.map((id) => typeof id === "string" ? internalDecodeGlobalID(this.builder, id, context, info, true) : id && { | ||
id: String(id.id), | ||
id: id.id, | ||
typename: this.builder.configStore.getTypeConfig(id.type).name | ||
@@ -82,0 +82,0 @@ }); |
@@ -70,3 +70,5 @@ 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'; | ||
options: GlobalIDInputFieldOptions<Types, Req, Kind, For> | ||
]>) => InputFieldRef<InputShapeFromTypeParam<Types, GlobalIDInputShape<For extends NodeRef<unknown, unknown, infer T> ? T : string>, Req>, Kind>; | ||
]>) => InputFieldRef<InputShapeFromTypeParam<Types, GlobalIDInputShape<For extends { | ||
parseId?: (...args: any[]) => infer T; | ||
} ? T : string>, Req>, Kind>; | ||
globalIDList: <Req extends FieldRequiredness<[ | ||
@@ -80,3 +82,5 @@ "ID" | ||
typename: string; | ||
id: For extends NodeRef<unknown, unknown, infer T> ? T : string; | ||
id: For extends { | ||
parseId?: (...args: any[]) => infer T; | ||
} ? T : string; | ||
}; | ||
@@ -83,0 +87,0 @@ } |
@@ -17,5 +17,5 @@ import './global-types.js'; | ||
if ((_inputField_extensions = inputField.extensions) === null || _inputField_extensions === void 0 ? void 0 : _inputField_extensions.isRelayGlobalID) { | ||
var _inputField_extensions1; | ||
var _inputField_extensions_relayGlobalIDFor; | ||
return (_inputField_extensions_relayGlobalIDFor = (_inputField_extensions1 = inputField.extensions) === null || _inputField_extensions1 === void 0 ? void 0 : _inputField_extensions1.relayGlobalIDFor) !== null && _inputField_extensions_relayGlobalIDFor !== void 0 ? _inputField_extensions_relayGlobalIDFor : true; | ||
var _inputField_extensions1, _inputField_extensions2; | ||
var _inputField_extensions_relayGlobalIDFor, _ref; | ||
return (_ref = (_inputField_extensions_relayGlobalIDFor = (_inputField_extensions1 = inputField.extensions) === null || _inputField_extensions1 === void 0 ? void 0 : _inputField_extensions1.relayGlobalIDFor) !== null && _inputField_extensions_relayGlobalIDFor !== void 0 ? _inputField_extensions_relayGlobalIDFor : (_inputField_extensions2 = inputField.extensions) === null || _inputField_extensions2 === void 0 ? void 0 : _inputField_extensions2.relayGlobalIDAlwaysParse) !== null && _ref !== void 0 ? _ref : false; | ||
} | ||
@@ -27,3 +27,4 @@ return null; | ||
} | ||
const argMapper = createInputValueMapper(argMappings, (globalID, mappings, ctx, info) => internalDecodeGlobalID(this.builder, String(globalID), ctx, info, Array.isArray(mappings.value) ? mappings.value : false)); | ||
var _mappings_value; | ||
const argMapper = createInputValueMapper(argMappings, (globalID, mappings, ctx, info) => internalDecodeGlobalID(this.builder, String(globalID), ctx, info, (_mappings_value = mappings.value) !== null && _mappings_value !== void 0 ? _mappings_value : false)); | ||
return (parent, args, context, info) => resolver(parent, argMapper(args, undefined, context, info), context, info); | ||
@@ -30,0 +31,0 @@ } |
import { InputFieldBuilder } from '@pothos/core'; | ||
import { NodeRef } from './node-ref.js'; | ||
const inputFieldBuilder = InputFieldBuilder.prototype; | ||
@@ -16,3 +15,3 @@ inputFieldBuilder.globalIDList = function globalIDList({ for: forTypes, ...options } = {}) { | ||
typename: this.builder.configStore.getTypeConfig(type).name, | ||
parse: type instanceof NodeRef ? type.parseId : undefined | ||
parseId: "parseId" in type ? type.parseId : undefined | ||
}))) !== null && _map !== void 0 ? _map : null | ||
@@ -34,3 +33,3 @@ } | ||
typename: this.builder.configStore.getTypeConfig(type).name, | ||
parse: type instanceof NodeRef ? type.parseId : undefined | ||
parseId: "parseId" in type ? type.parseId : undefined | ||
}))) !== null && _map !== void 0 ? _map : null | ||
@@ -37,0 +36,0 @@ } |
@@ -104,3 +104,6 @@ import { defaultTypeResolver } from 'graphql'; | ||
id: t.arg.globalID({ | ||
required: true | ||
required: true, | ||
extensions: { | ||
relayGlobalIDAlwaysParse: true | ||
} | ||
}) | ||
@@ -129,3 +132,6 @@ }, | ||
ids: t.arg.globalIDList({ | ||
required: true | ||
required: true, | ||
extensions: { | ||
relayGlobalIDAlwaysParse: true | ||
} | ||
}) | ||
@@ -132,0 +138,0 @@ }, |
@@ -55,3 +55,3 @@ "use strict"; | ||
const globalID = typeof rawID === 'string' ? (0, _internal.internalDecodeGlobalID)(this.builder, rawID, context, info, true) : rawID && { | ||
id: String(rawID.id), | ||
id: rawID.id, | ||
typename: this.builder.configStore.getTypeConfig(rawID.type).name | ||
@@ -83,3 +83,3 @@ }; | ||
const globalIds = rawIds.map((id)=>typeof id === 'string' ? (0, _internal.internalDecodeGlobalID)(this.builder, id, context, info, true) : id && { | ||
id: String(id.id), | ||
id: id.id, | ||
typename: this.builder.configStore.getTypeConfig(id.type).name | ||
@@ -86,0 +86,0 @@ }); |
@@ -81,5 +81,5 @@ "use strict"; | ||
if ((_inputField_extensions = inputField.extensions) === null || _inputField_extensions === void 0 ? void 0 : _inputField_extensions.isRelayGlobalID) { | ||
var _inputField_extensions1; | ||
var _inputField_extensions_relayGlobalIDFor; | ||
return (_inputField_extensions_relayGlobalIDFor = (_inputField_extensions1 = inputField.extensions) === null || _inputField_extensions1 === void 0 ? void 0 : _inputField_extensions1.relayGlobalIDFor) !== null && _inputField_extensions_relayGlobalIDFor !== void 0 ? _inputField_extensions_relayGlobalIDFor : true; | ||
var _inputField_extensions1, _inputField_extensions2; | ||
var _inputField_extensions_relayGlobalIDFor, _ref; | ||
return (_ref = (_inputField_extensions_relayGlobalIDFor = (_inputField_extensions1 = inputField.extensions) === null || _inputField_extensions1 === void 0 ? void 0 : _inputField_extensions1.relayGlobalIDFor) !== null && _inputField_extensions_relayGlobalIDFor !== void 0 ? _inputField_extensions_relayGlobalIDFor : (_inputField_extensions2 = inputField.extensions) === null || _inputField_extensions2 === void 0 ? void 0 : _inputField_extensions2.relayGlobalIDAlwaysParse) !== null && _ref !== void 0 ? _ref : false; | ||
} | ||
@@ -91,3 +91,4 @@ return null; | ||
} | ||
const argMapper = (0, _core.createInputValueMapper)(argMappings, (globalID, mappings, ctx, info)=>(0, _internal.internalDecodeGlobalID)(this.builder, String(globalID), ctx, info, Array.isArray(mappings.value) ? mappings.value : false)); | ||
var _mappings_value; | ||
const argMapper = (0, _core.createInputValueMapper)(argMappings, (globalID, mappings, ctx, info)=>(0, _internal.internalDecodeGlobalID)(this.builder, String(globalID), ctx, info, (_mappings_value = mappings.value) !== null && _mappings_value !== void 0 ? _mappings_value : false)); | ||
return (parent, args, context, info)=>resolver(parent, argMapper(args, undefined, context, info), context, info); | ||
@@ -94,0 +95,0 @@ } |
@@ -6,3 +6,2 @@ "use strict"; | ||
const _core = require("@pothos/core"); | ||
const _nodeRef = require("./node-ref"); | ||
const inputFieldBuilder = _core.InputFieldBuilder.prototype; | ||
@@ -21,3 +20,3 @@ inputFieldBuilder.globalIDList = function globalIDList({ for: forTypes , ...options } = {}) { | ||
typename: this.builder.configStore.getTypeConfig(type).name, | ||
parse: type instanceof _nodeRef.NodeRef ? type.parseId : undefined | ||
parseId: 'parseId' in type ? type.parseId : undefined | ||
}))) !== null && _map !== void 0 ? _map : null | ||
@@ -39,3 +38,3 @@ } | ||
typename: this.builder.configStore.getTypeConfig(type).name, | ||
parse: type instanceof _nodeRef.NodeRef ? type.parseId : undefined | ||
parseId: 'parseId' in type ? type.parseId : undefined | ||
}))) !== null && _map !== void 0 ? _map : null | ||
@@ -42,0 +41,0 @@ } |
@@ -156,3 +156,6 @@ "use strict"; | ||
id: t.arg.globalID({ | ||
required: true | ||
required: true, | ||
extensions: { | ||
relayGlobalIDAlwaysParse: true | ||
} | ||
}) | ||
@@ -181,3 +184,6 @@ }, | ||
ids: t.arg.globalIDList({ | ||
required: true | ||
required: true, | ||
extensions: { | ||
relayGlobalIDAlwaysParse: true | ||
} | ||
}) | ||
@@ -184,0 +190,0 @@ }, |
{ | ||
"name": "@pothos/plugin-relay", | ||
"version": "3.36.0", | ||
"version": "3.37.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", |
@@ -131,3 +131,3 @@ import { GraphQLResolveInfo } from 'graphql'; | ||
: rawID && { | ||
id: String(rawID.id), | ||
id: rawID.id, | ||
typename: this.builder.configStore.getTypeConfig(rawID.type).name, | ||
@@ -169,3 +169,3 @@ }; | ||
: id && { | ||
id: String(id.id), | ||
id: id.id, | ||
typename: this.builder.configStore.getTypeConfig(id.type).name, | ||
@@ -172,0 +172,0 @@ }, |
@@ -201,3 +201,3 @@ import { | ||
Types, | ||
GlobalIDInputShape<For extends NodeRef<unknown, unknown, infer T> ? T : string>, | ||
GlobalIDInputShape<For extends { parseId?: (...args: any[]) => infer T } ? T : string>, | ||
Req | ||
@@ -217,3 +217,3 @@ >, | ||
typename: string; | ||
id: For extends NodeRef<unknown, unknown, infer T> ? T : string; | ||
id: For extends { parseId?: (...args: any[]) => infer T } ? T : string; | ||
}; | ||
@@ -220,0 +220,0 @@ }, |
@@ -30,5 +30,5 @@ import './global-types'; | ||
if (inputField.extensions?.isRelayGlobalID) { | ||
return (inputField.extensions?.relayGlobalIDFor ?? true) as | ||
| true | ||
| { typename: string; parseId: (id: string, ctx: object) => unknown }[]; | ||
return (inputField.extensions?.relayGlobalIDFor ?? | ||
inputField.extensions?.relayGlobalIDAlwaysParse ?? | ||
false) as boolean | { typename: string; parseId: (id: string, ctx: object) => unknown }[]; | ||
} | ||
@@ -46,9 +46,3 @@ | ||
(globalID, mappings, ctx: Types['Context'], info: GraphQLResolveInfo) => | ||
internalDecodeGlobalID( | ||
this.builder, | ||
String(globalID), | ||
ctx, | ||
info, | ||
Array.isArray(mappings.value) ? mappings.value : false, | ||
), | ||
internalDecodeGlobalID(this.builder, String(globalID), ctx, info, mappings.value ?? false), | ||
); | ||
@@ -55,0 +49,0 @@ |
@@ -9,3 +9,2 @@ import { | ||
} from '@pothos/core'; | ||
import { NodeRef } from './node-ref'; | ||
import { | ||
@@ -41,3 +40,3 @@ GlobalIDInputFieldOptions, | ||
typename: this.builder.configStore.getTypeConfig(type).name, | ||
parse: type instanceof NodeRef ? type.parseId : undefined, | ||
parseId: 'parseId' in type ? type.parseId : undefined, | ||
})) ?? null, | ||
@@ -65,3 +64,3 @@ }, | ||
typename: this.builder.configStore.getTypeConfig(type).name, | ||
parse: type instanceof NodeRef ? type.parseId : undefined, | ||
parseId: 'parseId' in type ? type.parseId : undefined, | ||
})) ?? null, | ||
@@ -68,0 +67,0 @@ }, |
@@ -161,3 +161,8 @@ import { defaultTypeResolver, GraphQLResolveInfo } from 'graphql'; | ||
args: { | ||
id: t.arg.globalID({ required: true }), | ||
id: t.arg.globalID({ | ||
required: true, | ||
extensions: { | ||
relayGlobalIDAlwaysParse: true, | ||
}, | ||
}), | ||
}, | ||
@@ -202,3 +207,8 @@ resolve: resolveNodeFn | ||
args: { | ||
ids: t.arg.globalIDList({ required: true }), | ||
ids: t.arg.globalIDList({ | ||
required: true, | ||
extensions: { | ||
relayGlobalIDAlwaysParse: true, | ||
}, | ||
}), | ||
}, | ||
@@ -205,0 +215,0 @@ resolve: resolveNodesFn |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
404480
5189