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

Trouble with subscriptions #286

Open
Eskpil opened this issue Dec 26, 2020 · 3 comments
Open

Trouble with subscriptions #286

Eskpil opened this issue Dec 26, 2020 · 3 comments

Comments

@Eskpil
Copy link

Eskpil commented Dec 26, 2020

Hey, i am trying this package out. I got queries and mutations to work, but i have some trouble with subscriptions. Here is the code i am using to test:

client.graphql .runSubscription(subscription { prefixChanged {
id
prefix
}}
).subscribe({ next: (res) => console.log(res.data), error: (error) => console.error(error), complete: () => console.log("done"), });

@Eskpil
Copy link
Author

Eskpil commented Dec 26, 2020

oh sorry, the ticks in my subscription messes up the codeblock. Let me know if it is hard to understand

@moritzmyrz
Copy link

Maybe make the code a little bit clearer to read.

@ruge0326
Copy link

ruge0326 commented Jun 30, 2021

I have the same issue with subscriptions. It is like doesn't work. No error message, no data results.

import { GraphQLClient } from 'kikstart-graphql-client';

;(async ()=> {

    const client = new GraphQLClient({
      url: 'http://192.168.0.X:8088/v1/graphql',
      wsUrl: 'ws://192.168.0.X:8080',
      headers: {
        'x-hasura-admin-secret':  'XX'
      }
    })

   const subscribe =  await client.runSubscription(
    `
    subscription ContractMappings {
      mappings {
        api_user_id
        contract_name
        mapping
      }
    }   
  `,
    {},
  )
   
  subscribe.subscribe({
      next: res => console.log(JSON.stringify(res.data.statusSubscription, null, 2)),
      error: error => console.error(error),
      complete: () => console.log('done'),
   })

})()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants