Skip to content

Is there a way to export gql response dynamicly? #301

Closed
@nrbnlulu

Description

@nrbnlulu

The problem:

exporting data with graphql is inefficient .
for example lets look at this query:

query{
  SiteById(id:852){
    unitSet{
      connableSet{
        connablealertSet{
        TidKey
        TidValue
        }
      }
    }
  }
}

returns this json respons:

{
  "SiteById": [
    {
      "unitSet": [
        {
          "connableSet": [
            {
              "connablealertSet": [
                { "TidKey": 151, "TidValue": "סכום בדיקת ROM שגוי" }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Lets assume i only need TidKey and TidValue,
to do this this is what you would normally find on the web:

import pandas as pd
pd.json_normalize(res['SiteById'][0]['unitSet'][0]['connableSet'][0]['connablealertSet'])

Results this:
image

As you can see this is extremely inefficient for these reasons:

  1. I need to know exactly what i queried for.
  2. If the result had more fields the code above would break .
  3. If i would change the query slightly i would need to change how i export it as well.

I hope i am missing something because otherwise its back to REST

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions