Skip to content

Commit

Permalink
fix(schema): Fix dispatch resovler hook to convert actually resolved …
Browse files Browse the repository at this point in the history
…data (#2663)
  • Loading branch information
daffl authored Jun 11, 2022
1 parent b41279b commit f7e87db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/schema/src/hooks/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ export const resolveDispatch =
const status = context.params.resolve
const { isPaginated, data } = getData(context)
const resolveAndGetDispatch = async (current: any) => {
const resolved = await runResolvers(resolvers, current, ctx, status)
const resolved: any = await runResolvers(resolvers, current, ctx, status)

return Object.keys(resolved).reduce((res, key) => {
res[key] = getDispatch(current[key])
res[key] = getDispatch(resolved[key])

return res
}, {} as any)
Expand Down
3 changes: 2 additions & 1 deletion packages/schema/test/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export const userResultResolver = resolve<UserResult, HookContext<Application>>(
export const userDispatchResolver = resolve<UserResult, HookContext<Application>>({
schema: userResultSchema,
properties: {
password: () => undefined
password: async () => undefined,
email: async () => '[redacted]'
}
})

Expand Down
2 changes: 1 addition & 1 deletion packages/schema/test/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ describe('@feathersjs/schema/hooks', () => {
userId: 0,
id: 0,
user: {
email: 'hello@feathersjs.com',
id: 0,
email: '[redacted]',
name: 'hello (hello@feathersjs.com)'
}
})
Expand Down

0 comments on commit f7e87db

Please sign in to comment.