Skip to content

Commit 094847e

Browse files
committed
added a default type weights configuration to the function parameters
1 parent 7f5f655 commit 094847e

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/analysis/buildTypeWeights.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,29 @@ interface TypeWeightObject {
1313
[index: string]: Type;
1414
}
1515

16-
function buildTypeWeightsFromSchema(schema: GraphQLSchema): TypeWeightObject {
16+
interface TypeWeightConfig {
17+
mutation?: number;
18+
query?: number;
19+
object?: number;
20+
scalar?: number;
21+
connection?: number;
22+
}
23+
24+
/**
25+
* The default type weights object is based off of Shopifys implewentation of query
26+
* cost analysis. Our function should input a users configuration of type weights or fall
27+
* back on shopifys on
28+
*/
29+
function buildTypeWeightsFromSchema(
30+
schema: GraphQLSchema,
31+
typeWeightsConfig: TypeWeightConfig = {
32+
query: 1,
33+
mutation: 10,
34+
object: 1,
35+
scalar: 0,
36+
connection: 2,
37+
}
38+
): TypeWeightObject {
1739
throw Error(`getTypeWeightsFromSchema is not implemented.`);
1840
}
1941
export default buildTypeWeightsFromSchema;

test/analysis/buildTypeWeights.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ describe('Test buildTypeWeightsFromSchema function', () => {
77
let schema: GraphQLSchema;
88
});
99

10-
test('creates the type weight object from graphql schema object', () => {});
10+
describe('query types', () => {
11+
// cretes type weight object from schema with multipl types
12+
test('creates the type weight object from graphql schema object', () => {});
1113

12-
test('');
14+
// creates tyep weight object from schema with nested types
15+
test('');
16+
});
17+
18+
/**
19+
* Above tests are for query types only
20+
* todo testing functionality for mutations, pagination, lists, etc. is not yet implemented
21+
*/
1322
});

0 commit comments

Comments
 (0)