{"id":42843,"library":"hasura-om","title":"hasura-om (Hasura ORM)","description":"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.","status":"active","version":"1.4.6","language":"javascript","source_language":"en","source_url":"https://github.com/mrspartak/hasura-om","tags":["javascript","hasura","graphql","orm","nodejs"],"install":[{"cmd":"npm install hasura-om","lang":"bash","label":"npm"},{"cmd":"yarn add hasura-om","lang":"bash","label":"yarn"},{"cmd":"pnpm add hasura-om","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for HTTP requests to Hasura endpoint","package":"node-fetch","optional":false}],"imports":[{"note":"CommonJS require should use destructuring to get the Hasura class. Using import { Hasura } from 'hasura-om' for ESM (note: ESM support may require bundler).","wrong":"const Hasura = require('hasura-om')","symbol":"Hasura","correct":"const { Hasura } = require('hasura-om')"},{"note":"QueryBuilder is a named export, not default. Use destructuring.","wrong":"import QueryBuilder from 'hasura-om'","symbol":"QueryBuilder","correct":"const { QueryBuilder } = require('hasura-om')"},{"note":"The package also exports a default object? Verify in docs. Some versions may have default export but recommended to use named 'Hasura'.","wrong":"","symbol":"default export","correct":"import hasuraOM from 'hasura-om'"}],"quickstart":{"code":"const { Hasura } = require('hasura-om');\n\nconst om = new Hasura({\n    graphqlUrl: process.env.HASURA_URL || 'http://localhost:8080/v1/graphql',\n    adminSecret: process.env.HASURA_ADMIN_SECRET || 'myadminsecretkey'\n});\n\nasync function main() {\n    await om.generateTablesFromAPI();\n    const [err, result] = await om.query({\n        user: {\n            limit: 5,\n            order_by: { name: 'asc' },\n            fields: `\n                id\n                name\n                email\n            `\n        }\n    });\n    if (err) {\n        console.error('Error:', err);\n    } else {\n        console.log('Users:', result.user);\n    }\n}\n\nmain().catch(console.error);","lang":"javascript","description":"Initializes Hasura ORM, generates fragments from schema, and performs a simple query limiting to 5 users ordered by name."},"warnings":[{"fix":"Update to v0.0.18+ and use 'graphqlUrl' instead of 'endpoint'.","message":"Version 0.0.18 changed Hasura constructor options: 'endpoint' renamed to 'graphqlUrl'. Existing code using 'endpoint' will break.","severity":"breaking","affected_versions":"<0.0.18"},{"fix":"Replace om.generateTablesFromAPI() with om.fetchSchema().","message":"The method 'generateTablesFromAPI' is deprecated as of v1.0.0. Use 'fetchSchema' instead.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Pass custom headers in Hasura constructor: new Hasura({ graphqlUrl, headers: { 'x-hasura-role': 'admin' } })","message":"When using adminSecret, the header 'x-hasura-admin-secret' is set. If your Hasura instance requires a different header (like 'x-hasura-role'), you must configure it manually via 'headers' option.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a bundler like Webpack and import 'hasura-om'. Alternatively, bundle it yourself.","message":"In browser, the library requires a bundler (Webpack, Rollup, etc.) to work. It does not come with a pre-built UMD bundle. Attempting to use it directly via <script> tag will fail.","severity":"gotcha","affected_versions":">=1.2.0"}],"env_vars":null,"search_vec":"'activ':103 'aggreg':68 'allow':56 'api':27 'approach':90 'author':73 'auto':36 'auto-gener':35 'avail':76 'base':32 'boilerpl':92 'browser':82 'build':54 'bundler':84 'cadenc':99 'commonjs/esm':80 'confus':107 'creat':47 'current':97 'custom':48 'databas':40 'differenti':86 'extend':45 'first':89 'focus':29 'fragment':31,33,49,88 'fragment-first':87 'generat':37 'graphql':26,61,116,120 'hasura':2,4,7,25,109,119 'hasura-om':1,6 'interact':23 'irregular':101 'javascript':57,118 'jwt':72 'keep':94 'key':85 'librari':13,51 'mutat':66 'nest':70 'node.js':11,79 'nodej':122 'object':19,58 'object-ori':18 'om':3,8 'oper':62 'orient':20 'orm':5,12,112,121 'provid':16 'queri':53,65,69,71,95 'reduc':91 'releas':98 'repres':60 'schema':41 'simplifi':52 'standard':96 'subscript':67 'support':64 'tool':113 'v1.4.6':14 'way':21 'wrapper':117","created_at":"2026-06-05T16:56:55.981449+00:00","updated_at":"2026-06-05T16:56:55.981449+00:00","problems":[{"fix":"Run 'npm install node-fetch' to install the peer dependency.","cause":"Missing dependency 'node-fetch' when using the library in Node.js environment.","error":"Error: Cannot find module 'node-fetch'"},{"fix":"Update code to use 'await om.fetchSchema()' instead.","cause":"The method 'generateTablesFromAPI' was renamed to 'fetchSchema' in v1.0.0.","error":"TypeError: om.generateTablesFromAPI is not a function"},{"fix":"Ensure you pass an object with 'graphqlUrl' property when instantiating Hasura: new Hasura({ graphqlUrl: '...' })","cause":"Missing 'graphqlUrl' in Hasura constructor options.","error":"UnhandledPromiseRejectionWarning: Error: graphqlUrl is required"},{"fix":"Pass 'adminSecret' in the constructor. If not needed, set to empty string or use 'headers' for authentication.","cause":"Missing 'adminSecret' in Hasura constructor options but Hasura endpoint requires admin secret.","error":"Error: Admin secret is required"},{"fix":"Enable introspection in Hasura or manually define fragments using 'setTable' method instead of auto-generating.","cause":"Hasura endpoint returned 404 during schema fetch. Usually because GraphQL introspection is disabled in Hasura.","error":"Error: Not Found - Schema introspection might be disabled"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://mrspartak.github.io/hasura-om/","github":"https://github.com/mrspartak/hasura-om","docs":null,"changelog":null,"pypi":null,"npm":"hasura-om","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}