Skip to content

Commit 697e93f

Browse files
fix missing output individual files options
1 parent 42e6a21 commit 697e93f

2 files changed

Lines changed: 73 additions & 46 deletions

File tree

packages/apollo-codegen-swift/src/__tests__/codeGeneration.ts

Lines changed: 72 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("Swift code generation", () => {
4949
}
5050
`);
5151

52-
generator.classDeclarationForOperation(operations["HeroName"]);
52+
generator.classDeclarationForOperation(operations["HeroName"], false);
5353

5454
expect(generator.output).toMatchSnapshot();
5555
});
@@ -67,7 +67,7 @@ describe("Swift code generation", () => {
6767
}
6868
`);
6969

70-
generator.classDeclarationForOperation(operations["Hero"]);
70+
generator.classDeclarationForOperation(operations["Hero"], false);
7171

7272
expect(generator.output).toMatchSnapshot();
7373
});
@@ -85,7 +85,7 @@ describe("Swift code generation", () => {
8585
}
8686
`);
8787

88-
generator.classDeclarationForOperation(operations["Hero"]);
88+
generator.classDeclarationForOperation(operations["Hero"], false);
8989

9090
expect(generator.output).toMatchSnapshot();
9191
});
@@ -127,7 +127,7 @@ describe("Swift code generation", () => {
127127
}
128128
`);
129129

130-
generator.classDeclarationForOperation(operations["CreateReview"]);
130+
generator.classDeclarationForOperation(operations["CreateReview"], false);
131131

132132
expect(generator.output).toMatchSnapshot();
133133
});
@@ -147,7 +147,7 @@ describe("Swift code generation", () => {
147147
}
148148
`);
149149

150-
generator.classDeclarationForOperation(operations["Hero"]);
150+
generator.classDeclarationForOperation(operations["Hero"], false);
151151

152152
expect(generator.output).toMatchSnapshot();
153153
});
@@ -182,7 +182,7 @@ describe("Swift code generation", () => {
182182
{ generateOperationIds: true, mergeInFieldsFromFragmentSpreads: true }
183183
);
184184

185-
generator.classDeclarationForOperation(operations["Hero"]);
185+
generator.classDeclarationForOperation(operations["Hero"], false);
186186

187187
expect(generator.output).toMatchSnapshot();
188188
});
@@ -360,7 +360,7 @@ describe("Swift code generation", () => {
360360
}
361361
`);
362362

363-
generator.structDeclarationForFragment(fragments["HeroDetails"]);
363+
generator.structDeclarationForFragment(fragments["HeroDetails"], false);
364364

365365
expect(generator.output).toMatchSnapshot();
366366
});
@@ -373,7 +373,7 @@ describe("Swift code generation", () => {
373373
}
374374
`);
375375

376-
generator.structDeclarationForFragment(fragments["DroidDetails"]);
376+
generator.structDeclarationForFragment(fragments["DroidDetails"], false);
377377

378378
expect(generator.output).toMatchSnapshot();
379379
});
@@ -388,7 +388,7 @@ describe("Swift code generation", () => {
388388
}
389389
`);
390390

391-
generator.structDeclarationForFragment(fragments["HeroDetails"]);
391+
generator.structDeclarationForFragment(fragments["HeroDetails"], false);
392392

393393
expect(generator.output).toMatchSnapshot();
394394
});
@@ -405,7 +405,7 @@ describe("Swift code generation", () => {
405405
}
406406
`);
407407

408-
generator.structDeclarationForFragment(fragments["HeroDetails"]);
408+
generator.structDeclarationForFragment(fragments["HeroDetails"], false);
409409

410410
expect(generator.output).toMatchSnapshot();
411411
});
@@ -424,10 +424,13 @@ describe("Swift code generation", () => {
424424
const selectionSet = (operations["Hero"].selectionSet
425425
.selections[0] as Field).selectionSet as SelectionSet;
426426

427-
generator.structDeclarationForSelectionSet({
428-
structName: "Hero",
429-
selectionSet
430-
});
427+
generator.structDeclarationForSelectionSet(
428+
{
429+
structName: "Hero",
430+
selectionSet
431+
},
432+
false
433+
);
431434

432435
expect(generator.output).toMatchSnapshot();
433436
});
@@ -444,10 +447,13 @@ describe("Swift code generation", () => {
444447
const selectionSet = (operations["Hero"].selectionSet
445448
.selections[0] as Field).selectionSet as SelectionSet;
446449

447-
generator.structDeclarationForSelectionSet({
448-
structName: "Hero",
449-
selectionSet
450-
});
450+
generator.structDeclarationForSelectionSet(
451+
{
452+
structName: "Hero",
453+
selectionSet
454+
},
455+
false
456+
);
451457

452458
expect(generator.output).toMatchSnapshot();
453459
});
@@ -466,10 +472,13 @@ describe("Swift code generation", () => {
466472
const selectionSet = (operations["Hero"].selectionSet
467473
.selections[0] as Field).selectionSet as SelectionSet;
468474

469-
generator.structDeclarationForSelectionSet({
470-
structName: "Hero",
471-
selectionSet
472-
});
475+
generator.structDeclarationForSelectionSet(
476+
{
477+
structName: "Hero",
478+
selectionSet
479+
},
480+
false
481+
);
473482

474483
expect(generator.output).toMatchSnapshot();
475484
});
@@ -491,10 +500,13 @@ describe("Swift code generation", () => {
491500
const selectionSet = (operations["Hero"].selectionSet
492501
.selections[0] as Field).selectionSet as SelectionSet;
493502

494-
generator.structDeclarationForSelectionSet({
495-
structName: "Hero",
496-
selectionSet
497-
});
503+
generator.structDeclarationForSelectionSet(
504+
{
505+
structName: "Hero",
506+
selectionSet
507+
},
508+
false
509+
);
498510

499511
expect(generator.output).toMatchSnapshot();
500512
});
@@ -516,10 +528,13 @@ describe("Swift code generation", () => {
516528
const selectionSet = (operations["Hero"].selectionSet
517529
.selections[0] as Field).selectionSet as SelectionSet;
518530

519-
generator.structDeclarationForSelectionSet({
520-
structName: "Hero",
521-
selectionSet
522-
});
531+
generator.structDeclarationForSelectionSet(
532+
{
533+
structName: "Hero",
534+
selectionSet
535+
},
536+
false
537+
);
523538

524539
expect(generator.output).toMatchSnapshot();
525540
});
@@ -539,10 +554,13 @@ describe("Swift code generation", () => {
539554
const selectionSet = (operations["Hero"].selectionSet
540555
.selections[0] as Field).selectionSet as SelectionSet;
541556

542-
generator.structDeclarationForSelectionSet({
543-
structName: "Hero",
544-
selectionSet
545-
});
557+
generator.structDeclarationForSelectionSet(
558+
{
559+
structName: "Hero",
560+
selectionSet
561+
},
562+
false
563+
);
546564

547565
expect(generator.output).toMatchSnapshot();
548566
});
@@ -566,10 +584,13 @@ describe("Swift code generation", () => {
566584
const selectionSet = (operations["Hero"].selectionSet
567585
.selections[0] as Field).selectionSet as SelectionSet;
568586

569-
generator.structDeclarationForSelectionSet({
570-
structName: "Hero",
571-
selectionSet
572-
});
587+
generator.structDeclarationForSelectionSet(
588+
{
589+
structName: "Hero",
590+
selectionSet
591+
},
592+
false
593+
);
573594

574595
expect(generator.output).toMatchSnapshot();
575596
});
@@ -586,18 +607,21 @@ describe("Swift code generation", () => {
586607
const selectionSet = (operations["Hero"].selectionSet
587608
.selections[0] as Field).selectionSet as SelectionSet;
588609

589-
generator.structDeclarationForSelectionSet({
590-
structName: "Hero",
591-
selectionSet
592-
});
610+
generator.structDeclarationForSelectionSet(
611+
{
612+
structName: "Hero",
613+
selectionSet
614+
},
615+
false
616+
);
593617

594618
expect(generator.output).toMatchSnapshot();
595619
});
596620
});
597621

598622
describe("#typeDeclarationForGraphQLType()", () => {
599623
it("should generate an enum declaration for a GraphQLEnumType", () => {
600-
generator.typeDeclarationForGraphQLType(schema.getType("Episode"));
624+
generator.typeDeclarationForGraphQLType(schema.getType("Episode"), false);
601625

602626
expect(generator.output).toMatchSnapshot();
603627
});
@@ -608,13 +632,16 @@ describe("Swift code generation", () => {
608632
values: { PUBLIC: { value: "PUBLIC" }, PRIVATE: { value: "PRIVATE" } }
609633
});
610634

611-
generator.typeDeclarationForGraphQLType(albumPrivaciesEnum);
635+
generator.typeDeclarationForGraphQLType(albumPrivaciesEnum, false);
612636

613637
expect(generator.output).toMatchSnapshot();
614638
});
615639

616640
it("should generate a struct declaration for a GraphQLInputObjectType", () => {
617-
generator.typeDeclarationForGraphQLType(schema.getType("ReviewInput"));
641+
generator.typeDeclarationForGraphQLType(
642+
schema.getType("ReviewInput"),
643+
false
644+
);
618645

619646
expect(generator.output).toMatchSnapshot();
620647
});

packages/apollo-codegen-swift/src/codeGeneration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class SwiftAPIGenerator extends SwiftGenerator<CompilerContext> {
175175
options: { namespace },
176176
fragments
177177
} = this.context;
178-
const isRedundant = !!namespace;
178+
const isRedundant = !!namespace && !outputIndividualFiles;
179179
const modifiers = isRedundant ? ["final"] : ["public", "final"];
180180

181181
this.classDeclaration(

0 commit comments

Comments
 (0)