Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-pumas-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-inspector/core": patch
---

Escape single quotes in diff change messages for the rest of descriptions and deprecation reasons
6 changes: 4 additions & 2 deletions packages/core/src/diff/changes/argument.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GraphQLArgument, GraphQLField, GraphQLInterfaceType, GraphQLObjectType } from 'graphql';
import { safeChangeForInputValue } from '../../utils/graphql.js';
import { safeString } from '../../utils/string.js';
import { fmt, safeString } from '../../utils/string.js';
import {
Change,
ChangeType,
Expand All @@ -13,7 +13,9 @@ import {
function buildFieldArgumentDescriptionChangedMessage(
args: FieldArgumentDescriptionChangedChange['meta'],
): string {
return `Description for argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}' changed from '${args.oldDescription}' to '${args.newDescription}'`;
const oldDesc = fmt(args.oldDescription ?? 'undefined');
const newDesc = fmt(args.newDescription ?? 'undefined');
return `Description for argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}' changed from '${oldDesc}' to '${newDesc}'`;
}

export function fieldArgumentDescriptionChangedFromMeta(
Expand Down
12 changes: 7 additions & 5 deletions packages/core/src/diff/changes/directive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DirectiveLocationEnum, GraphQLArgument, GraphQLDirective, isNonNullType } from 'graphql';
import { safeChangeForInputValue } from '../../utils/graphql.js';
import { safeString } from '../../utils/string.js';
import { fmt, safeString } from '../../utils/string.js';
import {
Change,
ChangeType,
Expand Down Expand Up @@ -82,9 +82,9 @@ export function directiveAdded(
function buildDirectiveDescriptionChangedMessage(
args: DirectiveDescriptionChangedChange['meta'],
): string {
return `Directive '${args.directiveName}' description changed from '${
args.oldDirectiveDescription ?? 'undefined'
}' to '${args.newDirectiveDescription ?? 'undefined'}'`;
const oldDesc = fmt(args.oldDirectiveDescription ?? 'undefined');
const newDesc = fmt(args.newDirectiveDescription ?? 'undefined');
return `Directive '${args.directiveName}' description changed from '${oldDesc}' to '${newDesc}'`;
}

export function directiveDescriptionChangedFromMeta(args: DirectiveDescriptionChangedChange) {
Expand Down Expand Up @@ -314,7 +314,9 @@ export function directiveArgumentRemoved(
function buildDirectiveArgumentDescriptionChangedMessage(
args: DirectiveArgumentDescriptionChangedChange['meta'],
): string {
return `Description for argument '${args.directiveArgumentName}' on directive '${args.directiveName}' changed from '${args.oldDirectiveArgumentDescription}' to '${args.newDirectiveArgumentDescription}'`;
const oldDesc = fmt(args.oldDirectiveArgumentDescription ?? 'undefined');
const newDesc = fmt(args.newDirectiveArgumentDescription ?? 'undefined');
return `Description for argument '${args.directiveArgumentName}' on directive '${args.directiveName}' changed from '${oldDesc}' to '${newDesc}'`;
}

export function directiveArgumentDescriptionChangedFromMeta(
Expand Down
15 changes: 11 additions & 4 deletions packages/core/src/diff/changes/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isNonNullType,
} from 'graphql';
import { safeChangeForField } from '../../utils/graphql.js';
import { fmt } from '../../utils/string.js';
import {
Change,
ChangeType,
Expand Down Expand Up @@ -97,7 +98,9 @@ export function fieldAdded(
}

function buildFieldDescriptionChangedMessage(args: FieldDescriptionChangedChange['meta']) {
return `Field '${args.typeName}.${args.fieldName}' description changed from '${args.oldDescription}' to '${args.newDescription}'`;
const oldDesc = fmt(args.oldDescription || 'undefined');
const newDesc = fmt(args.newDescription || 'undefined');
return `Field '${args.typeName}.${args.fieldName}' description changed from '${oldDesc}' to '${newDesc}'`;
}

export function fieldDescriptionChangedFromMeta(args: FieldDescriptionChangedChange) {
Expand Down Expand Up @@ -129,7 +132,8 @@ export function fieldDescriptionChanged(
}

function buildFieldDescriptionAddedMessage(args: FieldDescriptionAddedChange['meta']) {
return `Field '${args.typeName}.${args.fieldName}' has description '${args.addedDescription}'`;
const desc = fmt(args.addedDescription);
return `Field '${args.typeName}.${args.fieldName}' has description '${desc}'`;
}

export function fieldDescriptionAddedFromMeta(args: FieldDescriptionAddedChange) {
Expand Down Expand Up @@ -249,7 +253,9 @@ export function fieldDeprecationRemoved(
function buildFieldDeprecationReasonChangedMessage(
args: FieldDeprecationReasonChangedChange['meta'],
) {
return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${args.oldDeprecationReason}' to '${args.newDeprecationReason}'`;
const oldReason = fmt(args.oldDeprecationReason);
const newReason = fmt(args.newDeprecationReason);
return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${oldReason}' to '${newReason}'`;
}

export function fieldDeprecationReasonChangedFromMeta(args: FieldDeprecationReasonChangedChange) {
Expand Down Expand Up @@ -283,7 +289,8 @@ export function fieldDeprecationReasonChanged(
}

function buildFieldDeprecationReasonAddedMessage(args: FieldDeprecationReasonAddedChange['meta']) {
return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${args.addedDeprecationReason}'`;
const reason = fmt(args.addedDeprecationReason);
return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${reason}'`;
}

export function fieldDeprecationReasonAddedFromMeta(args: FieldDeprecationReasonAddedChange) {
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/diff/changes/input.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GraphQLInputField, GraphQLInputObjectType, isNonNullType } from 'graphql';
import { safeChangeForInputValue } from '../../utils/graphql.js';
import { isDeprecated } from '../../utils/is-deprecated.js';
import { safeString } from '../../utils/string.js';
import { fmt, safeString } from '../../utils/string.js';
import {
Change,
ChangeType,
Expand Down Expand Up @@ -95,7 +95,8 @@ export function inputFieldAdded(
}

function buildInputFieldDescriptionAddedMessage(args: InputFieldDescriptionAddedChange['meta']) {
return `Input field '${args.inputName}.${args.inputFieldName}' has description '${args.addedInputFieldDescription}'`;
const desc = fmt(args.addedInputFieldDescription);
return `Input field '${args.inputName}.${args.inputFieldName}' has description '${desc}'`;
}

export function inputFieldDescriptionAddedFromMeta(args: InputFieldDescriptionAddedChange) {
Expand Down Expand Up @@ -127,7 +128,8 @@ export function inputFieldDescriptionAdded(
function buildInputFieldDescriptionRemovedMessage(
args: InputFieldDescriptionRemovedChange['meta'],
) {
return `Description '${args.removedDescription}' was removed from input field '${args.inputName}.${args.inputFieldName}'`;
const desc = fmt(args.removedDescription);
return `Description '${desc}' was removed from input field '${args.inputName}.${args.inputFieldName}'`;
}

export function inputFieldDescriptionRemovedFromMeta(args: InputFieldDescriptionRemovedChange) {
Expand Down Expand Up @@ -159,7 +161,9 @@ export function inputFieldDescriptionRemoved(
function buildInputFieldDescriptionChangedMessage(
args: InputFieldDescriptionChangedChange['meta'],
) {
return `Input field '${args.inputName}.${args.inputFieldName}' description changed from '${args.oldInputFieldDescription}' to '${args.newInputFieldDescription}'`;
const oldDesc = fmt(args.oldInputFieldDescription);
const newDesc = fmt(args.newInputFieldDescription);
return `Input field '${args.inputName}.${args.inputFieldName}' description changed from '${oldDesc}' to '${newDesc}'`;
}

export function inputFieldDescriptionChangedFromMeta(args: InputFieldDescriptionChangedChange) {
Expand Down
11 changes: 8 additions & 3 deletions packages/core/src/diff/changes/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type GraphQLNamedType,
} from 'graphql';
import { getKind } from '../../utils/graphql.js';
import { fmt } from '../../utils/string.js';
import {
Change,
ChangeType,
Expand Down Expand Up @@ -134,7 +135,9 @@ export function typeKindChanged(
}

function buildTypeDescriptionChangedMessage(args: TypeDescriptionChangedChange['meta']): string {
return `Description '${args.oldTypeDescription}' on type '${args.typeName}' has changed to '${args.newTypeDescription}'`;
const oldDesc = fmt(args.oldTypeDescription);
const newDesc = fmt(args.newTypeDescription);
return `Description '${oldDesc}' on type '${args.typeName}' has changed to '${newDesc}'`;
}

export function typeDescriptionChangedFromMeta(args: TypeDescriptionChangedChange) {
Expand Down Expand Up @@ -164,7 +167,8 @@ export function typeDescriptionChanged(
}

function buildTypeDescriptionRemoved(args: TypeDescriptionRemovedChange['meta']): string {
return `Description '${args.removedTypeDescription}' was removed from object type '${args.typeName}'`;
const desc = fmt(args.removedTypeDescription);
return `Description '${desc}' was removed from object type '${args.typeName}'`;
}

export function typeDescriptionRemovedFromMeta(args: TypeDescriptionRemovedChange) {
Expand Down Expand Up @@ -192,7 +196,8 @@ export function typeDescriptionRemoved(
}

function buildTypeDescriptionAddedMessage(args: TypeDescriptionAddedChange['meta']): string {
return `Object type '${args.typeName}' has description '${args.addedTypeDescription}'`;
const desc = fmt(args.addedTypeDescription);
return `Object type '${args.typeName}' has description '${desc}'`;
}

export function typeDescriptionAddedFromMeta(args: TypeDescriptionAddedChange) {
Expand Down
Loading