I'm working in a SvelteKit project and want to use gql codegen, but all queries are typed as unknown.
Ts file:
import { graphql } from '$lib/gql/index.js';
export const getPostById = graphql(`
query GET_ARTICLE($id: bigint!) {
articles_by_pk(id: $id) {
content
created_at
slug
updated_at
title
}
}
`);
codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
overwrite: true,
schema: "https:...myap",
debug: true,
verbose:true,
watch:true,
ignoreNoDocuments: true,
emitLegacyCommonJSImports: false,
documents:["./src/**/*.svelte", "./src/**/*.ts"],
generates: {
"src/lib/gql/": {
preset: 'client',
plugins: []
},
"./graphql.schema.json": {
plugins: ["introspection"]
}
}
};
export default config;
The const documents = [];
in the gql.ts file is empty (I think it shouldn't).
The package.json script includes: "codegen": "graphql-codegen-esm --config codegen.ts"
Running the script does not throw any errors. I have no idea where to start looking.