Skip to content

When two relationships exist on A and B save updates do not reflect properly from B (c in issue) #1

@iamacup

Description

@iamacup

There is a problem when updating C's value for cmixedblocks when it, and cmixedblocks2 are both referencing the same A (could be further than this)

import { CollectionConfig } from "payload/types";

const A: CollectionConfig = {
  slug: "a",
  access: {
    read: () => true,
  },
  fields: [
    {
      name: "name",
      type: "text",
    },
    {
      type: "relationship",
      relationTo: "c",
      hasMany: true,
      name: "amixedblocks",
      custom: {
        relationshipEnhancer: {
          relationshipIntegrity: true,
          biDirectional: [
            {
              relationTo: "c",
              path: "cmixedblocks",
            },
          ],
        },
      },
    },
    {
      type: "relationship",
      relationTo: "c",
      hasMany: true,
      name: "amixedblocks2",
      custom: {
        relationshipEnhancer: {
          relationshipIntegrity: true,
          biDirectional: [
            {
              relationTo: "c",
              path: "cmixedblocks2",
            },
          ],
        },
      },
    },
  ],
};

export default A;

and

import { CollectionConfig } from "payload/types";

const C: CollectionConfig = {
  slug: "c",
  access: {
    read: () => true,
  },
  fields: [
    {
      name: "name",
      type: "text",
    },
    {
      type: "relationship",
      relationTo: ["a", "b"],
      hasMany: true,
      name: "cmixedblocks",
      custom: {
        relationshipEnhancer: {
          relationshipIntegrity: true,
          biDirectional: [
            {
              relationTo: "a",
              path: "amixedblocks",
            },
            {
              relationTo: "b",
              path: "bmixedblocks",
            },
          ],
        },
      },
    },
    {
      type: "relationship",
      relationTo: "a",
      hasMany: true,
      name: "cmixedblocks2",
      custom: {
        relationshipEnhancer: {
          relationshipIntegrity: true,
          biDirectional: [
            {
              relationTo: "a",
              path: "amixedblocks2",
            },
          ],
        },
      },
    },
  ],
};

export default C;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions