From 828de89953161a124e44385435bac5c87fe4f9c5 Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Thu, 18 Jan 2024 21:54:31 +0000 Subject: [PATCH] fix: Export introspection type in d.ts output (#184) * Update d.ts output to export introspection type * Add changeset * Fix typo (whoops) --- .changeset/hot-icons-fetch.md | 5 +++++ packages/graphqlsp/src/graphql/getSchema.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/hot-icons-fetch.md diff --git a/.changeset/hot-icons-fetch.md b/.changeset/hot-icons-fetch.md new file mode 100644 index 00000000..93243265 --- /dev/null +++ b/.changeset/hot-icons-fetch.md @@ -0,0 +1,5 @@ +--- +'@0no-co/graphqlsp': patch +--- + +When creating a `d.ts` file, export the introspection type to make it reusable. diff --git a/packages/graphqlsp/src/graphql/getSchema.ts b/packages/graphqlsp/src/graphql/getSchema.ts index 1ba7a493..24062ea7 100644 --- a/packages/graphqlsp/src/graphql/getSchema.ts +++ b/packages/graphqlsp/src/graphql/getSchema.ts @@ -99,11 +99,11 @@ async function saveTadaIntrospection( if (/\.d\.ts$/.test(output)) { contents = [ dtsAnnotationComment, - `declare const introspection: ${json};\n`, + `export type introspection = ${json};\n`, "import * as gqlTada from 'gql.tada';\n", "declare module 'gql.tada' {", ' interface setupSchema {', - ' introspection: typeof introspection', + ' introspection: introspection', ' }', '}', ].join('\n');