From cd2053f2dde16c28765fc974d6c5c303821012a9 Mon Sep 17 00:00:00 2001 From: Nikola Bjelo Date: Mon, 5 Nov 2018 16:07:32 +0100 Subject: [PATCH 1/3] Correcting the userId fetching to avoid possible loops --- server/src/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/index.js b/server/src/index.js index 0ef91a3a2..aed90211f 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -18,12 +18,15 @@ async function getUserId (authId) { } const userData = await axios({ - url: process.env.GRAPHQL_API_URL, + url: process.env.USERS_API_URL, method: 'post', + headers: { + preshared: USERS_API_PRESHARED + }, data: { query: ` { - users_UserByAuthId(authId: "${authId}") + userByAuthId(authId: "${authId}") { id } @@ -31,7 +34,7 @@ async function getUserId (authId) { ` } }) - return userData.data.data.users_UserByAuthId.id + return userData.data.data.userByAuthId.id } catch (error) { return (error) } From f889f6c93c9cde5f61f12b0e6ed9bbe453864c9a Mon Sep 17 00:00:00 2001 From: Nikola Bjelo Date: Mon, 5 Nov 2018 18:44:02 +0100 Subject: [PATCH 2/3] typo on last commit --- server/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/index.js b/server/src/index.js index aed90211f..1c7549d00 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -21,7 +21,7 @@ async function getUserId (authId) { url: process.env.USERS_API_URL, method: 'post', headers: { - preshared: USERS_API_PRESHARED + preshared: process.env.USERS_API_PRESHARED }, data: { query: ` From 59669f23e73eb1973993d67c18761ced0e6a482b Mon Sep 17 00:00:00 2001 From: Nikola Bjelo Date: Tue, 6 Nov 2018 04:15:17 +0100 Subject: [PATCH 3/3] Setting "cache-and-network" as default fetch policy --- client/src/graphql/apollo.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/src/graphql/apollo.js b/client/src/graphql/apollo.js index cbe378fba..006367f4d 100644 --- a/client/src/graphql/apollo.js +++ b/client/src/graphql/apollo.js @@ -73,8 +73,23 @@ const authLink = setContext((_, { headers }) => { const cache = new InMemoryCache().restore(window.__APOLLO_STATE__) +const defaultOptions = { + watchQuery: { + fetchPolicy: 'cache-and-network', + errorPolicy: 'all' + }, + query: { + fetchPolicy: 'cache-and-network', + errorPolicy: 'all' + }, + mutate: { + errorPolicy: 'all' + } +} + export const client = new ApolloClient({ link: ApolloLink.from([authRetryLink, authLink, httpLink]), // replaced link with httpLink cache, + defaultOptions, connectToDevTools: true })