fauna / fauna-js

Javascript driver for Fauna v10 (current)
https://fauna.com
Other
37 stars 7 forks source link

Extend HTTPRequest to support path overrides #288

Closed ecooper closed 2 months ago

ecooper commented 2 months ago

This PR extends the existing HTTPRequest to take an optional path to support POST requests to endpoints other than /query/1.

Description

We'll need to support requests to Fauna APIs beyond /query/1. Today, this API path is hardcoded in both the fetch and http2 client wrappers. This PR does the following:

Motivation and context

We need to support more endpoints in this driver. The current http clients really only have a fixed concept of requesting queries or streaming. This change allows for a backwards compatible way to introduce providing a path without breaking existing code or interfaces.

Alternatives considered:

In the future, we may want to reconsider redesigning these interfaces in a major version bump, but that is out of scope for this PR.

Definitely open the other implementation approaches!

How was the change tested?

These changes have dedicated unit tests. The unit tests validate the override logic as well as type enforcement.

Because these changes are backwards compatible, all existing code and tests should work as expected.

Screenshots (if appropriate):

N/A

Change types

Checklist:


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

ecooper commented 2 months ago

i'm ok with this path forward (and with a major version bump that moves these to obj args as well).

how much blast radius is there in the docs site if we make a breaking change in these?

Because these are largely internals they are really only covered by the docs that are auto-published here: https://fauna.github.io/fauna-js/2.2.0/