diff --git a/.changeset/beige-days-grin.md b/.changeset/beige-days-grin.md new file mode 100644 index 0000000000..20df82e5bb --- /dev/null +++ b/.changeset/beige-days-grin.md @@ -0,0 +1,6 @@ +--- +"grafast": patch +--- + +Add `setParams` helper to loadOne/loadMany to save having to call `setParam` +multiple times. diff --git a/.changeset/big-crews-sniff.md b/.changeset/big-crews-sniff.md new file mode 100644 index 0000000000..ced8a3083c --- /dev/null +++ b/.changeset/big-crews-sniff.md @@ -0,0 +1,5 @@ +--- +"grafast": patch +--- + +Fix type mistake in loadManyLoader diff --git a/.changeset/red-maps-fall.md b/.changeset/red-maps-fall.md new file mode 100644 index 0000000000..152e2043f4 --- /dev/null +++ b/.changeset/red-maps-fall.md @@ -0,0 +1,5 @@ +--- +"graphile-build": patch +--- + +Minor error message fix. diff --git a/grafast/grafast/src/steps/loadMany.ts b/grafast/grafast/src/steps/loadMany.ts index bd8746c846..421119a71b 100644 --- a/grafast/grafast/src/steps/loadMany.ts +++ b/grafast/grafast/src/steps/loadMany.ts @@ -77,7 +77,7 @@ export function loadManyCallback< * LoadManyLoader. */ export function loadManyLoader< - const TLookup extends Multistep, + const TSpec, TItem, TData extends Maybe>> = Maybe< ReadonlyArrayOrAsyncIterable> @@ -85,8 +85,8 @@ export function loadManyLoader< TParams extends Record = Record, const TShared extends Multistep = never, >( - load: LoadManyLoader, -): LoadManyLoader { + load: LoadManyLoader, +): LoadManyLoader { return load; } @@ -203,6 +203,15 @@ export class LoadManyStep< value instanceof Step ? value : constant(value), ); } + setParams< + TParams extends { + [key in keyof TParams]?: TParams[key] | Step>; + }, + >(params: TParams): void { + for (const [key, val] of Object.entries(params)) { + this.setParam(key, val as any); + } + } addAttributes(attributes: Set): void { for (const attribute of attributes) { this.attributes.add(attribute); diff --git a/grafast/grafast/src/steps/loadOne.ts b/grafast/grafast/src/steps/loadOne.ts index a0db61bb8d..8d1afde987 100644 --- a/grafast/grafast/src/steps/loadOne.ts +++ b/grafast/grafast/src/steps/loadOne.ts @@ -162,6 +162,15 @@ export class LoadOneStep< value instanceof Step ? value : constant(value), ); } + setParams< + TParams extends { + [key in keyof TParams]?: TParams[key] | Step; + }, + >(params: TParams): void { + for (const [key, val] of Object.entries(params)) { + this.setParam(key, val as any); + } + } addAttributes(attributes: Set): void { for (const attribute of attributes) { this.attributes.add(attribute); diff --git a/grafast/grafast/src/steps/loadedRecord.ts b/grafast/grafast/src/steps/loadedRecord.ts index 533c7a134a..b0763274fc 100644 --- a/grafast/grafast/src/steps/loadedRecord.ts +++ b/grafast/grafast/src/steps/loadedRecord.ts @@ -74,6 +74,15 @@ export class LoadedRecordStep< value instanceof Step ? value : constant(value), ); } + setParams< + TParams extends { + [key in keyof TParams]?: TParams[key] | Step; + }, + >(params: TParams): void { + for (const [key, val] of Object.entries(params)) { + this.setParam(key, val as any); + } + } deduplicate(peers: LoadedRecordStep[]) { return peers.filter( (p) => diff --git a/graphile-build/graphile-build/src/makeNewBuild.ts b/graphile-build/graphile-build/src/makeNewBuild.ts index d5f0e028a2..bd166baff4 100644 --- a/graphile-build/graphile-build/src/makeNewBuild.ts +++ b/graphile-build/graphile-build/src/makeNewBuild.ts @@ -96,7 +96,7 @@ export default function makeNewBuild( ); } const newTypeSource = - origin || `'addType' call during hook '${build.status.currentHookName}'`; + origin || `'register' call during hook '${build.status.currentHookName}'`; if (allTypesSources[typeName]) { const oldTypeSource = allTypesSources[typeName]; const firstEntityDetails = !oldTypeSource