altair-graphql / altair

✨⚡️ A feature-rich GraphQL Client for all platforms.
https://altairgraphql.dev
MIT License
5.14k stars 324 forks source link

Subscription endpoint only path (not URL) #1913

Closed ssukienn closed 2 years ago

ssukienn commented 2 years ago

Is your feature request related to a problem? Please describe. I would like to only setup the subscriptionsEndpoint path in the express middleware config, not the full URL. Similarly to endpointURL where I can do it.

Describe the solution you'd like Maybe next option that would expect only the path i.e /subscriptions? I thinkthe usage Endpoint/URL in this case might be confusing. What I would expect is with that option the URL is taken from normal request URL and subscriptions path would be glued to it so with regular endpoint like: https://app.service.top:3000/graphql subscriptions would become https://app.graphy.top:3000/subscriptions and would be preset in the Subscriptions URL config.

Describe alternatives you've considered Staying with the single config option but in case of the parameter passed being only path (like /subscriptions) not full fledged URL spec compliant it would automatically assume to use regular request URL (minus /graphl ofc).

Additional context It is possible that maybe I miss something here.

imolorhe commented 2 years ago

I think for subscriptions it is a bit different since the protocol can also be different. i.e. it could be https://app.graphy.top:3000/subscriptions or wss://app.graphy.top:3000/subscriptions but there is no way to tell which if we only accept the path and not the full URL

ssukienn commented 2 years ago

Hmm that's true, what about if the domain still match and protocol could be choosen? Either http(s)/ws(s) etc.

imolorhe commented 2 years ago

So we would have an extra option for subscriptionProtocol?

ssukienn commented 2 years ago

Yes, like this or generally something shaped more into connection url object like configuration?

Btw, I made mistake in issue description. From the beginning I had in mind switching protocol for subscriptions but it is true that it does 't have to be wss always