Skip to content

Commit 5e064e9

Browse files
committed
feat: validate that types and fields referenced by a field are included in the same modules like that field
If a field is present in a certain module selection, everything it needs should also be included. That is - field type - collect path segments - @relation(inverseOf) - @reference(keyField)
1 parent 4382f9f commit 5e064e9

File tree

9 files changed

+523
-30
lines changed

9 files changed

+523
-30
lines changed

spec/model/compatibility-check/describe-module-specification.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { EffectiveModuleSpecification } from '../../../src/model/implementation/
44

55
describe('describeModuleSpecification', () => {
66
it('describes empty spec', () => {
7-
const result = describeModuleSpecification(EffectiveModuleSpecification.EMPTY);
7+
const result = describeModuleSpecification(EffectiveModuleSpecification.EMPTY, {
8+
preposition: 'by',
9+
});
810
expect(result).to.equal('');
911
});
1012

@@ -17,6 +19,7 @@ describe('describeModuleSpecification', () => {
1719
},
1820
],
1921
}),
22+
{ preposition: 'by' },
2023
);
2124
expect(result).to.equal('by module "module1"');
2225
});
@@ -33,6 +36,7 @@ describe('describeModuleSpecification', () => {
3336
},
3437
],
3538
}),
39+
{ preposition: 'by' },
3640
);
3741
expect(result).to.equal('by module "module1" and "module2"');
3842
});
@@ -52,6 +56,7 @@ describe('describeModuleSpecification', () => {
5256
},
5357
],
5458
}),
59+
{ preposition: 'by' },
5560
);
5661
expect(result).to.equal('by module "module1", "module2" and "module3"');
5762
});
@@ -65,6 +70,7 @@ describe('describeModuleSpecification', () => {
6570
},
6671
],
6772
}),
73+
{ preposition: 'by' },
6874
);
6975
expect(result).to.equal('by the combination of module "module1" and "module2"');
7076
});
@@ -78,6 +84,7 @@ describe('describeModuleSpecification', () => {
7884
},
7985
],
8086
}),
87+
{ preposition: 'by' },
8188
);
8289
expect(result).to.equal('by the combination of module "module1", "module2" and "module3"');
8390
});
@@ -100,6 +107,7 @@ describe('describeModuleSpecification', () => {
100107
},
101108
],
102109
}),
110+
{ preposition: 'by' },
103111
);
104112
expect(result).to.equal(
105113
'by module "a", "b" and "c", and by the combination of module "module1" and "module2"',
@@ -124,6 +132,7 @@ describe('describeModuleSpecification', () => {
124132
},
125133
],
126134
}),
135+
{ preposition: 'by' },
127136
);
128137
expect(result).to.equal(
129138
'by module "a", "b" and "c", and by the combination of module "module1", "module2" and "module3"',
@@ -151,6 +160,7 @@ describe('describeModuleSpecification', () => {
151160
},
152161
],
153162
}),
163+
{ preposition: 'by' },
154164
);
155165
expect(result).to.equal(
156166
'by module "a", "b" and "c", and by the combination of module "module1" and "module2", and by the combination of module "module3", "module4" and "module5"',
@@ -169,6 +179,7 @@ describe('describeModuleSpecification', () => {
169179
},
170180
],
171181
}),
182+
{ preposition: 'by' },
172183
);
173184
expect(result).to.equal(
174185
'by the combination of module "module1" and "module2", and by the combination of module "module3", "module4" and "module5"',

spec/schema/ast-validation-modules/helpers.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ import { prettyPrint } from '../../../src/graphql/pretty-print';
1919

2020
export function assertValidatorRejects(
2121
source: string | DocumentNode,
22-
msg: string,
22+
msg: string | ReadonlyArray<string>,
2323
options?: ValidationOptions,
2424
) {
25+
const messages = Array.isArray(msg) ? msg : [msg];
2526
const validationResult = validate(source, options);
2627
expect(validationResult.hasErrors()).to.be.true;
27-
expect(validationResult.getErrors().length, validationResult.toString()).to.equal(1);
28-
expect(validationResult.getErrors()[0].message, validationResult.toString()).to.equal(msg);
28+
expect(
29+
validationResult.getErrors().map((e) => e.message),
30+
validationResult.toString(),
31+
).to.deep.equal(messages);
2932
}
3033

3134
export function assertValidatorWarns(

0 commit comments

Comments
 (0)