GraphQL Errors (slice bounds out of range)

Hey,
we are using GraphQL in our (React) Web App to get data from MongoDB. The whole thing is set up using Realm.
Unfortunately we get errors quering the results. And strangely this happens only occasionally (~1 out of 5 times) but will sometimes prevent our users to use our service :frowning:

Our Query looks like this:

query {
      merchants {
        name
        address {
          postalCode
          street
        }
      }
    }

And as a result we get this (sometimes):

{
  "data": {
    "merchants": [
      {
        "address": null,
        "name": "Test Merchant 1"
      },
      {
        "address": null,
        "name": "Test Merchant 2"
      },
      {
        "address": null,
        "name": "Test Merchant 3"
      }
    ]
  },
  "errors": [
    {
      "message": "runtime error: slice bounds out of range [-1:]",
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "path": ["merchants", 0, "address", "postalCode"]
    },
    {
      "message": "runtime error: slice bounds out of range [-1:]",
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "path": ["merchants", 1, "address", "postalCode"]
    },
    {
      "message": "runtime error: slice bounds out of range [-1:]",
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "path": ["merchants", 2, "address", "postalCode"]
    }
  ]
}

We get this error even using the Realm GraphQL playground.

Any ideas why this is happening sometimes or how to avoid it?

Kind Regards :slight_smile:

1 Like

Hi Ebrima - do you have the ability to create a support ticket with MongoDB? That might be the most effective way to debug this issue.

Hi @Ebrima_Ieigh .

Did you manage to solve the issue?
I’m having the same problem, and if you can share any tips it would be much appreciated.

No not yet.
For now we just adjusted the apollo client to refetch the data once there is an error. But this can only be a temporary solution.
We have to look into this issue again soon