A collection of scalar types not included in base GraphQL.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Date, time, and timestamp validation with ISO 8601 compliance and timezone support. These scalars handle various temporal data formats commonly used in applications.
Validates ISO 8601 date format (YYYY-MM-DD).
/**
* GraphQL scalar for ISO 8601 date format validation
* Accepts dates in YYYY-MM-DD format
*/
const GraphQLDate: GraphQLScalarType;Example Values:
"2023-12-25""2024-01-01""1990-06-15"Validates ISO 8601 time format with optional milliseconds.
/**
* GraphQL scalar for ISO 8601 time format validation
* Accepts time in HH:MM:SS[.sss] format
*/
const GraphQLTime: GraphQLScalarType;Example Values:
"14:30:00""09:15:30.500""23:59:59"Validates ISO 8601 date-time format.
/**
* GraphQL scalar for ISO 8601 date-time format validation
* Accepts combined date and time representations
*/
const GraphQLDateTime: GraphQLScalarType;Example Values:
"2023-12-25T14:30:00""2024-01-01T00:00:00.000"Validates strict ISO 8601 date-time format with timezone information.
/**
* GraphQL scalar for strict ISO 8601 date-time with timezone
* Requires timezone offset or Z for UTC
*/
const GraphQLDateTimeISO: GraphQLScalarType;Example Values:
"2023-12-25T14:30:00Z""2024-01-01T15:30:00+01:00""2023-06-15T09:00:00-07:00"Validates Unix timestamps (seconds since epoch).
/**
* GraphQL scalar for Unix timestamp validation
* Accepts number of seconds since January 1, 1970 UTC
*/
const GraphQLTimestamp: GraphQLScalarType;Example Values:
1703520600 (2023-12-25T14:30:00Z)1704067200 (2024-01-01T00:00:00Z)Validates IANA timezone identifiers.
/**
* GraphQL scalar for IANA timezone identifier validation
* Accepts standard timezone names from the IANA timezone database
*/
const GraphQLTimeZone: GraphQLScalarType;Example Values:
"America/New_York""Europe/London""Asia/Tokyo""UTC"Validates UTC offset format.
/**
* GraphQL scalar for UTC offset validation
* Accepts offset in +/-HH:MM format
*/
const GraphQLUtcOffset: GraphQLScalarType;Example Values:
"+00:00""-05:00""+09:30""-11:00"Validates duration strings.
/**
* GraphQL scalar for duration string validation
* Accepts various duration string formats
*/
const GraphQLDuration: GraphQLScalarType;Validates ISO 8601 duration format.
/**
* GraphQL scalar for ISO 8601 duration format validation
* Accepts P[n]Y[n]M[n]DT[n]H[n]M[n]S format
*/
const GraphQLISO8601Duration: GraphQLScalarType;Example Values:
"P1Y2M3DT4H5M6S" (1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds)"PT30M" (30 minutes)"P7D" (7 days)"PT2H30M" (2 hours and 30 minutes)Validates local date without timezone information.
/**
* GraphQL scalar for local date validation
* Accepts date in YYYY-MM-DD format without timezone
*/
const GraphQLLocalDate: GraphQLScalarType;Example Values:
"2023-12-25""2024-02-29" (leap year)"1999-12-31"Validates local time without timezone information.
/**
* GraphQL scalar for local time validation
* Accepts time in HH:MM:SS[.sss] format without timezone
*/
const GraphQLLocalTime: GraphQLScalarType;Example Values:
"14:30:00""09:15:30.500""00:00:00"Validates local date-time without timezone information.
/**
* GraphQL scalar for local date-time validation
* Accepts combined date and time without timezone
*/
const GraphQLLocalDateTime: GraphQLScalarType;Example Values:
"2023-12-25T14:30:00""2024-01-01T00:00:00.000"Validates local end time with additional validation constraints.
/**
* GraphQL scalar for local end time validation
* Validates end time with business logic constraints
*/
const GraphQLLocalEndTime: GraphQLScalarType;import {
GraphQLDate,
GraphQLTime,
GraphQLDateTime,
GraphQLTimeZone
} from "graphql-scalars";
// In a GraphQL schema
const EventType = new GraphQLObjectType({
name: "Event",
fields: {
startDate: { type: GraphQLDate },
startTime: { type: GraphQLTime },
createdAt: { type: GraphQLDateTime },
timezone: { type: GraphQLTimeZone },
},
});
// Using with type definitions
const typeDefs = `
scalar Date
scalar Time
scalar DateTime
scalar TimeZone
type Event {
startDate: Date
startTime: Time
createdAt: DateTime
timezone: TimeZone
}
`;// String constants for schema building
const Date: string; // "scalar Date"
const Time: string; // "scalar Time"
const DateTime: string; // "scalar DateTime"
const DateTimeISO: string; // "scalar DateTimeISO"
const Timestamp: string; // "scalar Timestamp"
const TimeZone: string; // "scalar TimeZone"
const UtcOffset: string; // "scalar UtcOffset"
const Duration: string; // "scalar Duration"
const ISO8601Duration: string; // "scalar ISO8601Duration"
const LocalDate: string; // "scalar LocalDate"
const LocalTime: string; // "scalar LocalTime"
const LocalDateTime: string; // "scalar LocalDateTime"
const LocalEndTime: string; // "scalar LocalEndTime"// Mock data generators for testing
const DateMock: () => string;
const TimeMock: () => string;
const DateTimeMock: () => string;
const DateTimeISOMock: () => string;
const TimestampMock: () => number;
const TimeZoneMock: () => string;
const UtcOffsetMock: () => string;
const DurationMock: () => string;
const ISO8601DurationMock: () => string;
const LocalDateMock: () => string;
const LocalTimeMock: () => string;
const LocalDateTimeMock: () => string;
const LocalEndTimeMock: () => string;