Hi everyone! I set up an angular project yesterday...
# prisma-whats-new
e
Hi everyone! I set up an angular project yesterday using subscription. But i could only find documentation for how to set it up with react. Do you have any documentation on subscriptions with angular? (btw, i couldn’t even find documentation of subscriptions in the official apollo documentation for angular - but it works hehe)
n
@emilrmoeller I also tried to find more information here but did not manage to - found this example though: https://github.com/kamilkisiela/angular-graphql-subcriptions/blob/master/src/app/app.component.ts#L42-L64
e
Ah nice I didn’t find that one! Saved! I ended up using the typescript types to find the subscription interface hehe. But it does work flawless and I was able to make it all work in the end based on your react subscription example 🙂
n
@emilrmoeller Awesome! Could you give us some pointers how to upgrade our angular subscription example here? https://github.com/graphcool-examples/angular-graphql/blob/master/subscriptions-with-apollo/src/app/feed.component.ts currently we just do a generic subscription and do a refetch then
e
Thats a pretty neat trick with the refetch! I might use that for some components. What would you update it for? So you would use the data which is returned from the subscription and not do the refetch ?
n
yes, exactly!
this is more elegant than doing a generic refetch haha
e
Hehe yeah it is 🙂 I think kamilkisiela’s solution is pretty great!
Copy code
this.posts.updateQuery((prev) => {
        const allPosts = prev.allPosts || [];

        return {
          ...prev,
          allPosts: [...allPosts, data.Post.node]
        };
      });
n
haha oh man
of course, I just sent it to you and did not make the link myself 😄
e
Then there’s the initial request getting the data on init and then this pushes the data to the same store instead of having a parallel store
Haha yeah 😄
n