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

[lsp-server] multi-project config with file schemas is not working #3153

Closed
scamden opened this issue Apr 27, 2023 · 7 comments · Fixed by #3154
Closed

[lsp-server] multi-project config with file schemas is not working #3153

scamden opened this issue Apr 27, 2023 · 7 comments · Fixed by #3154
Labels
enhancement lsp-server graphql-language-service-server

Comments

@scamden
Copy link
Contributor

scamden commented Apr 27, 2023

Current Behavior

I have two projects configured in my rc as indicated on the vscode extension readme. Whichever project I load a file from first gets cached and works (ish there are issues with line numbers and the gql tag but that's for another issue). But the files from the other project will not function.

Based on my loose naive reading of the code it seems like getFragmentDefinitions inside GraphQLCache.ts caches according to projectConfig.dirpath which would have to be the same for both projects. I forked and tried adding the project name to the cache key and it seemed to solve but I have no idea if that could cause other issues.

Here's my config

projects:
  app-dashboard:
    schema:
      - ./workspaces/server/graphql/shared/shared-schema.graphql
      - ./workspaces/server/graphql/dashboard/dashboard-schema.graphql
    documents:
      - ./workspaces/app-dashboard/cache.tsx
      - ./workspaces/app-dashboard/pages/_app.tsx
      - ./workspaces/app-dashboard/{components,pages,utils}/**/*.{ts,tsx}
      - ./workspaces/shared-frontend/{components,hooks,utils}/**/*.{ts,tsx}
    extensions:
      languageService:
        enableValidation: false
  app-admin:
    schema:
      - ./workspaces/server/graphql/shared/shared-schema.graphql
      - ./workspaces/server/graphql/admin/admin-schema.graphql
    documents:
      - ./workspaces/app-admin/cache.tsx
      - ./workspaces/app-admin/pages/_app.tsx
      - ./workspaces/app-admin/{components,pages,utils}/**/*.{ts,tsx}
      - ./workspaces/shared-frontend/{components,hooks,utils}/**/*.{ts,tsx}
    extensions:
      languageService:
        enableValidation: false

Desired Behavior

Two projects in the same config both have go to definition working.

PRs welcome!

If you find a way to solve this problem by modifying the code in either the source or the distributed code, we are more than happy to accept enhancement requests as PRs!

@jacprada
Copy link

Hey @scamden, can you confirm this has been fixed (cc @acao)? I can still see this issue even when running the recently released version 0.8.13 of the GraphQL: Language Feature Support extension. Should that version include your fix? Thanks! 🙇

@acao acao reopened this Jun 12, 2023
@acao
Copy link
Member

acao commented Jun 12, 2023

Could be a regression introduced here:

#3163

#3120

this was supposed to fix this issue:

#3154

these changes don't seem to be related:

#3150

does it work with 0.8.7?

@jacprada
Copy link

Thanks for jumping in @acao! I came across this message when I was still on 0.8.7. At the time, I was experiencing what I believe is the same issue described above.

My understanding was that @scamden's fix would be included in version 0.8.9 as mentioned here. Due to the unrelated publishing issue, version 0.8.9 was never available on the VSCode Marketplace, so there is no way for me to try that particular version and see if everything was working as expected at that point.

Before doing anything else, I just wanted to double check with @scamden if the issue he described and fixed appears to be back for him too with the latest version. 🙇

@acao
Copy link
Member

acao commented Jun 12, 2023

@jacprada - @scamden 's fix is in the 0.8.13 release, so it may be that his fix worked for his context but not yours, or a regression occurred after his fix was merged. we are sorely lacking in test coverage for the multi-project config use case. I hope to improve this soon!

@acao
Copy link
Member

acao commented Jun 12, 2023

@jacprada perhaps you can share your config as well in case there are deltas? the more the merrier for adding more test cases

@jacprada
Copy link

Hey @acao, are you interested in the config file or is there more you would like to know?

I came across this open issue, which matches our simple use case and behaviour. Do you feel like the fix mentioned above should have addressed that particular issue too?

@acao
Copy link
Member

acao commented Jun 12, 2023

ok, so the delta is remote schema vs local file schema. that would explain why this is working but that is not. let's move the discussion to #2293 then

@acao acao closed this as completed Jun 12, 2023
@acao acao changed the title [lsp-server] only one of multiple projects in graphqlrc work in vscode [lsp-server] multi-project config with file schemas is not working Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement lsp-server graphql-language-service-server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants