2

Here is the thing, I'm building a simple inventory app that has products and parts. Products can have many parts and part can be in many Products.

I'm using React and GraphQL with Strapi backend and I want to update a product to add or remove certain products.

I can't go pass this error in GraphQL playground:

ID cannot represent a non-string and non-integer value:

I've tried with id: 1, id: "1", id: 1, id: "1" nothing works. Here is the Docs for the input:

enter image description here

I'm trying like this but it doesn't work:

mutation {
  updateProduct (input:{
    where:{
      id: 2
    }
    data: {
      parts: [
        {
          id: 3
        }
      ]
    }
  }){
    product{
      id
      productName
      parts {
        id
        partName
      }
    }
  }
}

I'd appreciate any help,

Thanks

fedjedmedjed
  • 415
  • 1
  • 6
  • 16

1 Answers1

0

Finally figured it out, turns out docs said it all along. It said: parts[ID] so I only had to:

mutation {
  updateProduct (input:{
    where:{
      id: 2
    }
    data: {
      parts: [
        3
      ]
    }
...

or if I wanted multiple parts I had to add it:

...
    data: {
      parts: [
         3,2
      ]
    }
...
fedjedmedjed
  • 415
  • 1
  • 6
  • 16