Skip to content
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

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

Open
iamacup opened this issue Dec 10, 2023 · 0 comments

Comments

@iamacup
Copy link
Owner

iamacup commented Dec 10, 2023

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant