psychonautwiki / bifrost

The PsychonautWiki API.
MIT License
48 stars 10 forks source link

Query.substances errors when `limit` argument is too high #25

Closed dlbnco closed 4 years ago

dlbnco commented 4 years ago

Query

query getSubstances($limit: Int, $offset: Int) {
  substances(limit: $limit, offset: $offset) {
    name
    class {
      psychoactive
      chemical
    }
    featured
  }
}

Variables

Seems to error when values higher than 51 are used.

{
  "limit": 100
}

Response

{
  "data": {
    "substances": null
  },
  "errors": [
    {
      "locations": [
        {
          "column": 45,
          "line": 1
        }
      ],
      "message": "Cannot destructure property `query` of 'undefined' or 'null'.",
      "path": [
        "substances"
      ]
    }
  ]
}
19h commented 4 years ago

I suspect values higher than 50 cause a hard-error on the internal API level and this bubbles up and the bad value cannot be returned because it violates the GraphQL schema. I'll take a look at it soon.

Andeskjerf commented 4 years ago

Any update on this? My app has been unable to query the API for a while now.

19h commented 4 years ago

@predme I'm not sure why this is a critical error. Please elaborate why you need to query for more than 50 items via the API.

Andeskjerf commented 4 years ago

@19h My app queries the API for all the substances, caches it and displays the result in the app. To query all substances, I set the limit to 9999. Unfortunately, if it's the first time the user starts the app, I won't be able to cache the result, nor give any substance info to the user.

Edit:

This used to work fine by the way. I've been querying the API this way for the past 3 months and only recently did it stop working. Not sure when, but I assume around the time this issue was opened.

19h commented 4 years ago

Thanks for your explanation. I will treat this as a critical error.

19h commented 4 years ago

A short investigation showed this is not actually related to pagination. I will close this issue and will track the status of this breakage in #26.

19h commented 4 years ago

@dlbnco @predme fixed in #26.