gqlts
gqlts copied to clipboard
Allow passing a custom `tsconfig`.
Hi,
I have a case where I want to use Pastel together with a GraphQL client that I have.
But right now it fails it to properly import (types are not resolved) because the generated index.d.ts
imports from './schema'
instead of './schema.js'
:
import {
FieldsSelection,
GraphqlOperation,
ClientOptions,
ClientRequestConfig,
Observable,
} from '@gqlts/runtime'
import { Client as WSClient } from 'graphql-ws'
import { AxiosInstance } from 'axios'
export * from './schema' // should be `schema.js`
Would be nice to either respect the current tsconfig file or to be able to pass it in the library like this:
import { generate } from '@gqlts/cli'
import { printSchema } from 'graphql'
import { schema } from '@stauro/api'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const tsConfig = JSON.parse(await fs.readFile('./tsconfig.json', 'utf-8'))
await generate({
schema: printSchema(schema),
onlyEsModules: true,
output: path.join(fileURLToPath(new URL('.', import.meta.url)), 'generated'),
tsconfig,
})
my tsconfig:
{
"compilerOptions": {
"jsx": "react",
"preserveSymlinks": true,
"moduleResolution": "Node16",
"module": "Node16"
}
}