Skip to content

Ecosystem overview

The smart-enum ecosystem is a core library plus a small family of packages that extend it to a full GraphQL + database stack. Each is independent — adopt only what you need.

The packages

PackagenpmWhat it does
smart-enum@reharik/smart-enumThe core. Enum creation, lookup, subsetting, serialization/transport, database revival, and GraphQL serializer patching.
smart-enum-knex@reharik/smart-enum-knexWires explicit row revival into Knex's postProcessResponse.
graphql-codegen-smart-enum@reharik/graphql-codegen-smart-enumGenerates smart-enum definitions and the enumRegistry barrel from schema enum types.
…-type-policies@reharik/graphql-codegen-smart-enum-type-policiesGenerates Apollo typePolicies that rehydrate enum fields from the cache.
…-preset@reharik/graphql-codegen-smart-enum-presetA codegen preset orchestrating all of the above with zero per-enum config.

How they fit together

The core library is self-contained — install it alone and you have better enums in any TypeScript project.

The codegen packages remove the work of keeping hand-authored enum files in sync with a GraphQL schema. The enum-definition plugin turns schema enums into definitions; type-policies makes the Apollo cache hand back members instead of strings; the preset ties both together and auto-derives the enumValues maps so resolver and operation types reference your enums without per-enum wiring.

The Knex adapter connects core's database revival to Knex's query hooks, so revival happens automatically per query instead of by hand.

Picking a starting point

Versions at time of writing

PackageVersion
@reharik/smart-enum0.4.6
@reharik/smart-enum-knex0.0.3
@reharik/graphql-codegen-smart-enum0.3.8
@reharik/graphql-codegen-smart-enum-type-policies0.1.3
@reharik/graphql-codegen-smart-enum-preset0.1.2

Check npm for the latest published versions.

Released under the MIT License.