diff --git a/examples/todo-app/src/resources/TodoResource.ts b/examples/todo-app/src/resources/TodoResource.ts index cd089155a0c8..d886d6cd2632 100644 --- a/examples/todo-app/src/resources/TodoResource.ts +++ b/examples/todo-app/src/resources/TodoResource.ts @@ -21,11 +21,6 @@ export const TodoResource = createPlaceholderResource({ }); export const queryRemainingTodos = new Query( - new schema.All(Todo), - (entries, { userId } = {}) => { - if (userId !== undefined) - return entries.filter((todo) => todo.userId === userId && !todo.completed) - .length; - return entries.filter((todo) => !todo.completed).length; - }, + TodoResource.getList.schema, + (entries) => entries && entries.filter((todo) => !todo.completed).length, ); diff --git a/packages/endpoint/src/queryEndpoint.ts b/packages/endpoint/src/queryEndpoint.ts index dddd277a588a..bd66254274a1 100644 --- a/packages/endpoint/src/queryEndpoint.ts +++ b/packages/endpoint/src/queryEndpoint.ts @@ -34,11 +34,7 @@ export class Query< protected createQuerySchema(schema: SchemaSimple) { const query = Object.create(schema); - query.denormalize = ( - { args, input }: { args: P; input: any }, - _: P, - unvisit: any, - ) => { + query.denormalize = (input: any, args: P, unvisit: any) => { if (input === undefined) return undefined; const value = (schema as any).denormalize(input, args, unvisit); return typeof value === 'symbol' @@ -56,7 +52,7 @@ export class Query< ) => any, entities: EntityTable, ) => { - return { args, input: recurse(schema, args, indexes, entities) }; + return recurse(schema, args, indexes, entities); }; return query; }