graphql/utilities/find_breaking_changes.py
def find_arg_changes(
    old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> BreakingAndDangerousChanges:
    """Find argument changes.

    Given two schemas, returns a list containing descriptions of any breaking or
    dangerous changes in the new_schema related to arguments (such as removal or change
    of type of an argument, or a change in an argument's default value).
    """
    old_type_map = old_schema.type_map
    new_type_map = new_schema.type_map

    breaking_changes: List[BreakingChange] = []
    dangerous_changes: List[DangerousChange] = []

    for type_name, old_type in old_type_map.items():
        new_type = new_type_map.get(type_name)
        if (
            not (is_object_type(old_type) or is_interface_type(old_type))
            or not (is_object_type(new_type) or is_interface_type(new_type))
            or new_type.__class__ is not old_type.__class__
        ):
            continue
        old_type = cast(Union[GraphQLObjectType, GraphQLInterfaceType], old_type)
        new_type = cast(Union[GraphQLObjectType, GraphQLInterfaceType], new_type)

        old_type_fields = old_type.fields
        new_type_fields = new_type.fields
        for field_name in old_type_fields:
            if field_name not in new_type_fields:
                continue

            old_args = old_type_fields[field_name].args
            new_args = new_type_fields[field_name].args
            for arg_name, old_arg in old_args.items():
                new_arg = new_args.get(arg_name)
                if not new_arg:
                    # Arg not present
                    breaking_changes.append(
                        BreakingChange(
                            BreakingChangeType.ARG_REMOVED,
                            f"{old_type.name}.{field_name} arg"
                            f" {arg_name} was removed",
                        )
                    )
                    continue
                is_safe = is_change_safe_for_input_object_field_or_field_arg(
                    old_arg.type, new_arg.type
                )
                if not is_safe:
                    breaking_changes.append(
                        BreakingChange(
                            BreakingChangeType.ARG_CHANGED_KIND,
                            f"{old_type.name}.{field_name} arg"
                            f" {arg_name} has changed type from"
                            f" {old_arg.type} to {new_arg.type}",
                        )
                    )
                elif (
                    old_arg.default_value is not INVALID
                    and old_arg.default_value != new_arg.default_value
                ):
                    dangerous_changes.append(
                        DangerousChange(
                            DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
                            f"{old_type.name}.{field_name} arg"
                            f" {arg_name} has changed defaultValue",
                        )
                    )

            # Check if arg was added to the field
            for arg_name in new_args:
                if arg_name not in old_args:
                    new_arg_def = new_args[arg_name]
                    if is_required_argument(new_arg_def):
                        breaking_changes.append(
                            BreakingChange(
                                BreakingChangeType.REQUIRED_ARG_ADDED,
                                f"A required arg {arg_name} on"
                                f" {type_name}.{field_name} was added",
                            )
                        )
                    else:
                        dangerous_changes.append(
                            DangerousChange(
                                DangerousChangeType.OPTIONAL_ARG_ADDED,
                                f"An optional arg {arg_name} on"
                                f" {type_name}.{field_name} was added",
                            )
                        )

    return BreakingAndDangerousChanges(breaking_changes, dangerous_changes)
Find argument changes.

    Given two schemas, returns a list containing descriptions of any breaking or
    dangerous changes in the new_schema related to arguments (such as removal or change
    of type of an argument, or a change in an argument's default value).
    
Find argument changes.
Given two schemas, returns a list containing descriptions of any breaking or
dangerous changes in the new_schema related to arguments (such as removal or change
of type of an argument, or a change in an argument's default value).
Find argument changes . Given two schemas returns a list containing descriptions of any breaking or dangerous changes in the new_schema related to arguments ( such as removal or change of type of an argument or a change in an argument ' s default value ) .
def find_arg_changes(
    old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> BreakingAndDangerousChanges:
    old_type_map = old_schema.type_map
    new_type_map = new_schema.type_map
    breaking_changes: List[BreakingChange] = []
    dangerous_changes: List[DangerousChange] = []
    for type_name, old_type in old_type_map.items():
        new_type = new_type_map.get(type_name)
        if (
            not (is_object_type(old_type) or is_interface_type(old_type))
            or not (is_object_type(new_type) or is_interface_type(new_type))
            or new_type.__class__ is not old_type.__class__
        ):
            continue
        old_type = cast(Union[GraphQLObjectType, GraphQLInterfaceType], old_type)
        new_type = cast(Union[GraphQLObjectType, GraphQLInterfaceType], new_type)
        old_type_fields = old_type.fields
        new_type_fields = new_type.fields
        for field_name in old_type_fields:
            if field_name not in new_type_fields:
                continue
            old_args = old_type_fields[field_name].args
            new_args = new_type_fields[field_name].args
            for arg_name, old_arg in old_args.items():
                new_arg = new_args.get(arg_name)
                if not new_arg:
                    breaking_changes.append(
                        BreakingChange(
                            BreakingChangeType.ARG_REMOVED,
                            f"{old_type.name}.{field_name} arg"
                            f" {arg_name} was removed",
                        )
                    )
                    continue
                is_safe = is_change_safe_for_input_object_field_or_field_arg(
                    old_arg.type, new_arg.type
                )
                if not is_safe:
                    breaking_changes.append(
                        BreakingChange(
                            BreakingChangeType.ARG_CHANGED_KIND,
                            f"{old_type.name}.{field_name} arg"
                            f" {arg_name} has changed type from"
                            f" {old_arg.type} to {new_arg.type}",
                        )
                    )
                elif (
                    old_arg.default_value is not INVALID
                    and old_arg.default_value != new_arg.default_value
                ):
                    dangerous_changes.append(
                        DangerousChange(
                            DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
                            f"{old_type.name}.{field_name} arg"
                            f" {arg_name} has changed defaultValue",
                        )
                    )
            for arg_name in new_args:
                if arg_name not in old_args:
                    new_arg_def = new_args[arg_name]
                    if is_required_argument(new_arg_def):
                        breaking_changes.append(
                            BreakingChange(
                                BreakingChangeType.REQUIRED_ARG_ADDED,
                                f"A required arg {arg_name} on"
                                f" {type_name}.{field_name} was added",
                            )
                        )
                    else:
                        dangerous_changes.append(
                            DangerousChange(
                                DangerousChangeType.OPTIONAL_ARG_ADDED,
                                f"An optional arg {arg_name} on"
                                f" {type_name}.{field_name} was added",
                            )
                        )
    return BreakingAndDangerousChanges(breaking_changes, dangerous_changes)
def find_arg_changes ( old_schema : GraphQLSchema , new_schema : GraphQLSchema ) -> BreakingAndDangerousChanges : old_type_map = old_schema . type_map new_type_map = new_schema . type_map breaking_changes : List [ BreakingChange ] = [ ] dangerous_changes : List [ DangerousChange ] = [ ] for type_name , old_type in old_type_map . items ( ) : new_type = new_type_map . get ( type_name ) if ( not ( is_object_type ( old_type ) or is_interface_type ( old_type ) ) or not ( is_object_type ( new_type ) or is_interface_type ( new_type ) ) or new_type . __class__ is not old_type . __class__ ) : continue old_type = cast ( Union [ GraphQLObjectType , GraphQLInterfaceType ] , old_type ) new_type = cast ( Union [ GraphQLObjectType , GraphQLInterfaceType ] , new_type ) old_type_fields = old_type . fields new_type_fields = new_type . fields for field_name in old_type_fields : if field_name not in new_type_fields : continue old_args = old_type_fields [ field_name ] . args new_args = new_type_fields [ field_name ] . args for arg_name , old_arg in old_args . items ( ) : new_arg = new_args . get ( arg_name ) if not new_arg : breaking_changes . append ( BreakingChange ( BreakingChangeType . ARG_REMOVED , f"{old_type.name}.{field_name} arg" f" {arg_name} was removed" , ) ) continue is_safe = is_change_safe_for_input_object_field_or_field_arg ( old_arg . type , new_arg . type ) if not is_safe : breaking_changes . append ( BreakingChange ( BreakingChangeType . ARG_CHANGED_KIND , f"{old_type.name}.{field_name} arg" f" {arg_name} has changed type from" f" {old_arg.type} to {new_arg.type}" , ) ) elif ( old_arg . default_value is not INVALID and old_arg . default_value != new_arg . default_value ) : dangerous_changes . append ( DangerousChange ( DangerousChangeType . ARG_DEFAULT_VALUE_CHANGE , f"{old_type.name}.{field_name} arg" f" {arg_name} has changed defaultValue" , ) ) for arg_name in new_args : if arg_name not in old_args : new_arg_def = new_args [ arg_name ] if is_required_argument ( new_arg_def ) : breaking_changes . append ( BreakingChange ( BreakingChangeType . REQUIRED_ARG_ADDED , f"A required arg {arg_name} on" f" {type_name}.{field_name} was added" , ) ) else : dangerous_changes . append ( DangerousChange ( DangerousChangeType . OPTIONAL_ARG_ADDED , f"An optional arg {arg_name} on" f" {type_name}.{field_name} was added" , ) ) return BreakingAndDangerousChanges ( breaking_changes , dangerous_changes )
Find argument changes.
Find argument changes .
"""Find argument changes.

    Given two schemas, returns a list containing descriptions of any breaking or
    dangerous changes in the new_schema related to arguments (such as removal or change
    of type of an argument, or a change in an argument's default value).
    """ # Arg not present # Check if arg was added to the field
old_schema
GraphQLSchema
new_schema
GraphQLSchema