E5F3 fix(schema): Fix dispatch resolver hook to convert actually resolved data by daffl · Pull Request #2663 · feathersjs/feathers · GitHub
[go: up one dir, main page]

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
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