Skip to content

Commit 77e6915

Browse files
committed
federation bug plz
1 parent 37433e7 commit 77e6915

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Diff for: src/TreeOperations/merge/arguments.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const mergeArguments = (parentName: string, args1: ParserField[], args2:
2424
if (!equivalentA2) return;
2525
if (a1.type.fieldType.type === Options.required) return a1;
2626
if (equivalentA2.type.fieldType.type === Options.required) return equivalentA2;
27+
if (a1.type.fieldType.type === equivalentA2.type.fieldType.type) return a1;
2728
})
2829
.filter(<T>(v: T | undefined): v is T => !!v);
2930
};

Diff for: src/__tests__/TreeOperations/merge/merge.input.spec.ts

+27
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,33 @@ describe('Merging GraphQL Inputs and field arguments', () => {
2626
}`,
2727
);
2828
});
29+
it('Should merge inputs leaving common fields both required and not', () => {
30+
const baseSchema = `
31+
input UserInput {
32+
name: String!
33+
list: Boolean
34+
age: Int # Not in Subgraph B
35+
}
36+
`;
37+
38+
const mergingSchema = `
39+
input UserInput {
40+
name: String!
41+
list: Boolean
42+
email: String # Not in Subgraph A
43+
}
44+
`;
45+
const t1 = mergeSDLs(baseSchema, mergingSchema);
46+
if (t1.__typename === 'error') throw new Error('Invalid parse');
47+
expectTrimmedEqual(
48+
t1.sdl,
49+
`
50+
input UserInput{
51+
name: String!
52+
list: Boolean
53+
}`,
54+
);
55+
});
2956
it('Should merge inputs marking fields required.', () => {
3057
const baseSchema = `
3158
input UserInput {

0 commit comments

Comments
 (0)