Registry / devops / graphql-codegen-hasura-core

graphql-codegen-hasura-core

JSON →
library4.10.0jsnpmunverified

Core runtime types and utility functions for generated Hasura CRUD code. Version 4.10.0, part of the graphql-codegen-hasura suite. Automates boilerplate for single-table mutations, queries, and multi-table helpers targeting Hasura backends. Relies on graphql-tag for template literals. Not affiliated with graphql-code-generator, Hasura, or Apollo teams.

npm install graphql-codegen-hasura-core
INSTALL
IMPORT
SIG · GRAPHQL-CODEGEN-HA
G
graphql-codegen-hasura-core
devopsjavascriptv4.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getSingleTableQuery
import { getSingleTableQuery } from 'graphql-codegen-hasura-core'
const { getSingleTableQuery } = require('graphql-codegen-hasura-core')
ESM only; tree-shakeable
getSingleTableInsertMutable
import { getSingleTableInsertMutable } from 'graphql-codegen-hasura-core'
import { getSingleTableInsertMutable } from 'graphql-codegen-hasura'
Must import from -core subpackage, not the parent
Types
import { Types } from 'graphql-codegen-hasura-core'
import Types from 'graphql-codegen-hasura-core'
Named export, not default

Demonstrates using core functions to generate a query and insert mutation for a Hasura table.

import { getSingleTableQuery, getSingleTableInsert, Types } from 'graphql-codegen-hasura-core'; import gql from 'graphql-tag'; // Assume generated types from codegen interface User { id: string; name: string; } const { query, variables } = getSingleTableQuery<User>({ tableName: 'users', fields: ['id', 'name'], filter: { id: { _eq: '1' } }, }); console.log(query); // gql`query users($filter: users_bool_exp) { users(where: $filter) { id name } }` console.log(variables); // { filter: { id: { _eq: '1' } } } const { mutation, mutationVariables } = getSingleTableInsert<User>({ tableName: 'users', fields: ['id', 'name'], objects: [{ id: '2', name: 'Alice' }], }); console.log(mutation); // gql`mutation insert_users($objects: [users_insert_input!]!) { insert_users(objects: $objects) { id name } }` console.log(mutationVariables); // { objects: [{ id: '2', name: 'Alice' }] }
Debug
Known issues
gotchaThis package is not affiliated with graphql-code-generator, Hasura, or Apollo teams. Use at your own risk.
fix
Review the license and support available on GitHub.
affects: >=4.0.0
breakingVersion 4.0 broke signatures of mutation functions; old syntax no longer works.
fix
Migrate to new object parameter style as shown in quickstart.
affects: >=4.0.0 <5.0.0
deprecatedgetSingleTableUpdate and getSingleTableDelete are deprecated in favor of more granular functions
fix
Use getSingleTableUpdateMutable and getSingleTableDeleteMutable instead.
affects: >=4.5.0
gotchaRequires graphql-tag as a peer dependency; missing it causes runtime errors
fix
Install graphql-tag: npm install graphql-tag
affects: >=4.0.0
Errors
Common errors & fixes
Cannot find module 'graphql-tag'
Missing peer dependency graphql-tag
fix
npm install graphql-tag
TypeError: getSingleTableQuery is not a function
Importing from wrong package or using default import incorrectly
fix
Use named import: import { getSingleTableQuery } from 'graphql-codegen-hasura-core'
Expected object but got undefined (parameter mismatch in mutation call)
API change in version 4 where mutations now take an ordered object parameter
fix
Upgrade call to new syntax: getSingleTableInsert<User>({ tableName, fields, objects })
Upgrade
Version history
4.10.0latest on npm
Audit
Dependencies
graphql-tagoptionalRequired for gql template literal runtime
Agent activity
9 hits · last 30 days
node
8
Resources
graphql-codegen-hasura-core — npm install graphql-codegen-hasura-core · libregistry