CargoSense / absinthe_client

A GraphQL client designed for Elixir Absinthe.
https://hexdocs.pm/absinthe_client
MIT License
74 stars 7 forks source link

Refactor to more fully embrace the Req API #5

Closed mcrumm closed 2 years ago

mcrumm commented 2 years ago

After evaluating some of the other Req plugins in the wild I decided that the run functions and the request steps added far too much accidental complexity.

Specifically, we can remove the pass-thru run functions and let the user invoke the equivalent Req function of their choosing. This change puts the user back in charge of the type of request they are performing and allows AbsintheClient to stop being prescriptive about some choices.

This refactor composes the following changes:

In a change similar to the AbsintheClient refactor, we are no longer providing a pass-thru function to perform a subscription operation. Instead, users must use Req.request/2 and the :web_socket option.

To simplify the process of starting a WebSocket and using it with a Request, WebSocket.connect/2 accepts a request and returns a request configured to perform operations over a WebSocket.

Taken together, these changes are designed to provide more clarity around what options are used to start the WebSocket, when the WebSocket starts, and which WebSocket process will handle a given request.

Additionally WebSocket.push/3 is now WebSocket.push/2 and it accepts a graphql arg in the same shape as the Request option– either a String.t() or a {String.t(), nil | map()} tuple.