py_gql.utilities.diff_schema#

Utilities to compare 2 GraphQL schema for incompatibilities.

class py_gql.utilities.diff_schema.DirectiveAdded(directive)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = 'Directive {self.directive.name} was added.'#
class py_gql.utilities.diff_schema.DirectiveArgumentAdded(directive, argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

format_str = '{self.required_str} argument {self.argument.name} was added to directive {self.directive.name}.'#
class py_gql.utilities.diff_schema.DirectiveArgumentChangedType(directive, old_argument, new_argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Argument {self.old_argument.name} of directive {self.directive.name} has changed type from {self.old_argument.type} to {self.new_argument.type}.'#
class py_gql.utilities.diff_schema.DirectiveArgumentDefaultValueChange(directive, old_argument, new_argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 1#
format_str = 'Argument {self.old_argument.name} of directive {self.directive.name} has changed default value.'#
class py_gql.utilities.diff_schema.DirectiveArgumentRemoved(directive, argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Argument {self.argument.name} was removed from directive {self.directive.name}.'#
class py_gql.utilities.diff_schema.DirectiveLocationAdded(directive, location)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = 'Location {self.location} was added to directive {self.directive.name}.'#
class py_gql.utilities.diff_schema.DirectiveLocationRemoved(directive, location)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Location {self.location} was removed from directive {self.directive.name}.'#
class py_gql.utilities.diff_schema.DirectiveRemoved(directive)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Directive {self.directive.name} was removed.'#
class py_gql.utilities.diff_schema.EnumValueAdded(enum, value)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 1#
format_str = '{self.value.name} was added to enum {self.enum.name}.'#
class py_gql.utilities.diff_schema.EnumValueDeprecated(enum, old_value, new_value)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = '{self.old_value.name} from enum {self.enum.name} was deprecated.'#
class py_gql.utilities.diff_schema.EnumValueDeprecationReasonChanged(enum, old_value, new_value)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = '{self.old_value.name} from enum {self.enum.name} has changed deprecation reason.'#
class py_gql.utilities.diff_schema.EnumValueDeprecationRemoved(enum, old_value, new_value)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = '{self.old_value.name} from enum {self.enum.name} is no longer deprecated.'#
class py_gql.utilities.diff_schema.EnumValueRemoved(enum, value)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = '{self.value.name} was removed from enum {self.enum.name}.'#
class py_gql.utilities.diff_schema.FieldAdded(parent_type, field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = 'Field {self.field.name} was added to {self.context_str} {self.type.name}.'#
class py_gql.utilities.diff_schema.FieldArgumentAdded(parent_type, field, argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

format_str = '{self.required_str} argument {self.argument.name} was added to field {self.field.name} of {self.context_str} {self.type.name}.'#
class py_gql.utilities.diff_schema.FieldArgumentChangedType(parent_type, field, old_argument, new_argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Argument {self.old_argument.name} of field {self.field.name} of {self.context_str} {self.type.name} has changed type from {self.old_argument.type} to {self.new_argument.type}.'#
class py_gql.utilities.diff_schema.FieldArgumentDefaultValueChange(parent_type, field, old_argument, new_argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 1#
format_str = 'Argument {self.old_argument.name} of field {self.field.name} of {self.context_str} {self.type.name} has changed default value.'#
class py_gql.utilities.diff_schema.FieldArgumentRemoved(parent_type, field, argument)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Argument {self.argument.name} was removed from field {self.field.name} of {self.context_str} {self.type.name}.'#
class py_gql.utilities.diff_schema.FieldChangedType(parent_type, old_field, new_field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Field {self.old_field.name} of {self.context_str} {self.type.name} has changed type from {self.old_field.type} to {self.new_field.type}.'#
class py_gql.utilities.diff_schema.FieldDeprecated(parent_type, old_field, new_field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = 'Field {self.old_field.name} of {self.context_str} {self.type.name} was deprecated.'#
class py_gql.utilities.diff_schema.FieldDeprecationReasonChanged(parent_type, old_field, new_field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = 'Field {self.old_field.name} of {self.context_str} {self.type.name} has changed deprecation reason.'#
class py_gql.utilities.diff_schema.FieldDeprecationRemoved(parent_type, old_field, new_field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = 'Field {self.old_field.name} of {self.context_str} {self.type.name} is no longer deprecated.'#
class py_gql.utilities.diff_schema.FieldRemoved(parent_type, field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Field {self.field.name} was removed from {self.context_str} {self.type.name}.'#
class py_gql.utilities.diff_schema.InputFieldAdded(input_type, field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

format_str = '{self.required_str} input field {self.field.name} was added to {self.type.name}.'#
severity = 2#
class py_gql.utilities.diff_schema.InputFieldChangedType(input_type, old_field, new_field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Input field {self.old_field.name} of {self.type.name} has changed type from {self.old_field.type} to {self.new_field.type}.'#
class py_gql.utilities.diff_schema.InputFieldDefaultValueChange(input_type, old_field, new_field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 1#
format_str = 'Input field {self.old_field.name} of {self.type.name} has changed default value.'#
class py_gql.utilities.diff_schema.InputFieldRemoved(input_type, field)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Input field {self.field.name} was removed from {self.type.name}.'#
class py_gql.utilities.diff_schema.SchemaChange[source]#

Bases: object

severity = NotImplemented#
format_str = NotImplemented#
property message#
Return type

str

class py_gql.utilities.diff_schema.SchemaChangeSeverity[source]#

Bases: enum.IntEnum

Severity level of a schema change.

COMPATIBLE = 0#

Change should be safe for all clients.

DANGEROUS = 1#

Change could break some clients or create silent issues depending on which part of the schema they use.

BREAKING = 2#

Change will break most clients.

class py_gql.utilities.diff_schema.TypeAdded(type_name)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 0#
format_str = 'Type {self.type_name} was added.'#
class py_gql.utilities.diff_schema.TypeAddedToInterface(interface, object_type)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 1#
format_str = '{self.type.name} now implements {self.interface.name}.'#
class py_gql.utilities.diff_schema.TypeAddedToUnion(type_name, union)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 1#
format_str = '{self.type_name} was added to union type {self.union.name}.'#
class py_gql.utilities.diff_schema.TypeChangedKind(type_name, old_kind, new_kind)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = '{self.type_name} changed from {self.old_kind_name} type to {self.new_kind_name} type.'#
class py_gql.utilities.diff_schema.TypeRemoved(type_name)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = 'Type {self.type_name} was removed.'#
class py_gql.utilities.diff_schema.TypeRemovedFromInterface(interface, object_type)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = '{self.type.name} no longer implements {self.interface.name}.'#
class py_gql.utilities.diff_schema.TypeRemovedFromUnion(type_name, union)[source]#

Bases: py_gql.utilities.diff_schema.changes.SchemaChange

severity = 2#
format_str = '{self.type_name} was removed from union type {self.union.name}.'#
py_gql.utilities.diff_schema.diff_schema(old_schema, new_schema, min_severity=None)[source]#

Iterate over all changes that can be statically found between old_schema and new_schema.

Some BREAKING and DANGEROUS changes could be safe depending on the actual queries made by clients of your schema. However it is not possible to detect this without looking at the queries being run against the schema so this classification errs on the side of safety.

Some compatible type changes are ignored given that they should not lead to any change in client behaviour.

Parameters
  • old_schema (Schema) – Source schema

  • new_schema (Schema) – Updated schema

  • min_severity (Optional[SchemaChangeSeverity]) – Set this to filter for changes of a given severity

Return type

Iterator[SchemaChange]