Hopefully an Apollo question is ok... Does `client...
# orm-help
l
Hopefully an Apollo question is ok... Does `client.query`โ€™s result update the cache? I have a query to get the current user, e.g.
const USER = gql'{ user { id name email ] }'
on a component. On login, the login component refires the same query manually
client.query({ query: USER })
but the original component never updates. The Apollo cache shows the changed User. Any ideas?
๐Ÿ‘ 1
w
You need to force it over the network
fetchPolicy: โ€˜network-onlyโ€™
I think its network-only
l
Crap. I hoped that wasn't the answer.
Thank you!
np!
l
Oh I see, in the client.query. Got it!
Thank you!
w
๐Ÿ™‚
n
why did you hope that wasn't the answer, @lawjolla?
l
@nilan I wasn't thinking clearly.. I thought I'd need to put the fetch policy of
network-only
on the components. But requiring it on the client.query works great and makes sense. It was simply fetching from the cache. Duh ๐Ÿ™‚
๐Ÿ’ก 1
t
@nilan prob embarassed it was so simple? @lawjolla no question is a bad question.....except maybe "whats the difference between graphcool and prisma?" at this point... ๐Ÿ™„
n
It's quite a dated discussion, but you might find some valuable thoughts here, @lawjolla: https://www.graph.cool/forum/t/react-hoc-to-check-for-authorized-user-protected-routes/478?u=nilan
l
Thanks @nilan! The problem with most of the current examples is they don't get into actual app architecting. For instance, if I want a component that displays "Sign In" for unauthed users or a user chip for signed on users, it's not clear with Apollo if you should put data fragments with each component -- relay style -- or run the same massive query on all components needing a type. And then when another component logs in, how should that be transmitted to the listening components? That's why I'm really excited to see how Wes tackles these difficult, non trivial problems. The answers are out there but not in educational form -- you have to dig into a massive code base. I'm not good enough to do that.
๐Ÿ‘Œ 1
n
I think we all are excited about that course ๐Ÿ™‚
parrotwave6 1
w
๐Ÿ™‚
<PleaseSignIn>
๐Ÿ˜Ž 1
The beauty of Apollo is that you can wrap tons of components in that query, and when one updates with the newly logged in user, the rest of them do
l
That's awesome! Thank you. I've adopted that pattern, but it felt/feels dirty when components that don't need certain data still get it. For instance,
<PleaseSignIn>
asks for a list of orders. Makes me anxious. I just need someone to tell me "no, it's ok. It'll all work out." ๐Ÿคฃ
๐Ÿ˜„ 1
w
hah yah
I just think o it as a reference to the client cache, not the data itself
n
last commit message:
Death to index
haha
w
lol I canโ€™t use too many index files in my courses because poeple get so confused
l
That's true. But I get this "trivial components are going to conspire to fire giant ugly queries in the middle of the night" sweat ๐Ÿ™‚
๐Ÿ˜„ 1