-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I noticed that the generated types for mappers have all fields marked as optional so if you delete one of them, typescript won't notice but it will fail at runtime. Is this intended?
For example:
type Vehicle {
id: ID!
telemetryLogs: [TelemetryLog!]!
}I have this mapper:
Vehicle.ts
import type { VehicleResolvers } from "../../types.generated.ts";
export const Vehicle: VehicleResolvers = {
telemetryLogs: async (_parent, _arg, _ctx) => {
/* Vehicle.telemetryLogs resolver is required because Vehicle.telemetryLogs exists but VehicleMapper.telemetryLogs does not */
},
};I am able to completely remove the telemetryLogs property:
import type { VehicleResolvers } from "../../types.generated.ts";
export const Vehicle: VehicleResolvers = {
// telemetryLogs: async (_parent, _arg, _ctx) => {
/* Vehicle.telemetryLogs resolver is required because Vehicle.telemetryLogs exists but VehicleMapper.telemetryLogs does not */
// },
};... it will still compile fine with typescript. However, since latestTelemetry is non nullable in my GraphQL schema, it will fail with a runtime an error when I query it.
In the generated.types.ts file
export type VehicleResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['Vehicle'] = ResolversParentTypes['Vehicle']> = {
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
telemetryLogs?: Resolver<Array<ResolversTypes['TelemetryLog']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};The problem is that telemetryLogs?: should really be telemetryLogs:. Isn't it?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels