Skip to content

Commit

Permalink
update query work
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Oct 8, 2023
1 parent ab99520 commit 4cfc247
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
9 changes: 2 additions & 7 deletions examples/todo-app/src/resources/TodoResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
8 changes: 2 additions & 6 deletions packages/endpoint/src/queryEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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;
}
Expand Down

0 comments on commit 4cfc247

Please sign in to comment.