Comments (7)
It's hard to tell anything here without seeing what exactly you did - please show us some code :)
Also, how did you measure this speed increase? Is this in RSC, SSR or in the Browser? How big is your response?
I think we'll generally need a bit more context here :)
from apollo-client.
We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you!
from apollo-client.
Here is some code.
It is pretty self explanatory though. Switch Apollo-CLient to use cross-fetch.
Here -
import fetch from 'cross-fetch';
export const client = (
showError: (str?: string) => void = (_str?: string) => {}
) =>
new ApolloClient({
defaultOptions,
link: from([
authLink,
retryLink,
errorLink(showError),
createHttpLink({
uri: process.env.NEXT_PUBLIC_GRAPHQL_URL,
fetch,
}),
]),
cache,
});
from apollo-client.
@billnbell2 appreciate the code, but I'm not sure what you're looking for from us?
from apollo-client.
Why do I need to use cross-fetch ?
If I leave it the default it takes Apollo Client 1-2 seconds per calls, when I use cross-fetch we are consistently at 200ms. Same exact call.
from apollo-client.
Can you try it yourself and see if you get similar perf gains?
from apollo-client.
You are absolutely free to use whatever fetch
implementation works for you. We're just using the built-in global fetch
function available in your environment.
The only thing I can think might be happening here is that perhaps something is patching fetch
in your environment and causing the perf issues on your end. Your code sample implies you're using Next.js which does fetch
patching to add cache behavior to it. In fact, this was something that was recently reverted in React itself. Perhaps you're running into something here?
To be honest, even if this weren't it, we wouldn't make any current changes as using the global fetch
function means we don't need additional dependencies which adds bundle size. Again, feel free to use cross-fetch
if you'd like instead. I'd start however by taking a look at your global fetch
function to see if there is something patching it first. You might be able to avoid the cross-fetch
dependency yourself if need be. You can find out more about how Next.js patches it in their docs.
from apollo-client.
Related Issues (20)
- Potentially unintentionally large AoE breaking changing to typescript `MockedResponse` in type 3.9 HOT 4
- clearStore causes a crash when there is an active query HOT 3
- Getting A on the result.data HOT 2
- BatchHTTPLink is not monitoring friendly HOT 6
- Support extensions in useSubscription HOT 1
- React functionality 'useContext' is not available in this environment [Nextjs app] HOT 4
- Subscription doesn't deduplicate HOT 6
- Types `cache.modify` and `writeFragment` lead to TypeScript errors for documented Apollo examples when specifying generic parameter HOT 1
- SOLVED : TypeError: Cannot return null for non-nullable field Subscription: Next.js frontend + FastApi backend HOT 3
- NextJS with "useSuspenseQuery" not passing headers to request HOT 4
- Using @defer in a query on a field which was previously queried creates a cache hit, when it should be a miss HOT 1
- Custom ApolloLink using `next.subscribe` is making duplicated requests HOT 9
- Adding graphql-tag-swc-plugin to performance docs for apollo client HOT 4
- (Batch)HttpLink Uncaught (in promise)DOMException: signal is aborted without reason HOT 6
- Typeguard for useQuery fails when the queryOptions passed using spread operator HOT 4
- Can you use `useFragment` with a type that doesn't have an id? HOT 4
- refetch does not return cached data HOT 5
- PossibleTypes not working as intended HOT 4
- Infinite network requests with non-normalized objects HOT 3
- fetchMore not hitting onError and causing an infinite loop of queries HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-client.