-
Notifications
You must be signed in to change notification settings - Fork 35
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
Using fragments in combination with PreloadQuery
leads to unique-names
warnings
#328
Comments
This is a weird one, and it seems to be a quirk of how React implements Client Component imports. I'll try to break it down, but this graphic might also help: So, what happens here is that our RSC component imports from Unfortunately, that executes the I'll have to dig deeper to find a solution for this, and I guess I'll have to make some changes to I can't give you a definite timeline on that - we're about to release Apollo Client 3.11 RC next week, so that has priority for now. I hope I can get to it once 3.11 has been released. In the meantime, you can disable that warning with import { disableFragmentWarnings } from 'graphql-tag';
disableFragmentWarnings() PS: Gruesse nach Hamburg :) |
@phryneas thanks a lot for the detailed explanation und liebe Grüße zurück. |
@phryneas Thanks for the details. Do you think this could also lead to |
@Algram I would not expect so, but if you can create a reproduction, please open a new issue and I'll take a look. |
I think this is an issue with // src/ManualDataTransport/dataTransport.ts
function transportDataToJS(data, stringify2) {
const key = Symbol.keyFor(ApolloSSRDataTransport);
return `(window[Symbol.for("${key}")] ??= []).push(${htmlEscapeJsonString(
stringify2(data)
)})`;
} On the client side, the query is parse-stringify-parsed in function deserializeOptions(options) {
return {
...options,
// `gql` memoizes results, but based on the input string.
// We parse-stringify-parse here to ensure that our minified query
// has the best chance of being the referential same query as the one used in
// client-side code.
query: gql(print(gql(options.query)))
};
} The query that is written to the HTML response has newlines removed, but the query after being parse-stringified has the newlines present. This causes Perhaps remove newlines when memoizing the results of parsing the query? Edit: a bit more digging reveals that the newlines are actually removed in // src/DataTransportAbstraction/transportedOptions.ts
function serializeOptions(options) {
return {
...options,
query: printMinified(options.query)
};
} |
Thanks for bringing that up, that's another good point. Even if it were 100% the same, you'd get that warning... The For now, please disable the warnings. |
@Algram I'll have to look into that. Could you please give me the full text of the warning? |
@phryneas Sure:
|
@Algram That error message seems to come from |
I have tried it and it doesn't work. |
Can you try import { disableFragmentWarnings } from '@apollo/client';
disableFragmentWarnings() instead? |
@phryneas we're getting the same fragment |
@nduchon did you make sure to do that call in the client bundle, meaning in a file with |
What's the matter?
When using the PreloadQuery component with a query that contains fragments, we get following
unique-names
warning in the console:What do we expect?
Using
PreloadQuery
should not lead tounique-names
warnings.Also: The links is not very helpful because the page doesn't exist anymore.
How to reproduce?
Take a look into the console of following example https://stackblitz.com/edit/nextjs-869gd8?file=app%2Fexample-query.ts,app%2Fpage.tsx
The text was updated successfully, but these errors were encountered: