import type {CodegenConfig} from '@graphql-codegen/cli'

declare const process: { env: Record<string, string | undefined> }

const config: CodegenConfig = {
  overwrite: true,
  schema: process.env.NUXT_PUBLIC_WS_GRAPHQL,
  generates: {
    './app/types/graphql.ts': {
      plugins: [{
        add: {
          content: '//Auto-generated file, do not make any change. Content could be overwritten.',
        },
      }, 'typescript'],
      config: {
        maybeValue: 'T | null | undefined',
        inputMaybeValue: 'T | null | undefined',
        declarationKind: 'class',
        enumsAsTypes: true,
        skipTypename: true,
      },
    },
    './app/composables/graphqlObject.ts': {
      plugins: [{
        add: {
          content: '//Auto-generated file, do not make any change. Content could be overwritten.',
        },
      }, './.codegen/plugin-schema-object.cjs'],
    },
  },
  hooks: { afterAllFileWrite: ['prettier --parser typescript --tab-width 4 --write'] },
}

export default config
