msupply-foundation / unified-codes

Provides a curated, searchable list of pharmaceutical products, each with an immutable code. A GraphQL API, a REST API and website are available for interaction with the database.
https://codes.msupply.foundation
2 stars 0 forks source link

Add properties to entities query #606

Closed jmbrunskill closed 7 months ago

jmbrunskill commented 7 months ago

Fixes #605

Description

The dgraph backend entities query was deliberately kept minimal to avoid having huge dgraph requests just to get product names, however the mSupply query is asking for properties.

query{
    entities(filter: { description: "para" type: "drug unit_of_use medicinal_product" orderBy: { field: "description" descending: false } } offset: 0 first: 25) { data { code description type properties { type value } product { properties { type value } } }, totalLength }
}

Now returns:

{
  "data": {
    "entities": {
      "data": [
        {
          "code": "bbfcf518",
          "description": "Paracetamol Oral Suspension 24mg per mL",
          "type": "DoseStrength",
          "properties": [],
          "product": null
        },

Checklist:

-[ ] Also need to make product properties work, as they should be included in mSupply too...

Tests:

Tick below if one of the following applies:

  1. Tests have been added to cover changes introduced by this PR.
  2. This PR requires no new tests.
lache-melvin commented 7 months ago

Also need to make product properties work, as they should be included in mSupply too...

Oh good call - do you mean that product field is used in mSupply? Are you intending to include that in this PR as well or a separate piece of work?

jmbrunskill commented 7 months ago

we do this entities query for all items for the fuzzy search - especially as we add more items I can imagine this query getting slow?

Yeah, it definitely doesn't feel great. Could compare speed to using a loader for all properties? Still seems fast locally on good hardware, but I agree! Maybe an issue for the future?

jmbrunskill commented 7 months ago

Oh good call - do you mean that product field is used in mSupply? Are you intending to include that in this PR as well or a separate piece of work?

Was going to do this in the same PR, but since it's approved, I'll merge this and do the other in a new one.