Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.

support custom scalars

Changed files
+11 -3
src
+2 -1
src/index.ts
···
);
const tagTemplate = info.config.template || 'gql';
+
const scalars = info.config.scalars || {};
const proxy = createBasicDecorator(info);
···
]
}
-
generateTypedDocumentNodes(schema.current, parts.join('/'), texts.join('\n')).then(() => {
+
generateTypedDocumentNodes(schema.current, parts.join('/'), texts.join('\n'), scalars).then(() => {
nodes.forEach((node, i) => {
const queryText = texts[i] || '';
const parsed = parse(queryText);
+9 -2
src/types/generate.ts
···
import * as typescriptOperationsPlugin from '@graphql-codegen/typescript-operations'
import * as typedDocumentNodePlugin from '@graphql-codegen/typed-document-node'
-
export const generateTypedDocumentNodes = async (schema: GraphQLSchema | null, outputFile: string, doc: string) => {
+
export const generateTypedDocumentNodes = async (schema: GraphQLSchema | null, outputFile: string, doc: string, scalars: Record<string, unknown>) => {
if (!schema) return;
const config = {
···
document: parse(doc),
},
],
-
config: {},
+
config: {
+
scalars,
+
// nonOptionalTypename: true,
+
// avoidOptionals, worth looking into
+
enumsAsTypes: true,
+
dedupeOperationSuffix: true,
+
dedupeFragments: true,
+
},
// used by a plugin internally, although the 'typescript' plugin currently
// returns the string output, rather than writing to a file
filename: outputFile,