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] 🐞 incorrect bundling of types for graphql-language-server #3790

Open
1 task done
phryneas opened this issue Sep 24, 2024 · 9 comments
Open
1 task done
Labels
bug lsp-server graphql-language-service-server

Comments

@phryneas
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Currently, [email protected] causes type errors with [email protected]. Apparently, this package bundles the types of the development dependency graphql into the published bundle, which will then cause TypeScript errors.

Also see the discussion in graphql/graphql-js#4201

Expected Behavior

As 16.9.0 is a valid peerDependency, it should not result in TS warnings.

Steps To Reproduce

Install [email protected] and [email protected], run tsc.

Environment

See this PR: apollographql/vscode-graphql#175 with a failing CI job

Anything else?

No response

@phryneas phryneas added bug lsp-server graphql-language-service-server labels Sep 24, 2024
@phryneas phryneas changed the title [lsp-server] 🐞 incorrect bundling of types [lsp-server] 🐞 incorrect bundling of types for graphql-language-server Sep 24, 2024
@yaacovCR
Copy link
Contributor

This would be fixed by the latest release: #3763

@phryneas
Copy link
Author

phryneas commented Sep 24, 2024

I don't think that a "move back to 16" is necessarily required to fix this. (I think that's what you're hinting at, right?)

The problem is that the graphql types end up in the graphql-language-server package - not as an imported dependency, but a rolled-up type file.

@phryneas
Copy link
Author

Or no, looking at the source code, I think this might actually not be the case and @JoviDeCroock might have overinterpreted things. The problem is not necessarily the bundling itself, but this statement:

export const RuleKinds = {
  ...Kind,
  ...AdditionalRuleKinds,
};

The spread pulls in all the information about Kind.

@JoviDeCroock
Copy link
Member

JoviDeCroock commented Sep 24, 2024

That spread, even if it's used as a JS-value, can be imported from graphql, which it does in JS but somehow in TypeScript rather than transpiling to export type RuleKinds = Kind & Y it's exploding the values. That being said, I am not really in the boat of that being an over-interpretation 😅 as the described state in the original issue is identical to the concluded state of the foregoing comment. This does show a cause though, the usage of Type enums has been flakey at times.

@phryneas
Copy link
Author

Yeah, I meant it's not a problem on the build tooling side, which I had assumed you meant.

I think this could fix it, I'm trying it out as we speak:

export const RuleKinds: Omit<typeof Kind, keyof _AdditionalRuleKinds> &
  _AdditionalRuleKinds = {
  ...Kind,
  ...AdditionalRuleKinds,
};

@phryneas
Copy link
Author

phryneas commented Sep 24, 2024

Oh, even simpler...

-export const RuleKinds = {
+export const RuleKinds: _RuleKinds = {
  ...Kind,
  ...AdditionalRuleKinds,
};

this would fix it without having to roll back the version of graphql (unless there is another reason)

@yaacovCR
Copy link
Contributor

I believe we wanted to move back to v16 as the dev dependency because it’s actually re-exported in one of the packages in total, and when we upgraded, we did it under the assumption that it would not affect users at all.

So we are definitely moving back to v16, which can be released whenever appropriate. @acao please feel free to jump in if I have that wrong.

More broadly, things could be rearchitectured of course!

@yaacovCR
Copy link
Contributor

graphiql will still support v17, but it won’t be the version in the dev dependency and I assume will fix this problem.

@phryneas
Copy link
Author

I'm happy either way :)

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

3 participants