question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to use subscription without query?

See original GitHub issue

I try to create react component, which uses only one subscription, no query. But If I do not add a query to component I do not have access to subscribeToMore fn.

Is there any way (sample) how to use subscription without query? All tutorials use a subscription with query.

As a workaround, I add dummy query to component and it looks like it works

Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
nascodecommented, Nov 30, 2017

Hi @goldo i used v2 and found the way to get subs directly without subscribeToMore. Make sure your apollo-link-ws and subscriptions-transport-ws is uptodate.

For example, here is one of my component:

const StreamAddedSubs = graphql(subsOnStreamAdded)(
  class extends Component {
    componentWillReceiveProps({
      data: { data: { onStreamAdded: newStream } }
    }) {
      console.log("STREAM ADDED SUBS", newStream);
    }

    render() {
      return null;
    }
  }
);

IMHO, using subs without subscribeToMore should be added to official doc to avoid confusion.

6reactions
kaanozcancommented, Jan 25, 2018

Hello @jbaxleyiii @nascode Do you happen to know how to unsubscribe this way? I am currently querying fake data to be able to unsubscribe on demand using the returned method of subscribeToMore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subscriptions - Apollo GraphQL Docs
In the majority of cases, your client should not use subscriptions to stay up to date with your backend. Instead, you should poll...
Read more >
GraphQL Subscriptions vs. Live Queries - Medium
There are two common ways to get live data from a GraphQL server: Subscriptions and Live Queries. A Subscription looks like this:
Read more >
Subscriptions and Live Queries - Real Time with GraphQL
GraphQL subscriptions are used by many. Live Query adoption, however, has not advanced that much. Let's take a look at both methods for ......
Read more >
How GraphQL Subscriptions Work: Tips, Best Practices and ...
Subscriptions use WebSocket for communication, not the normal POST method queries and mutations use. Subscriptions maintain an active ...
Read more >
How GraphQL Subscriptions Work - Dgraph
Subscriptions are similar to queries in that they specify a set of fields to be delivered to the client, but instead of immediately...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found