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
The action hook event is not up to date with the schema #11421
Comments
|
What action hook are you using? |
action('collections.create', async ({ key: collection }, { accountability }) => {
const { FieldsService } = services
const schema = await getSchema()
const fieldsService = new FieldsService({
knex: database, schema, accountability: { ...accountability, admin: true }
})
const fieldOptions = {
field: 'slug',
type: 'string',
meta: {
interface: 'input',
readonly: true
}
}
try {
await fieldsService.createField(collection, fieldOptions)
} catch (error) {
console.log(error);
}
})
This is the code I was trying, if the schema was up to date, the new collection should show at the schema @rijkvanzanten |
action('collections.create', async ({ key: collection }, context) => {
const schema = await getSchema()
console.log(schema, collection, !!schema.collections[collection]);
})if you try to run this code, you'll see that the new collection is not at the schema |
|
Hello! |
|
Sadly I had some problems getting directus to run on my pc. Since I don't have time right now to find out why, I'll unasign myself. |
|
Hello, could I claim this issue and attempt fixing it? |
|
Of course! We've assigned you, feel free to reach out over Discord if you have any questions along the way. |

Preflight Checklist
Describe the Bug
When I try to create a new field in a recent created collection, the schema when the hook is fired (action) is not up to date with what the schema should look like
To Reproduce
create a action hook, try to log the collections from the context schema, create a collection in the app, the new collection will not show at the schema
Errors Shown
No response
What version of Directus are you using?
9.5.0
What version of Node.js are you using?
16.13.1
What database are you using?
sql
What browser are you using?
chrome
What operating system are you using?
windows
How are you deploying Directus?
Docker
The text was updated successfully, but these errors were encountered: