Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with passing websocket connectionParams between a few endpoints. #1759

Closed
Devlin556 opened this issue Oct 2, 2018 · 2 comments
Closed

Comments

@Devlin556
Copy link

Devlin556 commented Oct 2, 2018

I have troubles with passing a connectionParams for graphql-subscriptions between two or more endpoints. I use Apollo-Server 2 and Apollo-Link-WS 1.0.9. I use a microservice architecture with apollo stack and schema stitching. I have a few graphql-endpoints and a gateway for all requests and I'm stuck with passing connectionParams for subscriptions from gateway-endpoint to graphql-endpoint.
How can I pass connectionParams or subscription-context per each subscription execution to endpoint which is connected with gateway by the apollo-link? It's needed for access control and authentication in subscriptions.
Below I attached code with a gateway connecting to an endpoint.

const hasSubscriptionOperation = args => args.query.definitions.some(
  ({ kind, operation }) => kind === 'OperationDefinition'
      && operation === 'subscription',
);

const httpLink = new HttpLink({ uri, fetch });
  const wsLink = new WebSocketLink({
    uri: `${uri}${'/subscriptions'}`,
    options: {
      timeout: 30000,
      reconnect: true,
    },
    webSocketImpl: ws,
  });

const splittedLink = ApolloLink.split(hasSubscriptionOperation, wsLink, httpLink);

const schema = await introspectSchema(splittedLink)
@ghost ghost added the 📝 documentation Focuses on changes to the documentation (docs) label Oct 2, 2018
@micksi
Copy link

micksi commented Jan 30, 2019

I'm having the exact same problem and have tried different approaches. Most recently this https://gist.github.com/josephktcheung/cd1b65b321736a520ae9d822ae5a951b but managing websockets like that with multiple endpoints doesn't seem like the most appropriate way.
So I'm still looking for a solution to this problem...

@abernix abernix added tag: subscriptions and removed 📝 documentation Focuses on changes to the documentation (docs) labels Jul 4, 2019
@glasser
Copy link
Member

glasser commented Oct 3, 2022

Direct subscriptions integration was removed from Apollo Server in v3 last year.

@glasser glasser closed this as completed Oct 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants