Comments (8)
Using skipToken
in that manner will immediately put the query into fetchPolicy: "standby"
, which should never issue a network request.
This is highly curious. Could you provide us with a reproduction showing that happening?
from apollo-client.
I have figured out that the problem has to do with <React.StrictMode>
somehow (StrictMode
causes render functions to be called twice, among other things). Without StrictMode
, the skipping works as intended. Under StrictMode
, both skipToken
and {skip: true}
seem to not result in skipping.
The repro seems to be as simple as:
const client = new ApolloClient({
uri: "/graphql",
connectToDevTools: true,
cache: new InMemoryCache(),
});
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<ApolloProvider client={client}>
<DummyComponent />
</ApolloProvider>
</React.StrictMode>,
);
export const DummyComponent: React.FunctionComponent<
PropsWithChildren<unknown>
> = ({children}) => {
console.log("!!! DummyComponent render");
let data: GetSpecQuery;
const {data: res} = useQuery(GET_BINARIES, skipToken);
console.log("!!! DummyComponent. data: ", res);
return <>DummyComponent</>;
};
FWIW, useQuery
with {skip: true}
works fine (including under StrictMode
).
Please tell me if this doesn't repro and I'll work on packaging it somehow.
from apollo-client.
@andreimatei out of curiosity, is this reproducible using version 3.9.9? Also in the code snippet above, I'm assuming you meant {skip: true}
instead of skipToken
as being passed to useQuery
? As useQuery
does not accept skipToken
.
from apollo-client.
out of curiosity, is this reproducible using version 3.9.9?
No, it does not seem to reproduce on 3.9.9! So the issue seems to have been introduced in 3.9.10. Going back and forth between these two versions reliably introduces and removes the problem.
Also in the code snippet above, I'm assuming you meant {skip: true} instead of skipToken as being passed to useQuery? As useQuery does not accept skipToken.
Sorry, the snippet was supposed to use useSuspenseQuery
. It was supposed to be
export const DummyComponent: React.FunctionComponent<
PropsWithChildren<unknown>
> = ({children}) => {
console.log("!!! DummyComponent render");
let data: GetSpecQuery;
const {data: res} = useSuspenseQuery(GET_BINARIES, skipToken);
console.log("!!! DummyComponent. data: ", res);
return <>DummyComponent</>;
};
useQuery
works fine.
from apollo-client.
Thanks for confirming that, @andreimatei! I believe @jerelmiller has some thoughts here on how to reconcile the fix we shipped in 3.9.10 with the issue you're seeing. We're also working on releasing 3.10 this week, so I can't give a precise timeline on the fix here, but we're looking into it. Thanks!
from apollo-client.
167 useSuspenseQuery
tests and this wasn't one of them 😂. Thanks for reporting!
from apollo-client.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
from apollo-client.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.
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 2
- NextJS with "useSuspenseQuery" not passing headers to request HOT 3
- 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 8
- 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 3
- 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.