idScalar
idScalar<
Brand>(codec,config):GraphQLScalarType<Id<Brand>,string>
Defined in: src/adapters/graphql.ts:35
Builds a GraphQLScalarType for the given codec and brand.
serialize— validates strictly viacodec.is(); throwsGraphQLErroron a non-canonical value and returns the value unchanged (no normalization) on success.parseValue— validates variables viacodec.safeParse; throwsGraphQLErroron failure. Accepts mixed-case and Crockford visual aliases; always returns the canonical form.parseLiteral— validates inlineKind.STRINGliterals the same way asparseValue; throwsGraphQLErrorfor any other AST kind or on a failedsafeParse.
graphql must be installed as a peer dependency.
Type Parameters
Section titled “Type Parameters”Brand extends string
Parameters
Section titled “Parameters”GraphQLCodec<Brand>
config
Section titled “config”description?
Section titled “description?”string
string
Returns
Section titled “Returns”GraphQLScalarType<Id<Brand>, string>
Example
Section titled “Example”import { idScalar } from "@smonn/ids/graphql";import { createTimestampId } from "@smonn/ids";
const usr = createTimestampId("usr");const UserIdScalar = idScalar(usr, { name: "UserId", description: "A branded user ID." });