Can I create a reference in a replica data source to a different data source?

Feature(s) impacted

I have a replica datasource with a schema defined, and a Sequelize datasource operating too. I’m trying to create a reference between the replica datasource and Sequelize and can’t get the configuration right.

Observed behavior

If I set the schema in the replica datasource to reference the sequelize model I get the error:
Error: clients has not been defined - where clients is the name of my collection.

Schema defined as:

schema: [
    {
      name: "logins",
      fields: {
        id: { type: "String", isPrimaryKey: true },
        status: { type: "String" },
        user: { type: "String" },
        client: { type: "String", reference: {
          relationName: 'client',
          relationInverse: 'logins',
          targetCollection: 'clients',
          targetField: 'id',
        }, },
        terms: { type: "Boolean" },
        email_verified: { type: "Boolean" },
        name: { type: "String" },
        email: { type: "String" },
      },
    },
  ],

I have also tried using the agent relations setup and setting client as { type: "String" }

agent.customizeCollection('clients', (collection) => {
    collection.addOneToOneRelation('login', 'logins', {
      originKey: 'client',
    });
  });
  agent.customizeCollection('logins', collection => {
    collection.addManyToOneRelation('client', 'clients', {
      foreignKey: 'client',
    });
  });

But this failed with a maximum call stack exceeded exception.

Expected behavior

I would expect to be able to relate custom datasources to other datasources in the same way as you can with other datasources.

Failure Logs

Context

  • Project name: KAI Conversations
  • Team name: Ops
  • Environment name: Development
  • Agent technology: (nodejs, php, rails, python) nodejs
  • Agent (forest package) name & version: @forestadmin/agent 1.53.1
  • Database type: postgres
  • Recent changes made on your end if any: building a new environment with the new agent

Hello @richw-kai,
Indeed you could not create a relation from the schema property, you should use our helper to create a relation between two datasources like you did. But it seems you encounter a bug (call stack exceeded exception). Just to be sure, could you pull all the latest versions of @forestadmin dependencies please? There is no breaking change :slight_smile: :pray: