Questions tagged [graphql-subscriptions]

GraphQL subscriptions are a way to push data from the server to the clients that choose to listen to real time messages from the server.

In addition to fetching data using queries and modifying data using mutations, the GraphQL spec supports a third operation type, called subscription.

Subscriptions in GraphQL and Relay

Subscriptions in GraphQL and Apollo

280 questions
6
votes
0 answers

How can I handle disconnect event using graphql-subscriptions

I am using graphql-subscriptions to manage session (rooms). I have simple application like "chat". I can send message to chat using: import { PubSub } from 'graphql-subscriptions'; ... pubSub.publish(triggerName, payload) I can listen to…
ciyada8549
  • 61
  • 4
6
votes
2 answers

How do I make GraphQL subscriptions in NodeJS via Apollo Client?

I want to make a subscription to a GraphQL server. The application is running in a NodeJS script (i.e. not in the webbrowser). Here is what I currently do: const fetch = require("node-fetch").default; const apollo = require("apollo-boost"); const…
AUser
  • 171
  • 1
  • 7
6
votes
0 answers

Allow subscription to return initial data of an entity

I need a subscription to return initial state of a requested type. I have tasks system in my app, a task may have multiple states: CREATED, QUEUED, RUNNING, COMPLETED, CANCELLED, CANCELLING etc. When a task is created, it has CREATED state and…
Mihail
  • 618
  • 5
  • 16
6
votes
0 answers

React Apollo - subscribeToMore / updateQuery updates propagating erroneously

A strange scenario with GraphQL. Let's say there is a Subscription called postIsRead, which signifies a post in a list of posts as currently being read, such as: Post: { id: 1, read: true } Only one post can be read at once. When a user clicks…
6
votes
3 answers

How to use subscriptions-transport-ws with passport and express-session

I'm using a passport local strategy that works well with express: passport.use(localStrategy); passport.serializeUser((user, done) => done(null, JSON.stringify(user))); passport.deserializeUser((obj, done) => done(null,…
6
votes
1 answer

React Apollo first object from subscription not being merge into previous data it actually gets removed

I have a query which gets me a list of notes and a subscription which listens and inserts new notes by altering the query. However the problem is the first note doesn't get added. So let me add more detail, initially the query response with an…
Jake Lacey
  • 623
  • 7
  • 24
5
votes
1 answer

Can I connect to a GraphQL Subscribtion using Insomnia REST client?

Insomnia now supports WebSockets. Therefore I was hoping that I can also use it to test GraphQL Subscriptions, since they are also using WebSockets. I created a GraphQL request to open a new Subscription, but I always get the following response: { …
eddex
  • 1,622
  • 1
  • 15
  • 37
5
votes
0 answers

Unhandled GraphQL subscription error, when using apollos subscribeToMore method in an angular chat component for subscription

Problem Description I have a chat component in angular that gets messages from the backend via a graphql query. On the same query, I subscribe to updates when a new message is added via a graphql mutation. The messages subscription is coded as a…
5
votes
2 answers

Apollo Subscriptions: Apollo Graphql is receiving updates on Playground but not on client

I'm using react on Apollo GraphQL subscriptions and I can receive updates on Apollo Playground but not on Client. Here is the response on the Apollo Playground: Graphql Server is on http://localhost:4000/ and subscriptions on…
Ilyas karim
  • 4,592
  • 4
  • 33
  • 47
5
votes
1 answer

How to change websocket url in graphql-playground (subscriptions)

I wanted to change the graphql websocket end point inside graphql, anyone know how to do this? by default it pings wss://localhost/graphql I need to change it to pusher url thanks :-)
Jagadesha NH
  • 2,529
  • 2
  • 23
  • 41
4
votes
1 answer

nestjs graphql subscription how to get context/pass data to resolver or interceptor?

I'm trying to use NestJS subscriptions, I have tried both graphql-ws and subscriptions-transport-ws. I have a very basic use case -- an interceptor to take the authorization header and then set the user object on the connection or request object to…
SebastianG
  • 8,563
  • 8
  • 47
  • 111
4
votes
1 answer

Apollo subscriptions - Nextjs - Error: Observable cancelled prematurely at Concast.removeObserver

I am trying to use apollo/graphql subscription in my nextjs project, my graphql server is placed in external nextjs service,I can work with queries and mutation without any problem but when I use an implementation of useSubscription I get the…
rrios
  • 41
  • 5
4
votes
1 answer

Improve Hasura Subscription Performance

we developed a web app that relies on real-time interaction between our users. We use Angular for the frontend and Hasura with GraphQL on Postgres as our backend. What we noticed is that when more than 300 users are active at the same time we…
Flowmerca
  • 165
  • 1
  • 5
4
votes
0 answers

Apollo iOS GraphQL Subscription Error: "Invalid HTTP upgrade"

I'm trying to get a GraphQL subscription from SoundtrackYourBrand working within my iOS app. The queries/mutations work fine but when I use the web socket I get either error 400 or 403 ("Invalid HTTP upgrade") or 1011 (no message) depending on how…
4
votes
0 answers

Running Subscriptions on GraphiQL using express-graphql, graphql, graphql-subscriptions and graphql-subscriptions-ws

I'm fairly new to GraphQL and currently familiarizing myself by making a quiz application using React on the front-end. At the moment, I'm busy with my back-end. After successfully setting up queries and mutations, I am finding it difficult to get…
1
2
3
18 19