Skip to content

Commit

Permalink
fix(core): sets info parameter as required ElementInfo for Collection…
Browse files Browse the repository at this point in the history
….toImplementation
  • Loading branch information
rafamel committed Nov 24, 2019
1 parent 69ca8ff commit 6317dca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/classes/Collection/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type CollectionImplementationInputFn<
Q extends QueryServiceUnion = QueryServiceUnion,
M extends MutationServiceUnion = MutationServiceUnion,
S extends SubscriptionServiceUnion = SubscriptionServiceUnion
> = (service: Q | M | S, info: ElementInfo) => ServiceImplementation;
> = (service: Q | M | S, info: Required<ElementInfo>) => ServiceImplementation;

/* Options */
export interface CollectionInterceptOptions {
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/classes/Collection/helpers/to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ export function toImplementation<
collection: AbstractCollectionTree<Q, M, S>,
fn: CollectionImplementationInputFn
): CollectionTreeImplementation {
return replace(collection, (element, info, next) => {
return replace(collection, (element, { path, route }, next) => {
element = next(element);
return isElementService(element)
? (fn(element, info) as AbstractElement<Q, M, S>)
: element;
if (!isElementService(element)) return element;

if (!route) throw Error(`Route expected at path: ${path}`);
return fn(element, { path, route }) as AbstractElement<Q, M, S>;
}) as CollectionTreeImplementation;
}

Expand Down

0 comments on commit 6317dca

Please sign in to comment.