Use persisted queries in dev, bc Next.js support
We had previously configured the client to not bother to try a GET request for GraphQL queries, and just jump straight to POST instead, because the `vercel dev` server for create-react-app reloaded the backend code for every request anyway, which doubled the dev response time. The Next.js server is more efficient than this, and keeps some memory, so GET requests work similarly in dev as on prod now! (i.e. it fails the first time, but then succeeds on the second) In this change, we remove the code to skip `createPersistedQueryLink` in development, and instead always call it. We simplify the code accordingly, too.
This commit is contained in:
parent
07d54b9a9e
commit
96d6d42120
1 changed files with 5 additions and 13 deletions
|
@ -208,22 +208,14 @@ for (const zone of cachedZones) {
|
||||||
initialCache[`Zone:${zone.id}`] = { __typename: "Zone", ...zone };
|
initialCache[`Zone:${zone.id}`] = { __typename: "Zone", ...zone };
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildLink = (getAuth0) => {
|
const buildLink = (getAuth0) =>
|
||||||
let link = buildAuthLink(getAuth0);
|
buildAuthLink(getAuth0)
|
||||||
if (process.env.NODE_ENV === "production") {
|
.concat(
|
||||||
// In production, we send GET requests for queries, to enable CDN and
|
|
||||||
// browser caching. But in development, we skip it, because our dev server
|
|
||||||
// reloads the route from scratch on each request, so queries never get
|
|
||||||
// persisted, and the GET always fails and falls back to POST anyway.
|
|
||||||
link = link.concat(
|
|
||||||
createPersistedQueryLink({
|
createPersistedQueryLink({
|
||||||
useGETForHashedQueries: true,
|
useGETForHashedQueries: true,
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
}
|
.concat(httpLink);
|
||||||
link = link.concat(httpLink);
|
|
||||||
return link;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apolloClient is the global Apollo Client instance we use for GraphQL
|
* apolloClient is the global Apollo Client instance we use for GraphQL
|
||||||
|
|
Loading…
Reference in a new issue