Files
webapp/codegen.ts
Ruslan Bakiev 2dbe600d8a
All checks were successful
Build Docker Image / build (push) Successful in 4m3s
refactor: remove all any types, add strict GraphQL scalar typing
- Add strictScalars: true to codegen.ts with proper scalar mappings
  (Date, Decimal, JSONString, JSON, UUID, BigInt → string/Record)
- Replace all ref<any[]> with proper GraphQL-derived types
- Add type guards for null filtering in arrays
- Fix bugs exposed by typing (locationLatitude vs latitude, etc.)
- Add interfaces for external components (MapboxSearchBox)

This enables end-to-end type safety from GraphQL schema to frontend.
2026-01-27 11:34:12 +07:00

91 lines
2.8 KiB
TypeScript

import type { CodegenConfig } from '@graphql-codegen/cli'
const plugins = [
'typescript',
'typescript-operations',
'typed-document-node',
]
const pluginConfig = {
scalars: {
DateTime: 'string',
Date: 'string',
Decimal: 'string',
JSONString: 'Record<string, unknown>',
JSON: 'Record<string, unknown>',
UUID: 'string',
BigInt: 'string',
},
useTypeImports: true,
strictScalars: true,
// Add suffix to operation result types to avoid conflicts with schema types
operationResultSuffix: 'Result',
}
const config: CodegenConfig = {
overwrite: true,
generates: {
// Public operations (no token)
'./app/composables/graphql/public/exchange-generated.ts': {
schema: 'https://exchange.optovia.ru/graphql/public/',
documents: './graphql/operations/public/exchange/*.graphql',
plugins,
config: pluginConfig,
},
'./app/composables/graphql/public/geo-generated.ts': {
schema: 'https://geo.optovia.ru/graphql/public/',
documents: './graphql/operations/public/geo/*.graphql',
plugins,
config: pluginConfig,
},
'./app/composables/graphql/public/kyc-generated.ts': {
schema: 'https://kyc.optovia.ru/graphql/public/',
documents: './graphql/operations/public/kyc/*.graphql',
plugins,
config: pluginConfig,
},
// User-level operations (ID Token)
'./app/composables/graphql/user/teams-generated.ts': {
schema: 'https://teams.optovia.ru/graphql/user/',
documents: './graphql/operations/user/teams/*.graphql',
plugins,
config: pluginConfig,
},
'./app/composables/graphql/user/kyc-generated.ts': {
schema: 'https://kyc.optovia.ru/graphql/user/',
documents: './graphql/operations/user/kyc/*.graphql',
plugins,
config: pluginConfig,
},
// Team-level operations (Access Token)
'./app/composables/graphql/team/teams-generated.ts': {
schema: 'https://teams.optovia.ru/graphql/team/',
documents: './graphql/operations/team/teams/*.graphql',
plugins,
config: pluginConfig,
},
'./app/composables/graphql/team/orders-generated.ts': {
schema: 'https://orders.optovia.ru/graphql/team/',
documents: './graphql/operations/team/orders/*.graphql',
plugins,
config: pluginConfig,
},
'./app/composables/graphql/team/exchange-generated.ts': {
schema: 'https://exchange.optovia.ru/graphql/team/',
documents: './graphql/operations/team/exchange/*.graphql',
plugins,
config: pluginConfig,
},
'./app/composables/graphql/team/billing-generated.ts': {
schema: 'https://billing.optovia.ru/graphql/team/',
documents: './graphql/operations/team/billing/*.graphql',
plugins,
config: pluginConfig,
},
},
}
export default config