uc-cdis / peregrine

GraphQL search API service
Apache License 2.0
11 stars 9 forks source link

availability_type=Open causes unexpected response in combination with first, offset #141

Closed jacquayj closed 4 years ago

jacquayj commented 4 years ago

This query returns an expected result:

{
  project(first:10, offset:0) {
    id
  }
}

Response:

{
  "data": {
    "project": [
      {
        "id": "621a0cc7-b98b-5900-baa4-fa5587cdee1b"
      },
      {
        "id": "ffd388bb-ccc0-539c-9b62-4d54e5a8ce7d"
      },
      {
        "id": "de58640b-92d6-543e-8476-8323dad56163"
      },
      {
        "id": "93deebb9-eca2-5544-baab-77ea77e51291"
      },
      {
        "id": "e25f7095-efc5-597c-a9e8-fb436467311d"
      },
      {
        "id": "f4e25616-f39d-5acb-884a-24b44fd09070"
      },
      {
        "id": "69c64e0e-bf8c-560c-8a5b-81656820cc58"
      },
      {
        "id": "601c41d4-06d0-514f-abb5-8411cb6112bf"
      },
      {
        "id": "6fb12fd1-8c5e-5c30-99d7-5e37d7982477"
      },
      {
        "id": "c6250c74-251f-5d34-a4cd-ad4063dc6e00"
      }
    ]
  }
}

However, when a sort is added, only 6 records are returned even though first is set to 10.

{
  project(first:10, offset:0, order_by_desc:"code") {
    id
  }
}

Response:

{
  "data": {
    "project": [
      {
        "id": "e229fcc3-48d6-59cd-b710-e83945477e8c"
      },
      {
        "id": "f55fe34a-11be-524e-8143-121c48673028"
      },
      {
        "id": "f05f3d1b-147f-5c87-80fc-6c0c2ff2cae6"
      },
      {
        "id": "b67aacec-bd07-57fd-8e13-36b8e67c7632"
      },
      {
        "id": "3adb38aa-6ffc-599e-aa1c-e9cc15e571d5"
      },
      {
        "id": "30b258a4-40b7-5ab3-bf11-b104e8a0aa9e"
      }
    ]
  }
}
jacquayj commented 4 years ago

Using quay.io/cdis/peregrine:2.0.1.

{
  project(first:10, offset:0) {
    id
    code
  }
}
{
  "data": {
    "project": [
      {
        "code": "P-20190924-0008",
        "id": "621a0cc7-b98b-5900-baa4-fa5587cdee1b"
      },
      {
        "code": "P-2019081-0001",
        "id": "ffd388bb-ccc0-539c-9b62-4d54e5a8ce7d"
      },
      {
        "code": "P-2017427-0008",
        "id": "de58640b-92d6-543e-8476-8323dad56163"
      },
      {
        "code": "P-20190924-0001",
        "id": "93deebb9-eca2-5544-baab-77ea77e51291"
      },
      {
        "code": "P-2017427-0005",
        "id": "e25f7095-efc5-597c-a9e8-fb436467311d"
      },
      {
        "code": "P-20190924-0003",
        "id": "f4e25616-f39d-5acb-884a-24b44fd09070"
      },
      {
        "code": "P-20190924-0002",
        "id": "69c64e0e-bf8c-560c-8a5b-81656820cc58"
      },
      {
        "code": "P-20190924-0005",
        "id": "601c41d4-06d0-514f-abb5-8411cb6112bf"
      },
      {
        "code": "P-20190924-0004",
        "id": "6fb12fd1-8c5e-5c30-99d7-5e37d7982477"
      },
      {
        "code": "P-20190924-0007",
        "id": "c6250c74-251f-5d34-a4cd-ad4063dc6e00"
      }
    ]
  }
}
{
  project(first:10, offset:0, order_by_desc:"code") {
    id
    code
  }
}
{
  "data": {
    "project": [
      {
        "code": "test-123",
        "id": "e229fcc3-48d6-59cd-b710-e83945477e8c"
      },
      {
        "code": "sdfgh",
        "id": "f55fe34a-11be-524e-8143-121c48673028"
      },
      {
        "code": "P-20190926-0021",
        "id": "2f2ca2db-93e1-5fa3-9e29-3fb9c193382b"
      },
      {
        "code": "P-20190926-0020",
        "id": "f05f3d1b-147f-5c87-80fc-6c0c2ff2cae6"
      },
      {
        "code": "P-20190926-0019",
        "id": "b67aacec-bd07-57fd-8e13-36b8e67c7632"
      },
      {
        "code": "P-20190926-0018",
        "id": "3adb38aa-6ffc-599e-aa1c-e9cc15e571d5"
      }
    ]
  }
}
jacquayj commented 4 years ago

Cloned my RDS database for remote access and ran local peregrine:2.1.0 dev instance against it, not able to reproduce the issue with the following auth mapping. Although rolling update peregrine:2.1.0 on k8 container still produces the same behavior.

auth_mapping = {
        'john@bioteam.net': {
            "/programs/myprogram": [
                {
                    "service": "peregrine", "method": "read"
                }
            ]
        }
    }

Thoughts:

jacquayj commented 4 years ago

availability_type=Open projects are causing the pagination bug. Consistently around half of the records that should be returned, are being returned, as designated by first.