Skip to content

Commit 528b009

Browse files
committed
chore: improve comment to align with autogenerated deprecation comment
1 parent e216a01 commit 528b009

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

protographic/src/sdl-to-proto-visitor.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,9 @@ Example:
11601160
}
11611161

11621162
if (deprecationInfo.deprecated && deprecationInfo.reason && deprecationInfo.reason.length > 0) {
1163-
this.protoText.push(...this.formatComment(`Deprecated: ${deprecationInfo.reason}`, 1));
1163+
this.protoText.push(
1164+
...this.formatComment(`Field ${protoFieldName} is deprecated: ${deprecationInfo.reason}`, 1),
1165+
);
11641166
}
11651167

11661168
const fieldOptions = [];
@@ -1297,7 +1299,9 @@ Example:
12971299
}
12981300

12991301
if (deprecationInfo.deprecated && deprecationInfo.reason && deprecationInfo.reason.length > 0) {
1300-
this.protoText.push(...this.formatComment(`Deprecated: ${deprecationInfo.reason}`, 1));
1302+
this.protoText.push(
1303+
...this.formatComment(`Field ${protoFieldName} is deprecated: ${deprecationInfo.reason}`, 1),
1304+
);
13011305
}
13021306

13031307
const fieldOptions = [];
@@ -1505,7 +1509,9 @@ Example:
15051509
}
15061510

15071511
if (deprecationInfo.deprecated && (deprecationInfo.reason?.length ?? 0) > 0) {
1508-
this.protoText.push(...this.formatComment(`Deprecated: ${deprecationInfo.reason}`, 1));
1512+
this.protoText.push(
1513+
...this.formatComment(`Enum value ${protoEnumValue} is deprecated: ${deprecationInfo.reason}`, 1),
1514+
);
15091515
}
15101516

15111517
// Get value number from lock data

protographic/tests/sdl-to-proto/12-directive.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('SDL to Proto Directive', () => {
2727
2828
message User {
2929
string id = 1;
30-
// Deprecated: This field is deprecated
30+
// Field first_name is deprecated: This field is deprecated
3131
string first_name = 2 [deprecated = true];
3232
string last_name = 3;
3333
}"
@@ -72,7 +72,7 @@ describe('SDL to Proto Directive', () => {
7272
7373
message User {
7474
string id = 1;
75-
// Deprecated: This field is deprecated
75+
// Field created_at is deprecated: This field is deprecated
7676
string created_at = 2 [deprecated = true];
7777
string updated_at = 3;
7878
}"
@@ -117,7 +117,7 @@ describe('SDL to Proto Directive', () => {
117117
118118
message User {
119119
string id = 1;
120-
// Deprecated: This field is deprecated on the field
120+
// Field created_at is deprecated: This field is deprecated on the field
121121
string created_at = 2 [deprecated = true];
122122
string updated_at = 3;
123123
}"
@@ -162,7 +162,7 @@ describe('SDL to Proto Directive', () => {
162162
163163
message User {
164164
string id = 1;
165-
// Deprecated: This field is deprecated on the interface
165+
// Field created_at is deprecated: This field is deprecated on the interface
166166
string created_at = 2 [deprecated = true];
167167
string updated_at = 3;
168168
}"
@@ -193,10 +193,10 @@ describe('SDL to Proto Directive', () => {
193193
194194
enum UserRole {
195195
USER_ROLE_UNSPECIFIED = 0;
196-
// Deprecated: This role is deprecated
196+
// Enum value USER_ROLE_ADMIN is deprecated: This role is deprecated
197197
USER_ROLE_ADMIN = 1 [deprecated = true];
198198
USER_ROLE_USER = 2;
199-
// Deprecated: This role is deprecated
199+
// Enum value USER_ROLE_GUEST is deprecated: This role is deprecated
200200
USER_ROLE_GUEST = 3 [deprecated = true];
201201
}"
202202
`);
@@ -226,7 +226,7 @@ describe('SDL to Proto Directive', () => {
226226
227227
enum UserRole {
228228
USER_ROLE_UNSPECIFIED = 0;
229-
// Deprecated: This role is deprecated
229+
// Enum value USER_ROLE_ADMIN is deprecated: This role is deprecated
230230
USER_ROLE_ADMIN = 1 [deprecated = true];
231231
USER_ROLE_USER = 2;
232232
USER_ROLE_GUEST = 3 [deprecated = true];
@@ -257,7 +257,7 @@ describe('SDL to Proto Directive', () => {
257257
258258
message UserInput {
259259
string id = 1;
260-
// Deprecated: This field is deprecated
260+
// Field name is deprecated: This field is deprecated
261261
string name = 2 [deprecated = true];
262262
}"
263263
`);
@@ -352,12 +352,12 @@ describe('SDL to Proto Directive', () => {
352352
353353
message UserInput {
354354
string id = 1;
355-
// Deprecated: Use fullName instead
355+
// Field first_name is deprecated: Use fullName instead
356356
string first_name = 2 [deprecated = true];
357-
// Deprecated: Use fullName instead
357+
// Field last_name is deprecated: Use fullName instead
358358
string last_name = 3 [deprecated = true];
359359
string full_name = 4;
360-
// Deprecated: This field will be removed
360+
// Field age is deprecated: This field will be removed
361361
google.protobuf.Int32Value age = 5 [deprecated = true];
362362
string email = 6;
363363
}"
@@ -397,7 +397,7 @@ describe('SDL to Proto Directive', () => {
397397
message AddressInput {
398398
string street = 1;
399399
string city = 2;
400-
// Deprecated: Use postalCode instead
400+
// Field zip_code is deprecated: Use postalCode instead
401401
string zip_code = 3 [deprecated = true];
402402
string postal_code = 4;
403403
}
@@ -406,7 +406,7 @@ describe('SDL to Proto Directive', () => {
406406
string id = 1;
407407
string name = 2;
408408
AddressInput address = 3;
409-
// Deprecated: This field is no longer needed
409+
// Field old_address is deprecated: This field is no longer needed
410410
AddressInput old_address = 4 [deprecated = true];
411411
}"
412412
`);
@@ -455,12 +455,12 @@ describe('SDL to Proto Directive', () => {
455455
message UserInput {
456456
string id = 1;
457457
string name = 2;
458-
// Deprecated: Use roles array instead
458+
// Field role is deprecated: Use roles array instead
459459
UserRole role = 3 [deprecated = true];
460460
repeated UserRole roles = 4;
461-
// Deprecated: Use status field instead
461+
// Field is_active is deprecated: Use status field instead
462462
bool is_active = 5 [deprecated = true];
463-
// Deprecated: This field is deprecated
463+
// Field metadata is deprecated: This field is deprecated
464464
google.protobuf.StringValue metadata = 6 [deprecated = true];
465465
}"
466466
`);

0 commit comments

Comments
 (0)