Skip to content

Commit cea1dcd

Browse files
authored
Add getGraphModels to exports (#407)
1 parent ae61ea3 commit cea1dcd

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/graphql/graphql.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,16 @@ function isScalar(type: any): boolean {
845845
);
846846
}
847847

848+
export function getGraphModels(graphSchema: gql.GraphQLSchema): string[] {
849+
const models: string[] = [];
850+
for (const [name, type] of Object.entries(graphSchema.getTypeMap())) {
851+
if (isV2ModelType(type)) {
852+
models.push(name);
853+
}
854+
}
855+
return models;
856+
}
857+
848858
interface IncrementalQueryConfig {
849859
readonly type: gql.GraphQLObjectType;
850860
readonly resolvedPrimaryKeys?: Dictionary<string>;

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export {
6161
crossMerge,
6262
flattenIterable,
6363
flattenV2,
64+
getGraphModels,
6465
paginatedQueryV2,
6566
pathToModelV2,
6667
readerFromQuery,

test/graphql.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,12 @@ describe('graphql', () => {
476476
incremental: false,
477477
});
478478
});
479+
480+
test('get graph models', () => {
481+
expect(sut.getGraphModels(graphSchemaV2)).toIncludeAllMembers([
482+
'cicd_Artifact',
483+
'cicd_Build',
484+
'cicd_Pipeline',
485+
]);
486+
});
479487
});

0 commit comments

Comments
 (0)