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

[Bug]: Creating or Updating advanced many-to-many relationship fails when more than one relation #913

Closed
TobiasZimmermannDsb opened this issue Nov 21, 2024 · 1 comment · Fixed by #914
Assignees
Labels
Milestone

Comments

@TobiasZimmermannDsb
Copy link

Expected behavior

Normal create and update objects with more than one advanced many-to-many relationship.

Actual behavior

Key "auto_id" passed for upsert not found in data

Steps to reproduce

Create a Car class with more than one advanced many-to-many relationship.
Run the GraphQL query

mutation {
  createCar(
    path: "/Product Data/Cars/vw/"
    key: "TestCar"
    defaultLanguage: "de"
    published: false
    type: "object"
    input: {
      carToCarRelation: [
        {
          type: "object"
          id: 232
          metadata: [{ name: "name", value: "green one" }]
        }
        {
          type: "object"
          id: 227
          metadata: [{ name: "name", value: "beige one" }]
        }
      ]
    }
  ) {
    success
    message
    output {
      id
    }
  }
}

result in error

{
  "data": {
    "createCar": {
      "success": false,
      "message": "Key \"`auto_id`\" passed for upsert not found in data",
      "output": {
        "id": null
      }
    }
  }
}

Same for updating existing Car with more than one advanced many-to-many relationship:

mutation {
  updateCar(
    id: 1167
    defaultLanguage: "de"
    input: {
      carToCarRelation: [
        {
          type: "object"
          id: 232
          metadata: [{ name: "name", value: "green one" }]
        }
        {
          type: "object"
          id: 227
          metadata: [{ name: "name", value: "beige one" }]
        }
      ]
    }
  ) {
    success
    message
    output {
      id
    }
  }
}

results in same error:

{
  "data": {
    "updateCar": {
      "success": false,
      "message": "Key \"`auto_id`\" passed for upsert not found in data",
      "output": {
        "id": null
      }
    }
  }
}

Probably relates to: #819

@TobiasZimmermannDsb
Copy link
Author

I have checked the fix. Class

src/GraphQL/DataObjectInputProcessor/AdvancedManyToManyObjectRelation.php

probably also needs to be fixed with the same adjustments.
Can you please check it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants