GraphQLCasts icon indicating copy to clipboard operation
GraphQLCasts copied to clipboard

Fix MongoDB error Unknown modifier: $pushAll

Open scaccoman opened this issue 7 years ago • 0 comments

When running the following GraphQL query:

mutation {
  addLyricToSong(songId: "5af29df7c084014b34d2bb8a", content: "Oh my oh my its a cold night"){
    id
  }
}

This error is returned from my locally hosted MongoDB:

{
  "data": {
    "addLyricToSong": null
  },
  "errors": [
    {
      "message": "Unknown modifier: $pushAll",
      "locations": [
        {
          "line": 9,
          "column": 3
        }
      ],
      "path": [
        "addLyricToSong"
      ]
    }
  ]
}

Adding {usePushEach: true} solves the problem. Ref: https://medium.com/@stefanledin/how-to-solve-the-unknown-modifier-pushall-error-in-mongoose-d631489f85c0

scaccoman avatar May 10 '18 08:05 scaccoman