MCPcopy Create free account
hub / github.com/openai/plugins / findArgChanges

Function findArgChanges

plugins/shopify/skills/shopify-admin/scripts/validate.mjs:15439–15490  ·  view source on GitHub ↗
(oldType, oldField, newField)

Source from the content-addressed store, hash-verified

15437 return schemaChanges;
15438 }
15439 function findArgChanges(oldType, oldField, newField) {
15440 const schemaChanges = [];
15441 const argsDiff = diff(oldField.args, newField.args);
15442 for (const oldArg of argsDiff.removed) {
15443 schemaChanges.push({
15444 type: BreakingChangeType.ARG_REMOVED,
15445 description: `${oldType.name}.${oldField.name} arg ${oldArg.name} was removed.`
15446 });
15447 }
15448 for (const [oldArg, newArg] of argsDiff.persisted) {
15449 const isSafe = isChangeSafeForInputObjectFieldOrFieldArg(
15450 oldArg.type,
15451 newArg.type
15452 );
15453 if (!isSafe) {
15454 schemaChanges.push({
15455 type: BreakingChangeType.ARG_CHANGED_KIND,
15456 description: `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed type from ${String(oldArg.type)} to ${String(newArg.type)}.`
15457 });
15458 } else if (oldArg.defaultValue !== void 0) {
15459 if (newArg.defaultValue === void 0) {
15460 schemaChanges.push({
15461 type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
15462 description: `${oldType.name}.${oldField.name} arg ${oldArg.name} defaultValue was removed.`
15463 });
15464 } else {
15465 const oldValueStr = stringifyValue(oldArg.defaultValue, oldArg.type);
15466 const newValueStr = stringifyValue(newArg.defaultValue, newArg.type);
15467 if (oldValueStr !== newValueStr) {
15468 schemaChanges.push({
15469 type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
15470 description: `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed defaultValue from ${oldValueStr} to ${newValueStr}.`
15471 });
15472 }
15473 }
15474 }
15475 }
15476 for (const newArg of argsDiff.added) {
15477 if ((0, _definition.isRequiredArgument)(newArg)) {
15478 schemaChanges.push({
15479 type: BreakingChangeType.REQUIRED_ARG_ADDED,
15480 description: `A required arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`
15481 });
15482 } else {
15483 schemaChanges.push({
15484 type: DangerousChangeType.OPTIONAL_ARG_ADDED,
15485 description: `An optional arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`
15486 });
15487 }
15488 }
15489 return schemaChanges;
15490 }
15491 function isChangeSafeForObjectOrInterfaceField(oldType, newType) {
15492 if ((0, _definition.isListType)(oldType)) {
15493 return (

Callers 1

findFieldChangesFunction · 0.70

Calls 3

diffFunction · 0.70
stringifyValueFunction · 0.70

Tested by

no test coverage detected