Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat(query): add functions to wrap api calls with typings #555

Merged
merged 6 commits into from
Jun 3, 2020

Conversation

kristw
Copy link
Contributor

@kristw kristw commented May 30, 2020

🏆 Enhancements

Facilitate the calls to explore_json and api/v1/chart/data by specify required params and provide typescript type for their response. Logics are based on the chartAction.js code in incubator-superset.

  • postChartData()
  • fetchExploreJson()

Future plan

  • Add more functions for other APIs.
  • Replace calls in incubator-superset and @superset-ui/chart to use these functions.

@kristw kristw requested a review from a team as a code owner May 30, 2020 23:01
@vercel
Copy link

vercel bot commented May 30, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/superset/superset-ui/ehq37vtbi
✅ Preview: https://superset-ui-git-kristw-query.superset.now.sh

@vercel vercel bot temporarily deployed to Preview May 30, 2020 23:03 Inactive
@codecov
Copy link

codecov bot commented May 30, 2020

Codecov Report

Merging #555 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #555      +/-   ##
==========================================
+ Coverage   23.13%   23.24%   +0.11%     
==========================================
  Files         290      293       +3     
  Lines        6783     6793      +10     
  Branches      676      681       +5     
==========================================
+ Hits         1569     1579      +10     
  Misses       5176     5176              
  Partials       38       38              
Impacted Files Coverage Δ
...perset-ui-query/src/api/legacy/fetchExploreJson.ts 100.00% <100.00%> (ø)
...ages/superset-ui-query/src/api/v1/postChartData.ts 100.00% <100.00%> (ø)
...s/superset-ui-query/test/api/fixtures/constants.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67b5d75...7483a33. Read the comment docs.

@@ -0,0 +1,28 @@
import { SupersetClientInterface, SupersetClient, RequestConfig } from '@superset-ui/connection';
import { QueryFormData } from '../../types/QueryFormData';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank god for this custom type... i have mild ptsd from formData lol


return fetchFunc({
...requestConfig,
// TODO: Have to transform formData as query string for GET

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example for what a query string could look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a utility function in incubator-superset that has to be ported here.

Copy link

@espressoroaster espressoroaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Curious what the conversion from formData to query string would look like.

Copy link
Contributor

@ktmud ktmud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM expect some doubt about variable names.

@@ -0,0 +1,17 @@
/* eslint-disable camelcase */
export interface V1ChartDataResponseResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the V1 prefix. Having a prefix makes it look temporary or deprecated. Was ChartDataResponseResult used elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the doubts about variable names. This was the hardest part about this PR.
I had trouble with naming and went back and forth whether to version or not. Still not fully satisfied TBH. On one hand I want to avoid naming collision if there is v2. On the other hand the V1xxx looks a bit weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @rusackas @suddjian if you have thoughts about naming.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think marking it as v1 is useful in cases where the interface specifically relates to behavior of the v1 api.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't feel strongly either way so I will merge and adjust later if anybody has more comments.

@kristw kristw merged commit 9137580 into master Jun 3, 2020
@delete-merged-branch delete-merged-branch bot deleted the kristw--query branch June 3, 2020 01:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants