|
8 | 8 | isNonNullType, |
9 | 9 | } from 'graphql'; |
10 | 10 | import { safeChangeForField } from '../../utils/graphql.js'; |
| 11 | +import { fmt } from '../../utils/string.js'; |
11 | 12 | import { |
12 | 13 | Change, |
13 | 14 | ChangeType, |
@@ -97,7 +98,13 @@ export function fieldAdded( |
97 | 98 | } |
98 | 99 |
|
99 | 100 | function buildFieldDescriptionChangedMessage(args: FieldDescriptionChangedChange['meta']) { |
100 | | - return `Field '${args.typeName}.${args.fieldName}' description changed from '${args.oldDescription}' to '${args.newDescription}'`; |
| 101 | + if (!args.oldDescription && args.newDescription) { |
| 102 | + return `Field '${args.typeName}.${args.fieldName}' description '${fmt(args.newDescription)}' was added`; |
| 103 | + } |
| 104 | + if (!args.newDescription && args.oldDescription) { |
| 105 | + return `Field '${args.typeName}.${args.fieldName}' description '${fmt(args.oldDescription)}' was removed`; |
| 106 | + } |
| 107 | + return `Field '${args.typeName}.${args.fieldName}' description changed from '${fmt(args.oldDescription)}' to '${fmt(args.newDescription)}'`; |
101 | 108 | } |
102 | 109 |
|
103 | 110 | export function fieldDescriptionChangedFromMeta(args: FieldDescriptionChangedChange) { |
@@ -129,7 +136,8 @@ export function fieldDescriptionChanged( |
129 | 136 | } |
130 | 137 |
|
131 | 138 | function buildFieldDescriptionAddedMessage(args: FieldDescriptionAddedChange['meta']) { |
132 | | - return `Field '${args.typeName}.${args.fieldName}' has description '${args.addedDescription}'`; |
| 139 | + const desc = fmt(args.addedDescription); |
| 140 | + return `Field '${args.typeName}.${args.fieldName}' has description '${desc}'`; |
133 | 141 | } |
134 | 142 |
|
135 | 143 | export function fieldDescriptionAddedFromMeta(args: FieldDescriptionAddedChange) { |
@@ -249,7 +257,9 @@ export function fieldDeprecationRemoved( |
249 | 257 | function buildFieldDeprecationReasonChangedMessage( |
250 | 258 | args: FieldDeprecationReasonChangedChange['meta'], |
251 | 259 | ) { |
252 | | - return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${args.oldDeprecationReason}' to '${args.newDeprecationReason}'`; |
| 260 | + const oldReason = fmt(args.oldDeprecationReason); |
| 261 | + const newReason = fmt(args.newDeprecationReason); |
| 262 | + return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${oldReason}' to '${newReason}'`; |
253 | 263 | } |
254 | 264 |
|
255 | 265 | export function fieldDeprecationReasonChangedFromMeta(args: FieldDeprecationReasonChangedChange) { |
@@ -283,7 +293,8 @@ export function fieldDeprecationReasonChanged( |
283 | 293 | } |
284 | 294 |
|
285 | 295 | function buildFieldDeprecationReasonAddedMessage(args: FieldDeprecationReasonAddedChange['meta']) { |
286 | | - return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${args.addedDeprecationReason}'`; |
| 296 | + const reason = fmt(args.addedDeprecationReason); |
| 297 | + return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${reason}'`; |
287 | 298 | } |
288 | 299 |
|
289 | 300 | export function fieldDeprecationReasonAddedFromMeta(args: FieldDeprecationReasonAddedChange) { |
|
0 commit comments