Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Subscription Example #315

Open
nhjk opened this issue Sep 13, 2019 · 3 comments
Open

Subscription Example #315

nhjk opened this issue Sep 13, 2019 · 3 comments

Comments

@nhjk
Copy link

nhjk commented Sep 13, 2019

Is there an example or documentation on how to do subscriptions?

@mesameen
Copy link

I'm too looking for it

@tabvn
Copy link

tabvn commented Jul 12, 2020

+1

@amonks
Copy link
Contributor

amonks commented Feb 17, 2021

here is a small example

import { Connection } from "thunder-react";    // thunder-react is the "client" directory in samsarahq/thunder

async function connectFunction () {
  return new WebSocket("ws://localhost");
}

const connection = new Connection(connectFunction);

function observer(data) {
  console.log("got data", data);
}

const query = `
  query SomeQuery($parameter: int64!) {
    someField(parameter: $parameter)
  }
`;

connection.subscribe({
  observer,
  query,
  variables: { argument: 1 },
})

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