Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action doesn't contain updated payload from previous filter hook #13183

Closed
samdze opened this issue May 9, 2022 · 0 comments
Closed

Action doesn't contain updated payload from previous filter hook #13183

samdze opened this issue May 9, 2022 · 0 comments

Comments

@samdze
Copy link

samdze commented May 9, 2022

Describe the Bug

I subscribed to the 'user.create' hook using both an action and a filter.
In the filter, I add an additional field to the payload and return it. The user gets created correctly with the added field.

The issue is inside the action hook. The payload object doesn't contain the additional field I added during the filter function.

To Reproduce

Here's my setup:

export default defineHook(({ filter, action }, { services }) => {
	const { ItemsService } = services

	filter('users.create', async (input, meta, { database, schema, accountability }) => {
		const profilesService = new ItemsService('profiles', { database, schema, accountability })
		const resultId = await profilesService.createOne({ first_name: input.first_name, last_name: input.last_name, email: input.email })

		console.log('User is being created!', { input, meta, resultId })
		return { ...input, profile: resultId }
	})

	action('users.create', async (input, { database, schema, accountability }) => {
                // input.payload doesn't contain 'profile'!
		console.log('User created!', input)
	})
})

Errors Shown

No error is shown.

What version of Directus are you using?

9.10.0

What version of Node.js are you using?

Docker image version

What database are you using?

Postgres 14

What browser are you using?

Firefox

How are you deploying Directus?

Docker

@directus directus locked and limited conversation to collaborators May 9, 2022
@rijkvanzanten rijkvanzanten converted this issue into discussion #13188 May 9, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant