Skip to content

Commit 2be129b

Browse files
committed
feat: make mutation inputs mutable
1 parent 3e97f80 commit 2be129b

File tree

2 files changed

+70
-70
lines changed

2 files changed

+70
-70
lines changed

src/TypeScriptTypeTransformers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function transformNonNullableInputType(
132132
state: State
133133
) {
134134
if (schema.isList(type)) {
135-
return ts.createTypeReferenceNode(ts.createIdentifier("ReadonlyArray"), [
135+
return ts.createTypeReferenceNode(ts.createIdentifier("Array"), [
136136
transformInputType(schema, schema.getListItemType(type), state)
137137
]);
138138
} else if (schema.isScalar(type)) {
@@ -155,7 +155,7 @@ function transformNonNullableInputType(
155155
const fieldType = schema.getFieldType(fieldID);
156156
const fieldName = schema.getFieldName(fieldID);
157157
const property = ts.createPropertySignature(
158-
[ts.createToken(ts.SyntaxKind.ReadonlyKeyword)],
158+
undefined,
159159
ts.createIdentifier(fieldName),
160160
state.optionalInputFields.indexOf(fieldName) >= 0 ||
161161
!schema.isNonNull(fieldType)

test/__snapshots__/TypeScriptGenerator-test.ts.snap

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -573,20 +573,20 @@ mutation CommentCreateMutation(
573573
~~~~~~~~~~ OUTPUT ~~~~~~~~~~
574574
// CommentCreateMutation.graphql
575575
export type CommentCreateInput = {
576-
readonly clientMutationId?: string | null;
577-
readonly feedbackId?: string | null;
578-
readonly feedback?: CommentfeedbackFeedback | null;
576+
clientMutationId?: string | null;
577+
feedbackId?: string | null;
578+
feedback?: CommentfeedbackFeedback | null;
579579
};
580580
export type CommentfeedbackFeedback = {
581-
readonly comment?: FeedbackcommentComment | null;
581+
comment?: FeedbackcommentComment | null;
582582
};
583583
export type FeedbackcommentComment = {
584-
readonly feedback?: CommentfeedbackFeedback | null;
584+
feedback?: CommentfeedbackFeedback | null;
585585
};
586586
export type CommentCreateMutationVariables = {
587587
input: CommentCreateInput;
588588
first?: number | null;
589-
orderBy?: ReadonlyArray<string> | null;
589+
orderBy?: Array<string> | null;
590590
};
591591
export type CommentCreateMutationResponse = {
592592
readonly commentCreate: {
@@ -619,8 +619,8 @@ mutation InputHasArray($input: UpdateAllSeenStateInput) @raw_response_type {
619619
~~~~~~~~~~ OUTPUT ~~~~~~~~~~
620620
// InputHasArray.graphql
621621
export type UpdateAllSeenStateInput = {
622-
readonly clientMutationId?: string | null;
623-
readonly storyIds?: ReadonlyArray<string | null> | null;
622+
clientMutationId?: string | null;
623+
storyIds?: Array<string | null> | null;
624624
};
625625
export type InputHasArrayVariables = {
626626
input?: UpdateAllSeenStateInput | null;
@@ -670,8 +670,8 @@ type Foo {
670670
~~~~~~~~~~ OUTPUT ~~~~~~~~~~
671671
// Test.graphql
672672
export type UpdateAllSeenStateInput = {
673-
readonly clientMutationId?: string | null;
674-
readonly storyIds?: ReadonlyArray<string | null> | null;
673+
clientMutationId?: string | null;
674+
storyIds?: Array<string | null> | null;
675675
};
676676
export type TestVariables = {
677677
input?: UpdateAllSeenStateInput | null;
@@ -738,20 +738,20 @@ fragment FriendFragment on User {
738738
import { FragmentRefs } from "relay-runtime";
739739
export type TestEnums = "mark" | "zuck" | "%future added value";
740740
export type CommentCreateInput = {
741-
readonly clientMutationId?: string | null;
742-
readonly feedbackId?: string | null;
743-
readonly feedback?: CommentfeedbackFeedback | null;
741+
clientMutationId?: string | null;
742+
feedbackId?: string | null;
743+
feedback?: CommentfeedbackFeedback | null;
744744
};
745745
export type CommentfeedbackFeedback = {
746-
readonly comment?: FeedbackcommentComment | null;
746+
comment?: FeedbackcommentComment | null;
747747
};
748748
export type FeedbackcommentComment = {
749-
readonly feedback?: CommentfeedbackFeedback | null;
749+
feedback?: CommentfeedbackFeedback | null;
750750
};
751751
export type CommentCreateMutationVariables = {
752752
input: CommentCreateInput;
753753
first?: number | null;
754-
orderBy?: ReadonlyArray<string> | null;
754+
orderBy?: Array<string> | null;
755755
};
756756
export type CommentCreateMutationResponse = {
757757
readonly commentCreate: {
@@ -846,20 +846,20 @@ fragment FeedbackFragment on Feedback {
846846
// CommentCreateMutation.graphql
847847
import { FragmentRefs } from "relay-runtime";
848848
export type CommentCreateInput = {
849-
readonly clientMutationId?: string | null;
850-
readonly feedbackId?: string | null;
851-
readonly feedback?: CommentfeedbackFeedback | null;
849+
clientMutationId?: string | null;
850+
feedbackId?: string | null;
851+
feedback?: CommentfeedbackFeedback | null;
852852
};
853853
export type CommentfeedbackFeedback = {
854-
readonly comment?: FeedbackcommentComment | null;
854+
comment?: FeedbackcommentComment | null;
855855
};
856856
export type FeedbackcommentComment = {
857-
readonly feedback?: CommentfeedbackFeedback | null;
857+
feedback?: CommentfeedbackFeedback | null;
858858
};
859859
export type CommentCreateMutationVariables = {
860860
input: CommentCreateInput;
861861
first?: number | null;
862-
orderBy?: ReadonlyArray<string> | null;
862+
orderBy?: Array<string> | null;
863863
};
864864
export type CommentCreateMutationResponse = {
865865
readonly commentCreate: {
@@ -956,15 +956,15 @@ fragment InlineFragmentWithOverlappingFields on Actor {
956956
// TestMutation.graphql
957957
import { FragmentRefs } from "relay-runtime";
958958
export type CommentCreateInput = {
959-
readonly clientMutationId?: string | null;
960-
readonly feedbackId?: string | null;
961-
readonly feedback?: CommentfeedbackFeedback | null;
959+
clientMutationId?: string | null;
960+
feedbackId?: string | null;
961+
feedback?: CommentfeedbackFeedback | null;
962962
};
963963
export type CommentfeedbackFeedback = {
964-
readonly comment?: FeedbackcommentComment | null;
964+
comment?: FeedbackcommentComment | null;
965965
};
966966
export type FeedbackcommentComment = {
967-
readonly feedback?: CommentfeedbackFeedback | null;
967+
feedback?: CommentfeedbackFeedback | null;
968968
};
969969
export type TestMutationVariables = {
970970
input: CommentCreateInput;
@@ -1436,15 +1436,15 @@ export type ExampleFragment = {
14361436
14371437
// TestMutation.graphql
14381438
export type CommentCreateInput = {
1439-
readonly clientMutationId?: string | null;
1440-
readonly feedbackId?: string | null;
1441-
readonly feedback?: CommentfeedbackFeedback | null;
1439+
clientMutationId?: string | null;
1440+
feedbackId?: string | null;
1441+
feedback?: CommentfeedbackFeedback | null;
14421442
};
14431443
export type CommentfeedbackFeedback = {
1444-
readonly comment?: FeedbackcommentComment | null;
1444+
comment?: FeedbackcommentComment | null;
14451445
};
14461446
export type FeedbackcommentComment = {
1447-
readonly feedback?: CommentfeedbackFeedback | null;
1447+
feedback?: CommentfeedbackFeedback | null;
14481448
};
14491449
export type TestMutationVariables = {
14501450
input: CommentCreateInput;
@@ -1464,8 +1464,8 @@ export type TestMutation = {
14641464
14651465
// TestSubscription.graphql
14661466
export type FeedbackLikeInput = {
1467-
readonly clientMutationId?: string | null;
1468-
readonly feedbackId?: string | null;
1467+
clientMutationId?: string | null;
1468+
feedbackId?: string | null;
14691469
};
14701470
export type TestSubscriptionVariables = {
14711471
input?: FeedbackLikeInput | null;
@@ -2401,20 +2401,20 @@ mutation CommentCreateMutation(
24012401
~~~~~~~~~~ OUTPUT ~~~~~~~~~~
24022402
// CommentCreateMutation.graphql
24032403
export type CommentCreateInput = {
2404-
readonly clientMutationId?: string | null;
2405-
readonly feedbackId?: string | null;
2406-
readonly feedback?: CommentfeedbackFeedback | null;
2404+
clientMutationId?: string | null;
2405+
feedbackId?: string | null;
2406+
feedback?: CommentfeedbackFeedback | null;
24072407
};
24082408
export type CommentfeedbackFeedback = {
2409-
readonly comment?: FeedbackcommentComment | null;
2409+
comment?: FeedbackcommentComment | null;
24102410
};
24112411
export type FeedbackcommentComment = {
2412-
readonly feedback?: CommentfeedbackFeedback | null;
2412+
feedback?: CommentfeedbackFeedback | null;
24132413
};
24142414
export type CommentCreateMutationVariables = {
24152415
input: CommentCreateInput;
24162416
first?: number | null;
2417-
orderBy?: ReadonlyArray<string> | null;
2417+
orderBy?: Array<string> | null;
24182418
};
24192419
export type CommentCreateMutationResponse = {
24202420
readonly commentCreate: {
@@ -2447,8 +2447,8 @@ mutation InputHasArray($input: UpdateAllSeenStateInput) @raw_response_type {
24472447
~~~~~~~~~~ OUTPUT ~~~~~~~~~~
24482448
// InputHasArray.graphql
24492449
export type UpdateAllSeenStateInput = {
2450-
readonly clientMutationId?: string | null;
2451-
readonly storyIds?: ReadonlyArray<string | null> | null;
2450+
clientMutationId?: string | null;
2451+
storyIds?: Array<string | null> | null;
24522452
};
24532453
export type InputHasArrayVariables = {
24542454
input?: UpdateAllSeenStateInput | null;
@@ -2498,8 +2498,8 @@ type Foo {
24982498
~~~~~~~~~~ OUTPUT ~~~~~~~~~~
24992499
// Test.graphql
25002500
export type UpdateAllSeenStateInput = {
2501-
readonly clientMutationId?: string | null;
2502-
readonly storyIds?: ReadonlyArray<string | null> | null;
2501+
clientMutationId?: string | null;
2502+
storyIds?: Array<string | null> | null;
25032503
};
25042504
export type TestVariables = {
25052505
input?: UpdateAllSeenStateInput | null;
@@ -2566,20 +2566,20 @@ fragment FriendFragment on User {
25662566
import { FragmentRefs } from "relay-runtime";
25672567
export type TestEnums = "mark" | "zuck" | "%future added value";
25682568
export type CommentCreateInput = {
2569-
readonly clientMutationId?: string | null;
2570-
readonly feedbackId?: string | null;
2571-
readonly feedback?: CommentfeedbackFeedback | null;
2569+
clientMutationId?: string | null;
2570+
feedbackId?: string | null;
2571+
feedback?: CommentfeedbackFeedback | null;
25722572
};
25732573
export type CommentfeedbackFeedback = {
2574-
readonly comment?: FeedbackcommentComment | null;
2574+
comment?: FeedbackcommentComment | null;
25752575
};
25762576
export type FeedbackcommentComment = {
2577-
readonly feedback?: CommentfeedbackFeedback | null;
2577+
feedback?: CommentfeedbackFeedback | null;
25782578
};
25792579
export type CommentCreateMutationVariables = {
25802580
input: CommentCreateInput;
25812581
first?: number | null;
2582-
orderBy?: ReadonlyArray<string> | null;
2582+
orderBy?: Array<string> | null;
25832583
};
25842584
export type CommentCreateMutationResponse = {
25852585
readonly commentCreate: {
@@ -2674,20 +2674,20 @@ fragment FeedbackFragment on Feedback {
26742674
// CommentCreateMutation.graphql
26752675
import { FragmentRefs } from "relay-runtime";
26762676
export type CommentCreateInput = {
2677-
readonly clientMutationId?: string | null;
2678-
readonly feedbackId?: string | null;
2679-
readonly feedback?: CommentfeedbackFeedback | null;
2677+
clientMutationId?: string | null;
2678+
feedbackId?: string | null;
2679+
feedback?: CommentfeedbackFeedback | null;
26802680
};
26812681
export type CommentfeedbackFeedback = {
2682-
readonly comment?: FeedbackcommentComment | null;
2682+
comment?: FeedbackcommentComment | null;
26832683
};
26842684
export type FeedbackcommentComment = {
2685-
readonly feedback?: CommentfeedbackFeedback | null;
2685+
feedback?: CommentfeedbackFeedback | null;
26862686
};
26872687
export type CommentCreateMutationVariables = {
26882688
input: CommentCreateInput;
26892689
first?: number | null;
2690-
orderBy?: ReadonlyArray<string> | null;
2690+
orderBy?: Array<string> | null;
26912691
};
26922692
export type CommentCreateMutationResponse = {
26932693
readonly commentCreate: {
@@ -2784,15 +2784,15 @@ fragment InlineFragmentWithOverlappingFields on Actor {
27842784
// TestMutation.graphql
27852785
import { FragmentRefs } from "relay-runtime";
27862786
export type CommentCreateInput = {
2787-
readonly clientMutationId?: string | null;
2788-
readonly feedbackId?: string | null;
2789-
readonly feedback?: CommentfeedbackFeedback | null;
2787+
clientMutationId?: string | null;
2788+
feedbackId?: string | null;
2789+
feedback?: CommentfeedbackFeedback | null;
27902790
};
27912791
export type CommentfeedbackFeedback = {
2792-
readonly comment?: FeedbackcommentComment | null;
2792+
comment?: FeedbackcommentComment | null;
27932793
};
27942794
export type FeedbackcommentComment = {
2795-
readonly feedback?: CommentfeedbackFeedback | null;
2795+
feedback?: CommentfeedbackFeedback | null;
27962796
};
27972797
export type TestMutationVariables = {
27982798
input: CommentCreateInput;
@@ -3264,15 +3264,15 @@ export type ExampleFragment = {
32643264
32653265
// TestMutation.graphql
32663266
export type CommentCreateInput = {
3267-
readonly clientMutationId?: string | null;
3268-
readonly feedbackId?: string | null;
3269-
readonly feedback?: CommentfeedbackFeedback | null;
3267+
clientMutationId?: string | null;
3268+
feedbackId?: string | null;
3269+
feedback?: CommentfeedbackFeedback | null;
32703270
};
32713271
export type CommentfeedbackFeedback = {
3272-
readonly comment?: FeedbackcommentComment | null;
3272+
comment?: FeedbackcommentComment | null;
32733273
};
32743274
export type FeedbackcommentComment = {
3275-
readonly feedback?: CommentfeedbackFeedback | null;
3275+
feedback?: CommentfeedbackFeedback | null;
32763276
};
32773277
export type TestMutationVariables = {
32783278
input: CommentCreateInput;
@@ -3292,8 +3292,8 @@ export type TestMutation = {
32923292
32933293
// TestSubscription.graphql
32943294
export type FeedbackLikeInput = {
3295-
readonly clientMutationId?: string | null;
3296-
readonly feedbackId?: string | null;
3295+
clientMutationId?: string | null;
3296+
feedbackId?: string | null;
32973297
};
32983298
export type TestSubscriptionVariables = {
32993299
input?: FeedbackLikeInput | null;

0 commit comments

Comments
 (0)