Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/beige-days-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"grafast": patch
---

Add `setParams` helper to loadOne/loadMany to save having to call `setParam`
multiple times.
5 changes: 5 additions & 0 deletions .changeset/big-crews-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"grafast": patch
---

Fix type mistake in loadManyLoader
5 changes: 5 additions & 0 deletions .changeset/red-maps-fall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"graphile-build": patch
---

Minor error message fix.
15 changes: 12 additions & 3 deletions grafast/grafast/src/steps/loadMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ export function loadManyCallback<
* LoadManyLoader.
*/
export function loadManyLoader<
const TLookup extends Multistep,
const TSpec,
TItem,
TData extends Maybe<ReadonlyArrayOrAsyncIterable<Maybe<TItem>>> = Maybe<
ReadonlyArrayOrAsyncIterable<Maybe<TItem>>
>,
TParams extends Record<string, any> = Record<string, any>,
const TShared extends Multistep = never,
>(
load: LoadManyLoader<TLookup, TItem, TData, TParams, TShared>,
): LoadManyLoader<TLookup, TItem, TData, TParams, TShared> {
load: LoadManyLoader<TSpec, TItem, TData, TParams, TShared>,
): LoadManyLoader<TSpec, TItem, TData, TParams, TShared> {
return load;
}

Expand Down Expand Up @@ -203,6 +203,15 @@ export class LoadManyStep<
value instanceof Step ? value : constant(value),
);
}
setParams<
TParams extends {
[key in keyof TParams]?: TParams[key] | Step<Maybe<TParams[key]>>;
},
>(params: TParams): void {
for (const [key, val] of Object.entries(params)) {
this.setParam(key, val as any);
}
}
addAttributes(attributes: Set<keyof TItem>): void {
for (const attribute of attributes) {
this.attributes.add(attribute);
Expand Down
9 changes: 9 additions & 0 deletions grafast/grafast/src/steps/loadOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ export class LoadOneStep<
value instanceof Step ? value : constant(value),
);
}
setParams<
TParams extends {
[key in keyof TParams]?: TParams[key] | Step<TParams[key]>;
},
>(params: TParams): void {
for (const [key, val] of Object.entries(params)) {
this.setParam(key, val as any);
}
}
addAttributes(attributes: Set<keyof TItem>): void {
for (const attribute of attributes) {
this.attributes.add(attribute);
Expand Down
9 changes: 9 additions & 0 deletions grafast/grafast/src/steps/loadedRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ export class LoadedRecordStep<
value instanceof Step ? value : constant(value),
);
}
setParams<
TParams extends {
[key in keyof TParams]?: TParams[key] | Step<TParams[key]>;
},
>(params: TParams): void {
for (const [key, val] of Object.entries(params)) {
this.setParam(key, val as any);
}
}
deduplicate(peers: LoadedRecordStep<any, any>[]) {
return peers.filter(
(p) =>
Expand Down
2 changes: 1 addition & 1 deletion graphile-build/graphile-build/src/makeNewBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading