Registry /
devops / graphql-codegen-hasura-core
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' }] }
Errors
Common errors & fixes
Cannot find module 'graphql-tag'
Missing peer dependency graphql-tag
fixnpm install graphql-tag
TypeError: getSingleTableQuery is not a function
Importing from wrong package or using default import incorrectly
fixUse 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
fixUpgrade call to new syntax: getSingleTableInsert<User>({ tableName, fields, objects }) Audit
Dependencies
graphql-tagoptionalRequired for gql template literal runtime