Hey there <@U36DH5AHE>! Thanks for the welcome. G...
# prisma-whats-new
s
Hey there @artyom! Thanks for the welcome. Glad to be trying out Graphcool, very exciting stuff. I’m running into a first issue. Trying to play with a subscription that automatically updates in an Angular 4 app. I’m trying to use v0.5.4 of subscriptions-transport-ws and getting errors about tag/printer. In the Graphcool Angular demo app it’s using Client from that package, but it looks like it was renamed to SubscriptionClient if I’m correct. I realize that this may not have anything to do with Graphcool though. Just throwing it out there in case someone has an easy fix. Also looking to see if there any docs to integrate auth0 into an Angular 4 app.
a
@sebastien let’s see what’s going on! @nilan ?
n
it’s using Client from that package, but it looks like it was renamed to SubscriptionClient if I’m correct
yea you're right @sebastien! 🙂 what's the exact error message? maybe @kamil can help you out with that
s
Here’s the error I’m getting:
Copy code
ERROR in ./~/subscriptions-transport-ws/dist/helpers.js
Module not found: Error: Can't resolve 'graphql-tag/printer' in '/Users/metal/Desktop/meal-plan-generator/meal-plan-generator-app/node_modules/subscriptions-transport-ws/dist'
 @ ./~/subscriptions-transport-ws/dist/helpers.js 2:16-46
 @ ./~/subscriptions-transport-ws/dist/client.js
 @ ./src/app/home/home.component.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?<http://localhost:4200> ./src/main.ts
Googled around and some people mention an issue with Typings, but not really finding a fix or anything.
Here’s also my code, in case it’s me that’s doing something wrong:
Copy code
ngOnInit() {
    const queryObs = this.apollo.watchQuery({
      query: gql`
        query allPosts {
          allPosts {
            id
            content
          }
        }
      `
    });

    this.allPostsSub = queryObs.subscribe(({data, loading}: any) => {
      this.posts = data.allPosts;
      this.loading = loading;
    });

    const wsClient = new SubscriptionClient('<ws://subscriptions.graph.cool/cj1cd3wb70zy80113yybu3gux>', {
      timeout: 10000
    });

    wsClient.subscribe({
      query: `subscription {
        allPosts {
          id
          content
        }
      }`,
      variables: null
    }, (err, res) => {
      queryObs.refetch();
    });
  }
And everything is working fine if I remove the subscription part.
Thanks so much for any help with this by the way, it’s really appreciated!
n
could you update to the latest apollo-client and react-apollo versions? Then you can also throw out graphql-tag and use {gql} from react-apollo instead
s
I’m using Angular actually, so is it the same thing but with angular-apollo instead? Already using the latest version of apollo-client.
n
Ohhh right. I can't say, but updating the versions is always a good idea.
it's worth a shot
s
Ok, I’ll try that!
n
Cheers, let me know how it goes @sebastien
k
@sebastien
subscriptions-transport-ws
since v0.5.4 is no longer using
graphql-tag/printer
internally so by updating the package to 0.5.4 (not 0.5.5-alpha*) will help
@sebastien Also... If you're using
graphql-tag/printer
but I don't think you do, try to use
graphql/language/printer
instead
s
Thanks so much @kamil, I’ll try that! I was about to give up on making subscriptions work for now, but that just gave me hope.
🦜 1