schemadiff.schema_loader API documentation

# Module `schemadiff.schema_loader`

Expand source code

    from graphql import build_schema, GraphQLSchema

    class SchemaLoader:
        """Represents a GraphQL Schema loaded from a string or file."""

        @classmethod
        def from_sdl(cls, schema_string: str) -> GraphQLSchema:
            return build_schema(schema_string)

        @classmethod
        def from_file(cls, filepath: str) -> GraphQLSchema:
            with open(filepath, encoding='utf-8') as f:
                schema_string = f.read()

            return cls.from_sdl(schema_string)

## Classes

`class SchemaLoader`

  Represents a GraphQL Schema loaded from a string or file.

  Expand source code

      class SchemaLoader:
          """Represents a GraphQL Schema loaded from a string or file."""

          @classmethod
          def from_sdl(cls, schema_string: str) -> GraphQLSchema:
              return build_schema(schema_string)

          @classmethod
          def from_file(cls, filepath: str) -> GraphQLSchema:
              with open(filepath, encoding='utf-8') as f:
                  schema_string = f.read()

              return cls.from_sdl(schema_string)

  ### Static methods

  `def from_file(filepath: str) ‑> graphql.type.schema.GraphQLSchema`
    Expand source code

        @classmethod
        def from_file(cls, filepath: str) -> GraphQLSchema:
            with open(filepath, encoding='utf-8') as f:
                schema_string = f.read()

            return cls.from_sdl(schema_string)

  `def from_sdl(schema_string: str) ‑> graphql.type.schema.GraphQLSchema`
    Expand source code

        @classmethod
        def from_sdl(cls, schema_string: str) -> GraphQLSchema:
            return build_schema(schema_string)