Fragment is never used
See original GitHub issueResponse from graphql server is: Fragment "___profile___requestIndex_1___userPhotoThumb" is never used. But the problem is in the apollo-client 😦
I have next query via graphql decorator:
query profile($slug: String!) {
viewer {
id,
}
user(slug: $slug) {
id,
...userPhotoThumb,
}
}
On the server side rendering everything works fine. But when I try to continue on the client side I will get next response from graphql:
{
"errors": [
{
"message": "Fragment \"___profile___requestIndex_1___userPhotoThumb\" is never used.",
"locations": [
{
"line": 16,
"column": 1
}
]
}
]
}
The problem is that request from apollo-client is
"query ___composed {
___profile___requestIndex_1___fieldIndex_0: viewer {
id
__typename
}
___getViewer___requestIndex_2___fieldIndex_0: viewer {
id
__typename
}
}
fragment ___profile___requestIndex_1___userPhotoThumb on User {
___profile___requestIndex_1___fieldIndex_1: picture
___profile___requestIndex_1___fieldIndex_2: slug
___profile___requestIndex_1___fieldIndex_3: __typename
}
"
As you can see “user” part is completely missing in the profile query. I think that user part is cached from server side rendering
Here is a complete graphql request
{
"debugName": "___composed",
"query": "query ___composed {\n ___getViewer___requestIndex_0___fieldIndex_0: viewer {\n id\n __typename\n }\n ___profile___requestIndex_1___fieldIndex_0: viewer {\n id\n __typename\n }\n ___getViewer___requestIndex_2___fieldIndex_0: viewer {\n id\n __typename\n }\n}\n\nfragment ___profile___requestIndex_1___userPhotoThumb on User {\n ___profile___requestIndex_1___fieldIndex_1: picture\n ___profile___requestIndex_1___fieldIndex_2: slug\n ___profile___requestIndex_1___fieldIndex_3: __typename\n}\n",
"variables": {
"___profile___requestIndex_1___slug": "zlatko-fedor"
}
}
I have tried apollo-client 0.4.19 and 0.4.20 with same results. In this moment I am not able to use fragments anymore. Please help me to fix this issue. Thank you very much
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Fragment "X" is never used. Suggest: warning instead of error.
This is actually an error from your GraphQL server - it's running validation on the query and that's a default validation rule for...
Read more >Fragments - Apollo GraphQL Docs
A GraphQL fragment is a piece of logic that can be shared between multiple queries and mutations. Here's the declaration of a NameParts...
Read more >ApolloError: Fragment was used, but not defined
I manually call client.query to fetch the latest data on click of the button, but it throws an error saying it can't find...
Read more >GraphQL fragments explained - LogRocket Blog
A GraphQL fragment is a reusable part of the query. In GraphQL, you may run into situations where ... Benefits of using a...
Read more >Using Fragments – Angular - GraphQL Code Generator
Using Fragments. A GraphQL fragment is a shared piece of query logic. ... There are two principal uses for fragments in Apollo:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm it is fixed in the 0.5.0-1
@seeden ah, ok, makes sense. It’s exactly what you suspected. We removed the query diffing functionality, so the next version won’t contain that bug any more 😃