graphiql
graphiql copied to clipboard
Some fragments show red underlines in VSCode that disappear after editing/re-saving file containing fragment
Hi there! We have a graphql config file like this:
schema: "../backend/src/graphql_server/**/*.graphql"
documents: "./src/graphql/**/*.graphql"
extensions:
codegen:
overwrite: true
config:
noNamespaces: true
strict: true
scalars:
Date: string
DateTime: string
withHooks: true
withComponent: false
withHOC: false
reactApolloVersion: 2
generates:
src/generated/graphql/graphql.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
- "fragment-matcher"
We have many fragments defined in documents path(s). There are a (large) handful of fragments that seem to not be initially recognized, when that fragment is referenced in another document graphql file. For example, let's say I have a file containing this fragment:
fragment A {
...B
}
If B is defined in the same file, this works, but if B is defined in another file, it may get a red underline. Mousing over it shows the error Unknown fragment "B". GraphQL: Validation.
However, I've found that if I go to the file containing B, delete a character from the fragment's name, add it back, save, go back to the file containing fragment A, remove and re-add the reference to fragment B (in fragment A), the previously unknown fragment B shows up in intellisense, and the red underline disappears. This change does not stick if I reload the window (assuming this is restarting the graphql language server).
The only thing I can tell for sure is that this doesn't impact referencing a fragment in the same file. I haven't been able to figure out some other pattern that would allow me to come up with a standalone, sharable reproduction project.
Versions
VSCode: 1.62.3 GraphQL Extension: 0.3.26
Thank you, I noticed this as well when working with fragments recently. It’s by one of a few potential issues.
I added logic to re-build all the caches used for lookup on every request, and this is probably unnecessary, causing performance issues, and potentially causing race conditions where parts of the project-wide fragment cache are not available for reference on certain events.
Hi @acao!
Were there any updates to this recently? We have red underlines in VSCode as well in our fragments (in external files), which disappear after editing the fragment in that file.
The issue is still in place. Are there any updates?
Same issues. Disappear after renaming the fragment. Is there any way to manually rebuild the fragments cache?
Hey @acao,
Are there any updates? I experience exactly the same issue in VSCode.
The related issue: #3066
I was trying to move from Apollo extension to this, and this is still an issue apparently?
Using schema instead of schemaPath in my config file fixed this issue for me, as referenced in #3066 🎉