Skip to content
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

Some fragments show red underlines in VSCode that disappear after editing/re-saving file containing fragment #2064

Open
benasher44 opened this issue Nov 27, 2021 · 8 comments
Labels
bug lsp-server graphql-language-service-server

Comments

@benasher44
Copy link

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

@acao acao added the bug label Nov 28, 2021
@acao
Copy link
Member

acao commented Nov 28, 2021

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.

@acao acao added the lsp-server graphql-language-service-server label Dec 4, 2021
@JMitnik
Copy link

JMitnik commented Mar 15, 2022

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.

@alexey-kachalov
Copy link

The issue is still in place. Are there any updates?

@Rigo-m
Copy link

Rigo-m commented Oct 7, 2022

Same issues. Disappear after renaming the fragment. Is there any way to manually rebuild the fragments cache?

@avlaguta
Copy link

avlaguta commented Mar 7, 2023

Hey @acao,

Are there any updates? I experience exactly the same issue in VSCode.

@avlaguta
Copy link

avlaguta commented Mar 7, 2023

The related issue:
#3066

@jimisaacs
Copy link

I was trying to move from Apollo extension to this, and this is still an issue apparently?

@manspaniel
Copy link

Using schema instead of schemaPath in my config file fixed this issue for me, as referenced in #3066 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug lsp-server graphql-language-service-server
Projects
None yet
Development

No branches or pull requests

8 participants