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

[SupersetClient] implement put and delete HTTP methods #85

Merged
merged 4 commits into from
Jan 30, 2019
Merged

Conversation

mistercrunch
Copy link
Contributor

🏆 Enhancements
Trying to use METHOD = DELETE

@mistercrunch mistercrunch requested a review from a team as a code owner January 29, 2019 17:08
@codecov
Copy link

codecov bot commented Jan 29, 2019

Codecov Report

Merging #85 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #85   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          68     68           
  Lines         774    780    +6     
  Branches      182    180    -2     
=====================================
+ Hits          774    780    +6
Impacted Files Coverage Δ
...kages/superset-ui-connection/src/SupersetClient.ts 100% <100%> (ø) ⬆️
.../superset-ui-connection/src/SupersetClientClass.ts 100% <100%> (ø) ⬆️
packages/superset-ui-translation/src/Translator.ts 100% <0%> (ø) ⬆️

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 b907169...19dfa5b. Read the comment docs.

Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

Thanks for working to add these, initially we did not because these methods weren't used elsewhere in the app.

Had a few suggestions, I'm not a big fan of adding the general request on the public API and I think there's still work to update the existing POST implementation, but can see if @kristw or @xtinec think otherwise.

@@ -34,6 +35,7 @@ const SupersetClient: SupersetClientInterface = {
isAuthenticated: () => getInstance(singletonClient).isAuthenticated(),
post: (request: RequestConfig) => getInstance(singletonClient).post(request),
reAuthenticate: () => getInstance(singletonClient).init(/* force = */ true),
request: (request: RequestConfig) => getInstance(singletonClient).get(request),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should expose a general request method on the public interface, there are only 4 possible methods so if you want delete or put I would just add those.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like there are many more methods: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

Happy to add more explicit delete and put as they are most common. Can I leave request just in case? If someone has an edge case where they need to use one of the more obscure methods, it sucks to have to come and add it here...

@@ -70,12 +70,17 @@ export class SupersetClientClass {
return this.csrfToken !== null && this.csrfToken !== undefined;
}

async get({
async get(requestConfig: RequestConfig): Promise<SupersetClientResponse> {
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're refactoring get like this, I think you should also refactor post, and then could add delete / put on top of those.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@mistercrunch
Copy link
Contributor Author

@kristw @williaster this is ready for review, let me know if you want me to withdraw request from the API. I don't expect to use it, but could get handy if someone ever has to use one of the long-tail of http methods documented here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

@mistercrunch mistercrunch changed the title [SupersetClient] allow any http METHOD [SupersetClient] implement put and delete HTTP methods Jan 30, 2019
Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding these! 🏆

for publishing, we could handle this release, or we can get you set up with npm publishing. if you want to do it, can you give me your npm username / make one and I'll add you to the @superset-ui org? mistercrunch didn't seem to exist. after that we can chat on slack for more detailed instructions.

@kristw kristw merged commit fbd4b6e into master Jan 30, 2019
@delete-merged-branch delete-merged-branch bot deleted the requests branch January 30, 2019 21:56
@mistercrunch
Copy link
Contributor Author

@williaster I just created an account here: https://www.npmjs.com/~mistercrunch

@williaster
Copy link
Contributor

sent an invite 👌 Sounds like this should be included in the release @kristw just made.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants