Skip to content

Commit 259da24

Browse files
committed
added readonly properites to the typeWeightObject types
1 parent eb23356 commit 259da24

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/@types/buildTypeWeights.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
interface Fields {
2-
[index: string]: number;
2+
readonly [index: string]: number;
33
}
44

55
interface Type {
6-
weight: number;
7-
fields: Fields;
6+
readonly weight: number;
7+
readonly fields: Fields;
88
}
99

1010
interface TypeWeightObject {
11-
[index: string]: Type;
11+
readonly [index: string]: Type;
1212
}
1313

1414
interface TypeWeightConfig {

test/analysis/buildTypeWeights.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import { buildSchema } from 'graphql';
22
import { GraphQLSchema } from 'graphql/type/schema';
33
import buildTypeWeightsFromSchema from '../../src/analysis/buildTypeWeights';
44

5+
// these types allow the tests to overwite properties on the typeWeightObject
6+
interface TestFields {
7+
[index: string]: number;
8+
}
9+
interface TestType {
10+
weight: number;
11+
fields: TestFields;
12+
}
13+
interface TestTypeWeightObject {
14+
[index: string]: TestType;
15+
}
16+
517
xdescribe('Test buildTypeWeightsFromSchema function', () => {
618
let schema: GraphQLSchema;
719

@@ -306,7 +318,7 @@ xdescribe('Test buildTypeWeightsFromSchema function', () => {
306318
});
307319

308320
describe('changes "type weight object" type weights with user configuration of...', () => {
309-
let expectedOutput: TypeWeightObject;
321+
let expectedOutput: TestTypeWeightObject;
310322

311323
beforeEach(() => {
312324
schema = buildSchema(`

0 commit comments

Comments
 (0)