···11+---
22+"@0no-co/graphqlsp": major
33+---
44+55+Retire automatic typegen with tagged-templates, we encourage folks to either try out
66+[gql.tada](https://github.com/0no-co/gql.tada) or the [client-preset](https://the-guild.dev/graphql/codegen/docs/guides/react-vue)
+2-6
README.md
···11# GraphQLSP
2233This is a TypeScript LSP Plugin that will recognise documents in your
44-TypeScript code and help you out with hover-information, diagnostics,
55-auto-complete and automatically generating [Typed-Document-nodes](https://the-guild.dev/graphql/codegen/plugins/typescript/typed-document-node)
44+TypeScript code and help you out with hover-information, diagnostics and
55+auto-complete.
6677## Features
8899- Hover information showing the decriptions of fields
1010- Diagnostics for adding fields that don't exist, are deprecated, missmatched argument types, ...
1111- Auto-complete inside your editor for fields
1212-- When you save it will generate `typed-document-nodes` for your documents and cast them to the correct type
1312- Will warn you when you are importing from a file that is exporting fragments that you're not using
14131514> Note that this plugin does not do syntax highlighting, for that you still need something like
···63626463- `template` the shape of your template, by default `gql`
6564- `templateIsCallExpression` this tells our client that you are using `graphql('doc')`
6666-- `disableTypegen` disables type-generation in general, this could be needed if offset bugs are introduced
6767-- `scalars` allows you to pass an object of scalars that we'll feed into `graphql-code-generator`
6868-- `extraTypes` allows you to specify imports or declare types to help with `scalar` definitions
6965- `shouldCheckForColocatedFragments` when turned on, this will scan your imports to find
7066 unused fragments and provide a message notifying you about them
7167- `trackFieldUsage` this only works with the client-preset, when turned on it will warn you about
+11-7
packages/graphqlsp/README.md
···11# GraphQLSP
2233This is a TypeScript LSP Plugin that will recognise documents in your
44-TypeScript code and help you out with hover-information, diagnostics,
55-auto-complete and automatically generating [Typed-Document-nodes](https://the-guild.dev/graphql/codegen/plugins/typescript/typed-document-node)
44+TypeScript code and help you out with hover-information, diagnostics and
55+auto-complete.
6677## Features
8899- Hover information showing the decriptions of fields
1010- Diagnostics for adding fields that don't exist, are deprecated, missmatched argument types, ...
1111- Auto-complete inside your editor for fields
1212-- When you save it will generate `typed-document-nodes` for your documents and cast them to the correct type
1312- Will warn you when you are importing from a file that is exporting fragments that you're not using
14131514> Note that this plugin does not do syntax highlighting, for that you still need something like
···4241workspace version of TypeScript. In VSCode you can do so by clicking the bottom right
4342when on a TypeScript file or adding a file like [this](https://github.com/0no-co/GraphQLSP/blob/main/packages/example/.vscode/settings.json).
44434545-> If you are using VSCode ensure that your editor is using the Workspace Version of TypeScript
4444+> If you are using VSCode ensure that your editor is using [the Workspace Version of TypeScript](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript)
4545+> this can be done by manually selecting it or adding a `.vscode/config.json` with the contents of
4646+>
4747+> ```json
4848+> {
4949+> "typescript.tsdk": "node_modules/typescript/lib",
5050+> "typescript.enablePromptUseWorkspaceTsdk": true
5151+> }
5252+> ```
46534754### Configuration
4855···55625663- `template` the shape of your template, by default `gql`
5764- `templateIsCallExpression` this tells our client that you are using `graphql('doc')`
5858-- `disableTypegen` disables type-generation in general, this could be needed if offset bugs are introduced
5959-- `scalars` allows you to pass an object of scalars that we'll feed into `graphql-code-generator`
6060-- `extraTypes` allows you to specify imports or declare types to help with `scalar` definitions
6165- `shouldCheckForColocatedFragments` when turned on, this will scan your imports to find
6266 unused fragments and provide a message notifying you about them
6367- `trackFieldUsage` this only works with the client-preset, when turned on it will warn you about
···22222323type Config = {
2424 schema: SchemaOrigin | string;
2525+ // TODO: rename to tag or just remove entirely and always check for
2626+ // gql and graphql.
2527 template?: string;
2828+ // TODO: we need a bettername, gql.tada will also have
2929+ // call expressions, we can differentiate by means of
3030+ // tada having a second argument containing the fragments.
2631 templateIsCallExpression?: boolean;
2727- disableTypegen?: boolean;
2828- extraTypes?: string;
2929- scalars?: Record<string, unknown>;
3232+ // Up in the air whether we want to keep supporting
3333+ // this. Current limitation are barrel-file exports
3434+ // could be counter-acted with an opinion on
3535+ // fragment-naming. Could become more relevant
3636+ // with gql.tada and could be useful for
3737+ // client-preset as well however the component type-annotations
3838+ // can better indicate a missing spread for the
3939+ // client-preset.
3040 shouldCheckForColocatedFragments?: boolean;
3141};
3242···43534454 logger('Setting up the GraphQL Plugin');
45554646- const scalars = config.scalars || {};
4747- const extraTypes = config.extraTypes || '';
4848- const disableTypegen = config.disableTypegen ?? false;
4949-5056 const proxy = createBasicDecorator(info);
51575252- const baseTypesPath =
5353- info.project.getCurrentDirectory() + '/__generated__/baseGraphQLSP.ts';
5454-5558 const schema = loadSchema(
5659 info.project.getProjectName(),
5760 config.schema,
5858- logger,
5959- baseTypesPath,
6060- !disableTypegen,
6161- scalars,
6262- extraTypes
6161+ logger
6362 );
64636564 proxy.getSemanticDiagnostics = (filename: string): ts.Diagnostic[] => {
6665 const originalDiagnostics =
6766 info.languageService.getSemanticDiagnostics(filename);
68676969- const graphQLDiagnostics = getGraphQLDiagnostics(
7070- originalDiagnostics.length > 0,
7171- filename,
7272- baseTypesPath,
7373- schema,
7474- info
7575- );
6868+ const graphQLDiagnostics = getGraphQLDiagnostics(filename, schema, info);
76697770 return graphQLDiagnostics
7871 ? [...graphQLDiagnostics, ...originalDiagnostics]