Skip to content

Commit 2deb9be

Browse files
authored
Merge pull request #638 from constructive-io/fix-sdk-model-exports
fix(graphql-codegen): re-export models and custom operations from index.ts
2 parents eb66bc6 + fc20770 commit 2deb9be

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type { OrmClientConfig, QueryResult, GraphQLError } from "./client";
1414
export { GraphQLRequestError } from "./client";
1515
export { QueryBuilder } from "./query-builder";
1616
export * from "./select-types";
17+
export * from "./models";
1718
/**
1819
* Create an ORM client instance
1920
*
@@ -61,6 +62,9 @@ export type { OrmClientConfig, QueryResult, GraphQLError } from "./client";
6162
export { GraphQLRequestError } from "./client";
6263
export { QueryBuilder } from "./query-builder";
6364
export * from "./select-types";
65+
export * from "./models";
66+
export { createQueryOperations } from "./query";
67+
export { createMutationOperations } from "./mutation";
6468
/**
6569
* Create an ORM client instance
6670
*

graphql/codegen/src/cli/codegen/orm/client-generator.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,40 @@ export function generateCreateClientFile(
424424
// export * from './select-types';
425425
statements.push(t.exportAllDeclaration(t.stringLiteral('./select-types')));
426426

427+
// Re-export all models for backwards compatibility
428+
// export * from './models';
429+
statements.push(t.exportAllDeclaration(t.stringLiteral('./models')));
430+
431+
// Re-export custom operations for backwards compatibility
432+
if (hasCustomQueries) {
433+
statements.push(
434+
t.exportNamedDeclaration(
435+
null,
436+
[
437+
t.exportSpecifier(
438+
t.identifier('createQueryOperations'),
439+
t.identifier('createQueryOperations')
440+
),
441+
],
442+
t.stringLiteral('./query')
443+
)
444+
);
445+
}
446+
if (hasCustomMutations) {
447+
statements.push(
448+
t.exportNamedDeclaration(
449+
null,
450+
[
451+
t.exportSpecifier(
452+
t.identifier('createMutationOperations'),
453+
t.identifier('createMutationOperations')
454+
),
455+
],
456+
t.stringLiteral('./mutation')
457+
)
458+
);
459+
}
460+
427461
// Build the return object properties
428462
const returnProperties: t.ObjectProperty[] = [];
429463

0 commit comments

Comments
 (0)