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

Apollo server 2.0 - DatasourceREST - Improve types #1190

Conversation

fabien0102
Copy link
Contributor

@fabien0102 fabien0102 commented Jun 18, 2018

Hello,

I'm just begining to play a little bit with Apollo server 2.0, datasourceRest and typescript.

This PR include some little improvements:

  • Use generics instead of any to permit to type the response easily
  • Use the full type from URLSearchParams to be more precise about the possibilities of the API
  • Add PATCH method

@ghost ghost added the ⛲️ feature New addition or enhancement to existing solutions label Jun 18, 2018
@martijnwalraven
Copy link
Contributor

Thanks, this looks great! The new Params typing won't work as is because we use Object.keys(params).length > 0 to check whether to append the params. I'll change this, and also extract a URLSearchParamsInit as part of the URL type definitions, so we don't have to duplicate typings.

@martijnwalraven martijnwalraven merged commit 86fd88e into apollographql:version-2 Jun 19, 2018
@martijnwalraven
Copy link
Contributor

I ended up defining URLSearchParamsInit to take Object as values instead of string because I wanted to allow implicit coercion from numbers and booleans. That at least seems to be defined behavior for Node, not entirely sure about the WHATWG standard.

I also added any as a default type parameter for TResponse, to keep the existing behavior and not force people to specify a result type.

@fabien0102
Copy link
Contributor Author

@martijnwalraven Nice! Thank you for your support and your reactivity 💯

@fabien0102 fabien0102 deleted the datasource-rest/improve-types branch June 20, 2018 05:45
@evans evans mentioned this pull request Jun 21, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⛲️ feature New addition or enhancement to existing solutions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants