Giter Club home page Giter Club logo

Comments (4)

spawnia avatar spawnia commented on August 29, 2024

Can you provide details for an actual use case where headers must be set per request?

from sailor.

spawnia avatar spawnia commented on August 29, 2024

I would like to avoid adding additional arguments to the generated Operation::execute() method, since that could clash with the generated arguments. We could use something like a builder pattern:

MyQuery
    ::withOptions(['headers' => ...])
    ->execute(1, 'asdf');

The actual client implementation is decoupled by an interface though, which currently only requires a single request() method. I wonder how we would extend that, can we have a one-size-fits-all implementation? Do we need to restructure that completely?

from sailor.

mintbridge avatar mintbridge commented on August 29, 2024

Yeah i had a play with adding arguments to Operation::execute() and it got complex real quick. The builder option looks like it could be a nice though, will have a play with that

We use headers for a few things, adding context about the user so that infrastructure can route things, but the main pain point is that we call a downstream graphql endpoint as the user that is logged in an set the authorization header to be the users token

from sailor.

spawnia avatar spawnia commented on August 29, 2024

https://github.com/spawnia/sailor/releases/tag/v0.10.0 solves this.

Dynamic clients

You can configure clients dynamically for specific operations or per request:

/** @var \Spawnia\Sailor\Client $client Somehow instantiated dynamically */
\Example\Api\HelloSailor::setClient($client);

// Will use $client over the client from EndpointConfig
$result = HelloSailor::execute();

// Reverts to using the client from EndpointConfig
HelloSailor::setClient(null);

from sailor.

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.