diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap index e9a299087..99468545f 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap @@ -14,6 +14,7 @@ export type { OrmClientConfig, QueryResult, GraphQLError } from "./client"; export { GraphQLRequestError } from "./client"; export { QueryBuilder } from "./query-builder"; export * from "./select-types"; +export * from "./models"; /** * Create an ORM client instance * @@ -61,6 +62,9 @@ export type { OrmClientConfig, QueryResult, GraphQLError } from "./client"; export { GraphQLRequestError } from "./client"; export { QueryBuilder } from "./query-builder"; export * from "./select-types"; +export * from "./models"; +export { createQueryOperations } from "./query"; +export { createMutationOperations } from "./mutation"; /** * Create an ORM client instance * diff --git a/graphql/codegen/src/cli/codegen/orm/client-generator.ts b/graphql/codegen/src/cli/codegen/orm/client-generator.ts index 08e3bbf29..c3b61e1b8 100644 --- a/graphql/codegen/src/cli/codegen/orm/client-generator.ts +++ b/graphql/codegen/src/cli/codegen/orm/client-generator.ts @@ -424,6 +424,40 @@ export function generateCreateClientFile( // export * from './select-types'; statements.push(t.exportAllDeclaration(t.stringLiteral('./select-types'))); + // Re-export all models for backwards compatibility + // export * from './models'; + statements.push(t.exportAllDeclaration(t.stringLiteral('./models'))); + + // Re-export custom operations for backwards compatibility + if (hasCustomQueries) { + statements.push( + t.exportNamedDeclaration( + null, + [ + t.exportSpecifier( + t.identifier('createQueryOperations'), + t.identifier('createQueryOperations') + ), + ], + t.stringLiteral('./query') + ) + ); + } + if (hasCustomMutations) { + statements.push( + t.exportNamedDeclaration( + null, + [ + t.exportSpecifier( + t.identifier('createMutationOperations'), + t.identifier('createMutationOperations') + ), + ], + t.stringLiteral('./mutation') + ) + ); + } + // Build the return object properties const returnProperties: t.ObjectProperty[] = [];