py_gql.schema.differ#

Utilities to compare 2 GraphQL schema for incompatibilities.

py_gql.schema.differ.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]

class py_gql.schema.differ.SchemaChange[source]#

Bases: object

format_str = NotImplemented#
property message#
Return type

str

severity = NotImplemented#
class py_gql.schema.differ.SchemaChangeSeverity[source]#

Bases: enum.IntEnum

Severity level of a schema change.

BREAKING = 2#

Change will break most clients.

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.

class py_gql.schema.differ.DirectiveAdded(directive)[source]#

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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}.'#
severity = 2#
class py_gql.schema.differ.DirectiveArgumentDefaultValueChange(directive, old_argument, new_argument)[source]#

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.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.schema.differ.FieldArgumentChangedType(parent_type, field, old_argument, new_argument)[source]#

Bases: py_gql.schema.differ.changes.SchemaChange

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}.'#
severity = 2#
class py_gql.schema.differ.FieldArgumentDefaultValueChange(parent_type, field, old_argument, new_argument)[source]#

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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}.'#
severity = 2#
class py_gql.schema.differ.FieldDeprecated(parent_type, old_field, new_field)[source]#

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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}.'#
severity = 2#
class py_gql.schema.differ.InputFieldDefaultValueChange(input_type, old_field, new_field)[source]#

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

format_str = 'Input field {self.field.name} was removed from {self.type.name}.'#
severity = 2#
class py_gql.schema.differ.TypeAdded(type_name)[source]#

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

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

Bases: py_gql.schema.differ.changes.SchemaChange

format_str = '{self.type_name} was removed from union type {self.union.name}.'#
severity = 2#