refactor: remove all any types, add strict GraphQL scalar typing
All checks were successful
Build Docker Image / build (push) Successful in 4m3s
All checks were successful
Build Docker Image / build (push) Successful in 4m3s
- 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.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
const items = ref<any[]>([])
|
||||
import type { GetTeamOrdersQueryResult } from '~/composables/graphql/team/orders-generated'
|
||||
|
||||
type TeamOrder = NonNullable<NonNullable<GetTeamOrdersQueryResult['getTeamOrders']>[number]>
|
||||
type TeamOrderStage = NonNullable<NonNullable<TeamOrder['stages']>[number]>
|
||||
|
||||
const items = ref<TeamOrder[]>([])
|
||||
const isLoading = ref(false)
|
||||
const isInitialized = ref(false)
|
||||
|
||||
@@ -23,13 +28,14 @@ export function useTeamOrders() {
|
||||
|
||||
const routesForMap = computed(() =>
|
||||
filteredItems.value
|
||||
.filter(order => order.uuid && order.name)
|
||||
.map(order => ({
|
||||
uuid: order.uuid,
|
||||
name: order.name,
|
||||
status: order.status,
|
||||
uuid: order.uuid!,
|
||||
name: order.name!,
|
||||
status: order.status ?? undefined,
|
||||
stages: (order.stages || [])
|
||||
.filter((s: any) => s.stageType === 'transport' && s.sourceLatitude && s.sourceLongitude && s.destinationLatitude && s.destinationLongitude)
|
||||
.map((s: any) => ({
|
||||
.filter((s): s is TeamOrderStage => s !== null && s.stageType === 'transport' && !!s.sourceLatitude && !!s.sourceLongitude && !!s.destinationLatitude && !!s.destinationLongitude)
|
||||
.map((s) => ({
|
||||
fromLat: s.sourceLatitude,
|
||||
fromLon: s.sourceLongitude,
|
||||
toLat: s.destinationLatitude,
|
||||
@@ -47,7 +53,7 @@ export function useTeamOrders() {
|
||||
try {
|
||||
const { GetTeamOrdersDocument } = await import('~/composables/graphql/team/orders-generated')
|
||||
const data = await execute(GetTeamOrdersDocument, {}, 'team', 'orders')
|
||||
items.value = data?.getTeamOrders || []
|
||||
items.value = (data?.getTeamOrders || []).filter((o): o is TeamOrder => o !== null)
|
||||
isInitialized.value = true
|
||||
} catch (e) {
|
||||
console.error('Failed to load orders', e)
|
||||
|
||||
Reference in New Issue
Block a user