Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Change type export #2827

Merged
merged 5 commits into from
Nov 13, 2024
Merged
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
6 changes: 6 additions & 0 deletions .changeset/odd-moons-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-inspector/core': minor
---

Added missing types to Change type and fix typo "DirectiveUsageInputObjectdRemovedChange" to
"DirectiveUsageInputObjectRemovedChange"
24 changes: 16 additions & 8 deletions packages/core/__tests__/diff/directive-usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,10 @@ describe('directive-usage', () => {

expect(changes.length).toEqual(1);
expect(change.criticality.level).toEqual(CriticalityLevel.Dangerous);
expect(change.type).toEqual('DIRECTIVE_USAGE_ARGUMENT_DEFINITION_ADDED');
expect(change.message).toEqual("Directive 'external' was added to argument 'a'");
expect(change.type).toEqual('DIRECTIVE_USAGE_INPUT_FIELD_DEFINITION_ADDED');
expect(change.message).toEqual(
"Directive 'external' was added to input field 'a' in input object 'Foo'",
);
});
test('removed directive', async () => {
const a = buildSchema(/* GraphQL */ `
Expand All @@ -479,8 +481,10 @@ describe('directive-usage', () => {

expect(changes.length).toEqual(1);
expect(change.criticality.level).toEqual(CriticalityLevel.Dangerous);
expect(change.type).toEqual('DIRECTIVE_USAGE_ARGUMENT_DEFINITION_REMOVED');
expect(change.message).toEqual("Directive 'external' was removed from input value 'Foo.a'");
expect(change.type).toEqual('DIRECTIVE_USAGE_INPUT_FIELD_DEFINITION_REMOVED');
expect(change.message).toEqual(
"Directive 'external' was removed from input field 'a' in input object 'Foo'",
);
});
});

Expand Down Expand Up @@ -634,7 +638,9 @@ describe('directive-usage', () => {

expect(change.criticality.level).toEqual(CriticalityLevel.Dangerous);
expect(change.type).toEqual('DIRECTIVE_USAGE_ARGUMENT_DEFINITION_ADDED');
expect(change.message).toEqual("Directive 'external' was added to argument 'a'");
expect(change.message).toEqual(
"Directive 'external' was added to argument 'a' of field 'a' in type 'Foo'",
);
});

test('removed directive', async () => {
Expand All @@ -656,7 +662,9 @@ describe('directive-usage', () => {

expect(change.criticality.level).toEqual(CriticalityLevel.Dangerous);
expect(change.type).toEqual('DIRECTIVE_USAGE_ARGUMENT_DEFINITION_REMOVED');
expect(change.message).toEqual("Directive 'external' was removed from argument 'Foo.a'");
expect(change.message).toEqual(
"Directive 'external' was removed from argument 'a' of field 'a' in type 'Foo'",
);
});
});

Expand Down Expand Up @@ -686,7 +694,7 @@ describe('directive-usage', () => {

expect(change.criticality.level).toEqual(CriticalityLevel.Dangerous);
expect(change.type).toEqual('DIRECTIVE_USAGE_SCHEMA_ADDED');
expect(change.message).toEqual("Directive 'external' was added to schema");
expect(change.message).toEqual("Directive 'external' was added to schema 'Foo'");
});
test('removed directive', async () => {
const a = buildSchema(/* GraphQL */ `
Expand All @@ -713,7 +721,7 @@ describe('directive-usage', () => {

expect(change.criticality.level).toEqual(CriticalityLevel.Dangerous);
expect(change.type).toEqual('DIRECTIVE_USAGE_SCHEMA_REMOVED');
expect(change.message).toEqual("Directive 'external' was removed from schema");
expect(change.message).toEqual("Directive 'external' was removed from schema 'Foo'");
});
});
});
19 changes: 16 additions & 3 deletions packages/core/src/diff/changes/change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ export type DirectiveUsageEnumValueRemovedChange = {
};
};

export type DirectiveUsageInputObjectdRemovedChange = {
export type DirectiveUsageInputObjectRemovedChange = {
type: typeof ChangeType.DirectiveUsageInputObjectRemoved;
meta: {
inputObjectName: string;
Expand Down Expand Up @@ -812,6 +812,17 @@ export type DirectiveUsageInterfaceRemovedChange = {
removedDirectiveName: string;
};
};

export type DirectiveUsageArgumentDefinitionAddedChange = {
type: typeof ChangeType.DirectiveUsageArgumentDefinitionAdded;
meta: {
typeName: string;
fieldName: string;
argumentName: string;
addedDirectiveName: string;
};
};

type Changes = {
[ChangeType.TypeAdded]: TypeAddedChange;
[ChangeType.TypeRemoved]: TypeRemovedChange;
Expand Down Expand Up @@ -892,7 +903,7 @@ type Changes = {
[ChangeType.DirectiveUsageEnumValueAdded]: DirectiveUsageEnumValueAddedChange;
[ChangeType.DirectiveUsageEnumValueRemoved]: DirectiveUsageEnumValueRemovedChange;
[ChangeType.DirectiveUsageInputObjectAdded]: DirectiveUsageInputObjectAddedChange;
[ChangeType.DirectiveUsageInputObjectRemoved]: DirectiveUsageInputObjectdRemovedChange;
[ChangeType.DirectiveUsageInputObjectRemoved]: DirectiveUsageInputObjectRemovedChange;
[ChangeType.DirectiveUsageFieldAdded]: DirectiveUsageFieldAddedChange;
[ChangeType.DirectiveUsageFieldRemoved]: DirectiveUsageFieldRemovedChange;
[ChangeType.DirectiveUsageScalarAdded]: DirectiveUsageScalarAddedChange;
Expand All @@ -901,12 +912,14 @@ type Changes = {
[ChangeType.DirectiveUsageObjectRemoved]: DirectiveUsageObjectRemovedChange;
[ChangeType.DirectiveUsageInterfaceAdded]: DirectiveUsageInterfaceAddedChange;
[ChangeType.DirectiveUsageInterfaceRemoved]: DirectiveUsageInterfaceRemovedChange;
[ChangeType.DirectiveUsageArgumentDefinitionAdded]: DirectiveUsageArgumentDefinitionChange;
[ChangeType.DirectiveUsageArgumentDefinitionAdded]: DirectiveUsageArgumentDefinitionAddedChange;
[ChangeType.DirectiveUsageArgumentDefinitionRemoved]: DirectiveUsageArgumentDefinitionRemovedChange;
[ChangeType.DirectiveUsageSchemaAdded]: DirectiveUsageSchemaAddedChange;
[ChangeType.DirectiveUsageSchemaRemoved]: DirectiveUsageSchemaRemovedChange;
[ChangeType.DirectiveUsageFieldDefinitionAdded]: DirectiveUsageFieldDefinitionAddedChange;
[ChangeType.DirectiveUsageFieldDefinitionRemoved]: DirectiveUsageFieldDefinitionRemovedChange;
[ChangeType.DirectiveUsageInputFieldDefinitionAdded]: DirectiveUsageInputFieldDefinitionAddedChange;
[ChangeType.DirectiveUsageInputFieldDefinitionRemoved]: DirectiveUsageInputFieldDefinitionRemovedChange;
};

export type SerializableChange = Changes[keyof Changes];
Loading
Loading