Agent v2 - How to override the default routes?

Hello,

I’m trying to know if it’s possible to override the default route, as exemple update of a collection.

agent-version: node-v2 => Forest Admin - [Beta] Developer guide (agents v2)

The new NodeJS implementation won’t support route overrides.

There are many reasons for that, the main one being that letting customers interact with low-level requests caused changes on our end to break customer code more often than we would like.

Instead multiple features are planned to fill the same need.

We’re working hard to release and document them as fast as possible, now that the new agent is publicly announced and a Beta is available.

[not released] Hooks

collection.addHook('List', (context, flow) => {
  return flow.continue()
});

Hooks is the lowest level feature that the new agents will have.
They allow to change behaviors in a controlled way.

[undocumented] Write overrides

collection.replaceWrite('aFieldName', value => {
  return { aFieldName: btoa(value) };
})

Write overrides allow to override the action that is performed when a given field is modified.

[not released] Validators

collection.addFieldValidation('aFieldName', 'GreaterThan', 4)
collection.addRelationValidation('someRelation', async (context) => {
  return {
    field: 'author:country:name',
    operator: 'Equal',
    value: 'France'
  }
});

This feature allows to add validation both in the frontend and agent for a list of preset conditions on specific fields.

2 Likes

so with you’re exemple we going to have something like :

collection.addHook('Update', (context, flow) => {
  return flow.continue()
});

Is the field validation is are already check or only if the field changed ?

It is difficult to reply to that last question: hooks are being designed/developed as we speak, so I can’t know for sure.

What I can tell is that

  • Once they are released they will be documented
  • Methods will be available to raise validation and permission errors from them before any action is performed on the backends which are plugged into the agent
1 Like