Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api-gateway): add meta about query in gql #8410

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nurulhudaapon
Copy link

@nurulhudaapon nurulhudaapon commented Jun 29, 2024

Check List

  • Tests has been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made (if issue reference is not provided)

This PR adds extensions.meta which is equivalent to all metadata about query result that is available via the REST API /load endpoint. The load endpoint returns metadata such as total and others but these were not available through the graphql API.

Here is an example of getting total/query-meta from GraphQL API:
Query:

query GetTotal {
  users: cube(total: true, limit: 1, meta: true) {
    users {
      email
    }
  }
  users_with_total: cube(total: true, limit: 1) {
    users {
      email
    }
  }
}

Response:

{
  "data": {
    "users": [
      {
        "users": {
          "email": "nurul@voyagesms.com"
        }
      }
    ],
    "users_with_total": [
      {
        "users": {
          "email": "nurul@voyagesms.com"
        }
      }
    ]
  },
  "extensions": {
    "meta": {
      "users": {
        "total": 5,
        "dbType": "postgres",
        "extDbType": "cubestore",
        "external": false,
        "lastRefreshTime": "2024-07-03T12:27:17.147Z",
        "slowQuery": false
      },
      "users_with_total": {
        "total": 5
      }
    }
  }
}

So this PR is enabling feature like getting the total via GraphQL API which wasn't possible previously and opens up adding other metadata if needed.

@nurulhudaapon nurulhudaapon requested a review from a team as a code owner June 29, 2024 07:38
Copy link

vercel bot commented Jun 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-angular-dashboard ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Jul 3, 2024 1:32pm
@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label Jun 29, 2024
@igorlukanin
Copy link
Member

Hi @nurulhudaapon 👋 Thanks for your contribution!

I see that you not only add resultMeta but you also propagate total—that is amazing. Ideally, it would be great to have these changes in separate PRs.

Do I understand correctly that resultMeta would bring meta together with query results? That does seem like a deviation from what /v1/meta and /v1/load do for the REST API. Could you please elaborate on your design decisions here?

If the goal is to allow requesting meta via the GraphQL API, I would try to design it similarly to the REST API, i.e.g, have a dedicated way to request just meta, not pair it with a result set.

@igorlukanin igorlukanin self-assigned this Jul 2, 2024
@nurulhudaapon nurulhudaapon changed the title feat(@cubejs-backend/api-gateway): add meta field to gql res Jul 3, 2024
@nurulhudaapon
Copy link
Author

nurulhudaapon commented Jul 3, 2024

Hi @nurulhudaapon 👋 Thanks for your contribution!

I see that you not only add resultMeta but you also propagate total—that is amazing. Ideally, it would be great to have these changes in separate PRs.

Do I understand correctly that resultMeta would bring meta together with query results? That does seem like a deviation from what /v1/meta and /v1/load do for the REST API. Could you please elaborate on your design decisions here?

If the goal is to allow requesting meta via the GraphQL API, I would try to design it similarly to the REST API, i.e.g, have a dedicated way to request just meta, not pair it with a result set.

Hi @igorlukanin, sorry for the confusion about the /meta API, this is different and only adds metadata about query result. I've updated the PR title, description and also updated the doc to align on what it does. Let me know if it is clearer now. Thanks.

@nurulhudaapon nurulhudaapon changed the title feat(@cubejs-backend/api-gateway): add meta about query in gql Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:community Contribution from Cube.js community members.
3 participants