I have two components. The first one is <Feed /...
# prisma-whats-new
j
I have two components. The first one is <Feed />. The feed queries for all posts in the database. It iterates over each post and returns <Post id={post.id} />. The <Post /> component then queries for the post info based on the postId. I only want the <Post /> component to update live when the data is changed in the query. The <Feed /> have to refetch the data to get the new data. Is this possible?
When some data is mutated in the <Post /> component, it also affects the <Feed /> data, without having to refetch. I don't want this
i
I assume you are using Apollo?
j
Yes, thats right
Check the docs out there
Also, we have a React channel you might be interested in
j
Ah, great Thanks.
The
data.refetch
is what i want the <Feed /> component to do before i get the new data. But right now i get the new data without doing a refetch, beacuse of the mutate in child component <Post />
Copy code
update: (store, { data: { createReaction } }) => {
                        const data = store.readQuery({
                            query: getPost,
                            variables: { id: ownProps.postId }
                        })
                        data.Post.reactions.push(createReaction)
                        const write = store.writeQuery({
                            query: getPost,
                            data
                        })
                    }
I use the
update
property in graphql() when i do mutate in <Post />
Like i said, i only want this to affect the <Post /> and not the parent <Feed /> component
i
Does <Feed /> grab props from <Post />
j
Nope. Feed is the parent that send props to <Post />
But it looks like data is being updated in every component that queries the data i update? Is that right?
i
Hmm… I’m not sure. I’d have to see the code to actually understand it. Sorry 😕
If you create a gist, I can look at it and give you a better answer. I’ve just always sucked at word problems, haha
j
haha, okei. I'll give it a try. Give me 2 minutes. Thanks
i
Sure thing 😄
j
Ok, i tried to strip the code down
What i want is the component <Post /> to have refreshed content, but not the <Feed />, because it will re-order the list.
What i think is happening is that when i do a mutation and update the cache, it affects all components that queries that data
i
I think you’re right but I’ve never really worked with Apollo’s cache, so I wouldn’t be able to tell you a solution
I think they just released a new minor version that’s supposed to dramatically improve the cache or something like that
But I’m not sure on that either 💁
j
Okey, thank you anyway 🙂
i
The react channel may help you more
j
Do you know why the updatedAt property in the database don't update when i add a new relation to a to-many relation?
i
Graphcool Framework or Prisma?
I think someone reported an issue on this in Github
j
Graph Cool cloud, so probably Graphcool Framework?
i
Using the web Console?
j
Yes
i
Ahh, yeah… I don’t know
I use the Framework & Prisma
But I think that issue may help you out
I’ll try to find it
j
👍