-
Notifications
You must be signed in to change notification settings - Fork 1
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
feature: Adds collections & uploads Apollo to version 3 #455
Conversation
@@ -129,18 +129,8 @@ export const Home = screenTrack()(({ navigation, route }) => { | |||
if (!isFetchingMoreFitPics && fitPicsReceived > 0) { | |||
fetchMore({ | |||
variables: { firstFitPics: 8, skipFitPics: fitPicsReceived }, | |||
updateQuery: (prev: { fitPics: Homepage_fitPics[]; fitPicsCount: any }, { fetchMoreResult }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateQuery
is going to be deprecated next major release, this PR updates the homepage to use the new cache merge function as an example.
@@ -112,25 +111,12 @@ export const setupApolloClient = async () => { | |||
} | |||
}) | |||
|
|||
const accessToken = await getAccessTokenFromSession() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already storing the useSession in the context provider, no need for it in the cache layer
src/Apollo/index.ts
Outdated
typePolicies: { | ||
Query: { | ||
fields: { | ||
fitPicsCount: { | ||
read(newCount) { | ||
return newCount | ||
}, | ||
}, | ||
fitPics: offsetLimitPagination(), | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new method for updateQuery
- updating the query directly in the cache instead of calling updateQuery
}) | ||
const httpLink = new HttpLink({ | ||
uri: process.env.MONSOON_ENDPOINT || "http://localhost:4000/", // Server URL (must be absolute) | ||
}) as any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should figure out the proper types for this
}, | ||
fitPics: { | ||
merge(existing = [], incoming = [], { args: { skipFitPics = 0 } }) { | ||
const merged = existing ? existing.slice(0) : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kierangillen Do we actually need to do this for every paginated query? seems a bit odd they would add that much complexity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is the new method for handling merging arrays now that updateQuery
is deprecated: https://www.apollographql.com/docs/react/caching/cache-field-behavior/#merging-arrays
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here's a helpful blogpost as the Apollo docs are out of date: https://www.apollographql.com/blog/announcing-the-release-of-apollo-client-3-0/?mc_cid=e593721cc7&mc_eid=235a3fce14
@@ -48,7 +48,7 @@ export const Bag = screenTrack()((props) => { | |||
}, []) | |||
) | |||
|
|||
const { data, refetch } = useQuery(GET_BAG) | |||
const { previousData, data = previousData, refetch } = useQuery(GET_BAG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's that about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more info on the issue and fix: apollographql/apollo-client#6603
I brought it up in slack too: https://seasonsnyc.slack.com/archives/CMJE9QVA5/p1611168937010600
…ure/collection-rail
Collections
from Eclipse