@agnathan/types-simple
v1.0.39
Published
TypeScript types, GraphQL schema, and operations for StratiqAI
Readme
StratiqAI Types Simple
Central package for GraphQL schema, operations, and TypeScript types.
Workflow for Keeping Types in Sync
1. Update GraphQL Schema
Edit src/schema.graphql when you need to change types, fields, or operations.
2. Update GraphQL Operations
Edit operation files in src/graphql/**/*.ts to match the schema.
3. Generate TypeScript Types
Run code generation to create TypeScript types from the schema and validate operations:
npm run generate:typesThis will:
- ✅ Generate TypeScript types from the schema
- ✅ Validate all operations against the schema
- ✅ Fail if operations don't match the schema (prevents drift)
4. Use Generated Types
Import and use the generated types in your code:
import { Q_GET_PROJECT } from "stratiqai-types-simple/operations";
import type {
GetProjectQuery,
GetProjectQueryVariables,
} from "stratiqai-types-simple";
// Type-safe GraphQL operations
const result = await client.query<GetProjectQuery, GetProjectQueryVariables>({
query: Q_GET_PROJECT,
variables: { id: "123" },
});Best Practices
- Always run
npm run generate:typesafter schema changes - This ensures types stay in sync - Fix validation errors immediately - Don't ignore codegen validation errors
- Use generated types everywhere - Import types from this package, don't redefine them
- Schema-first development - Update the schema first, then operations, then regenerate types
CI/CD Integration
Add to your CI pipeline to catch type mismatches:
- name: Validate GraphQL types
run: npm run generate:typesThis will fail the build if operations don't match the schema.
