fauna-js icon indicating copy to clipboard operation
fauna-js copied to clipboard

Add backwards compatible type params for HTTPRequest and HTTPStreamRequest

Open ecooper opened this issue 1 year ago • 0 comments

Data types for HTTPRequest and HTTPStreamRequest are hardcoded today. Because of #288, we need to support generics for data. They default to backwards compatible types.

Description

This PR makes the following backwards compatible changes:

  • HTTPRequest now takes a type parameter that is applied to data. It defaults to QueryRequest.
  • HTTPStreamRequest now takes a type parameter that is applied to data. It defaults to StreamRequest.

Motivation and context

To take advantage of HTTPClient.request against endpoints other than /query/v1, we need to support payloads other than QueryRequest. While we don't have an immediate use case for extending HTTPStreamRequest, I would argue it makes sense to keep the approaches the same across our two primary request types (call/response and streaming).

How was the change tested?

No tests were added for this specific change. If all existing tests pass, this is a safe change. The underlying data types are never referred to or accessed directly within the client.

Screenshots (if appropriate):

N/A

Change types

    • [ ] Bug fix (non-breaking change that fixes an issue)
    • [x] New feature (non-breaking change that adds functionality)
    • [ ] Breaking change (backwards-incompatible fix or feature)

Checklist:

    • [x] My code follows the code style of this project.
    • [ ] My change requires a change to Fauna documentation.
    • [ ] My change requires a change to the README, and I have updated it accordingly.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ecooper avatar Oct 07 '24 21:10 ecooper