mattkrick / cashay

:moneybag: Relay for the rest of us :moneybag:
MIT License
453 stars 28 forks source link

Question: multiple auth credentials #135

Open jordanh opened 7 years ago

jordanh commented 7 years ago

Imagine as though you wanted to make a Slackbot. Let's assert folks using the Slackbot go through a step to store their unique authentication credentials (i.e. a JWT token) with the Slackbot so that when it interacts with the service that feeds the Slackbot data, it does so with their identity.

Now, imagine as though to implement this Slackbot one wanted to use Cashay—in part because the API the Slackbot wishes to interact with behind the scenes is a GraphQL API, but also because Cashay's pub/sub pattern and redux bindings make for a wonderful foundation for building a stateful bot.

Presently Cashay.js exports a singleton like:

export default new Cashay();

If I wanted to use Cashay to implement this Slackbot, I think I'd need to create and track multiple Cashay instances (one per set of user authentication credentials), right? Could the cashay module export the class definition so I can create new instances myself?

Is there another pattern I should consider?

mattkrick commented 7 years ago

cashay.query({transport: myTransport}).

But I don't get it. Cashay is for the client. Why would one client have many auths?

jordanh commented 7 years ago

I'm exploring using Cashay more generally as a GraphQL client embedded within a micro-service. In this case, a server that implements a chatbot. Let's talk about it!

mattkrick commented 7 years ago

I'll be back at the desk in about an hour, let's chat then. I've got no clue what a client side microservice looks like!

On Oct 31, 2016 11:11 AM, "Jordan Husney" notifications@github.com wrote:

I'm exploring using Cashay more generally as a GraphQL client embedded within a micro-service. In this case, a server that implements a chatbot. Let's talk about it!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mattkrick/cashay/issues/135#issuecomment-257373711, or mute the thread https://github.com/notifications/unsubscribe-auth/AFQjv8d7z-gqjaySTvPOWOs7NR3e49Hnks5q5i9OgaJpZM4KkiZa .