Hasura-om is a Node.js ORM library (v1.4.6) that provides an object-oriented way to interact with Hasura GraphQL API. It focuses on fragments: base fragments are auto-generated from your database schema, then you can extend or create custom fragments. The library simplifies query building by allowing JavaScript objects to represent GraphQL operations. It supports queries, mutations, subscriptions, aggregate queries, nested queries, JWT authorization, and is available for both Node.js (CommonJS/ESM) and browser with bundlers. Key differentiator: fragment-first approach reduces boilerplate and keeps queries standardized. Current release cadence is irregular but active. Not to be confused with Hasura's own ORM tools or other GraphQL wrappers.
npm install hasura-omNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes Hasura ORM, generates fragments from schema, and performs a simple query limiting to 5 users ordered by name.
Update to v0.0.18+ and use 'graphqlUrl' instead of 'endpoint'.
Replace om.generateTablesFromAPI() with om.fetchSchema().
Pass custom headers in Hasura constructor: new Hasura({ graphqlUrl, headers: { 'x-hasura-role': 'admin' } })Use a bundler like Webpack and import 'hasura-om'. Alternatively, bundle it yourself.
Run 'npm install node-fetch' to install the peer dependency.
Update code to use 'await om.fetchSchema()' instead.
Ensure you pass an object with 'graphqlUrl' property when instantiating Hasura: new Hasura({ graphqlUrl: '...' })Pass 'adminSecret' in the constructor. If not needed, set to empty string or use 'headers' for authentication.
Enable introspection in Hasura or manually define fragments using 'setTable' method instead of auto-generating.