Giter VIP home page Giter VIP logo

Comments (9)

 avatar commented on August 28, 2024

Is there any progress on this topic? I would love to use this enhancement :)

from datasource-rest.

shipraguptaa avatar shipraguptaa commented on August 28, 2024

Is there any update on this? I also need to make HEAD method request using RESTDataSource but there is no support for that.

from datasource-rest.

shipraguptaa avatar shipraguptaa commented on August 28, 2024

@abernix Any update?

from datasource-rest.

devdudeio avatar devdudeio commented on August 28, 2024

it’s not the best solution but if you need a fast solution just use fetch and do a HEAD request

from datasource-rest.

Phoenix1405 avatar Phoenix1405 commented on August 28, 2024

@abernix Any update on this? We recently ran into this issue.

from datasource-rest.

abernix avatar abernix commented on August 28, 2024

I don't have the precise answer as to the exact "why", but I could certainly believe that the omission of HEAD from the original implementation was because it wasn't fully realized that there was much in the way of data to be retrieved from such an endpoint (that doesn't return a body).

That said, data obviously comes in various forms and it's entirely possible to return certain valuable data as header values, so I think the need resonates with me too.

Thanks for opening the pull request, @Phoenix1405.

from datasource-rest.

devdudeio avatar devdudeio commented on August 28, 2024

I just passed the header into my returned data as a symbol

from datasource-rest.

kettanaito avatar kettanaito commented on August 28, 2024

I believe HEAD requests can also compute data, just not return a body. That can be cached with RESTDataSource, so the addition of the HEAD method is quite practical.

from datasource-rest.

trevor-scheer avatar trevor-scheer commented on August 28, 2024

Ok, having familiarized myself with HEAD semantics I feel prepared to discuss this and propose a couple options.

  • HEAD bodies in responses must be ignored, meaning all of their useful data exists in the response headers. They ought to be treated as a GET request with no response body.
  • RESTDataSource in its current form doesn't expose the response object (just the parsed body) in its return value of fetch or the helper "http method" methods.

Based on this information, I'm going to assume people want access to the response headers when the make a HEAD request (else it's just an empty string). AFAICT, @Phoenix1405's PR mentioned above did not address this. I'm really not sure how useful this API addition can be otherwise, though.

I propose 2 possible options (with the option of 1, then later 2):

  1. Add a head method which breaks convention from the other convenience methods, i.e. it does not return a parsed body and instead returns either the whole response object or just its headers. This will result in some additional internal complexity around HEAD being special (i.e. the fetch method will have 2 different return types and have to look for HEAD, etc.). It also creates an inconsistency in the API (making it unique among the other convenience methods).
  2. In a breaking change to the API, start returning additional data in the convenience methods (either the whole response object alongside a parsed body or something similar, but at a bare minimum the headers as well).

I'd be interested in hearing input on these options from anyone on this thread. I'm leaning towards 2 myself since it offers a more robust and consistent API.

from datasource-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.