schemadiff.changes.object API documentation

# Module `schemadiff.changes.object`

Expand source code

    from graphql import GraphQLField, GraphQLObjectType

    from schemadiff.changes import Change, Criticality

    class ObjectTypeFieldAdded(Change):

        criticality = Criticality.safe()

        def __init__(self, parent: GraphQLObjectType, field_name, field: GraphQLField):
            self.parent = parent
            self.field_name = field_name
            self.field = field
            self.description = parent.fields[field_name].description

        @property
        def message(self):
            return f"Field `{self.field_name}` was added to object type `{self.parent.name}`"

        @property
        def path(self):
            return f"{self.parent.name}.{self.field_name}"

    class ObjectTypeFieldRemoved(Change):

        def __init__(self, parent, field_name, field):
            self.parent = parent
            self.field_name = field_name
            self.field = field
            self.criticality = (
                Criticality.dangerous(
                    "Removing deprecated fields without sufficient time for clients "
                    "to update their queries may break their code"
                ) if field.deprecation_reason else Criticality.breaking(
                    "Removing a field is a breaking change. It is preferred to deprecate the field before removing it."
                )
            )

        @property
        def message(self):
            return f"Field `{self.field_name}` was removed from object type `{self.parent.name}`"

        @property
        def path(self):
            return f"{self.parent.name}.{self.field_name}"

## Classes

`class ObjectTypeFieldAdded (parent: graphql.type.definition.GraphQLObjectType, field_name, field: graphql.type.definition.GraphQLField)`

  Common interface of all schema changes

  This class offers the common operations and properties of all schema changes. You may use it as a type hint to get better suggestions in your editor of choice.

  Expand source code

      class ObjectTypeFieldAdded(Change):

          criticality = Criticality.safe()

          def __init__(self, parent: GraphQLObjectType, field_name, field: GraphQLField):
              self.parent = parent
              self.field_name = field_name
              self.field = field
              self.description = parent.fields[field_name].description

          @property
          def message(self):
              return f"Field `{self.field_name}` was added to object type `{self.parent.name}`"

          @property
          def path(self):
              return f"{self.parent.name}.{self.field_name}"

  ### Ancestors

  - Change
  - abc.ABC

  ### Class variables

  `var criticality : Criticality`

  ### Inherited members

  - `Change`:
    - `breaking`
    - `checksum`
    - `dangerous`
    - `message`
    - `path`
    - `restricted`
    - `safe`
    - `to_dict`
    - `to_json`
`class ObjectTypeFieldRemoved (parent, field_name, field)`

  Common interface of all schema changes

  This class offers the common operations and properties of all schema changes. You may use it as a type hint to get better suggestions in your editor of choice.

  Expand source code

      class ObjectTypeFieldRemoved(Change):

          def __init__(self, parent, field_name, field):
              self.parent = parent
              self.field_name = field_name
              self.field = field
              self.criticality = (
                  Criticality.dangerous(
                      "Removing deprecated fields without sufficient time for clients "
                      "to update their queries may break their code"
                  ) if field.deprecation_reason else Criticality.breaking(
                      "Removing a field is a breaking change. It is preferred to deprecate the field before removing it."
                  )
              )

          @property
          def message(self):
              return f"Field `{self.field_name}` was removed from object type `{self.parent.name}`"

          @property
          def path(self):
              return f"{self.parent.name}.{self.field_name}"

  ### Ancestors

  - Change
  - abc.ABC

  ### Inherited members

  - `Change`:
    - `breaking`
    - `checksum`
    - `dangerous`
    - `message`
    - `path`
    - `restricted`
    - `safe`
    - `to_dict`
    - `to_json`