def from_arguments(
        cls,
        info: Info,
        *,
        before: str | None = None,
        after: str | None = None,
        first: int | None = None,
        last: int | None = None,
        max_results: int | None = None,
        prefix: str | None = None,
    ) -> Self:
        """Get the slice metadata to use on ListConnection."""
        from strawberry.relay.types import PREFIX

        if prefix is None:
            prefix = PREFIX

        max_results = (
            max_results
            if max_results is not None
            else info.schema.config.relay_max_results
        )
        start = 0
        end: int | None = None

        if after:
            after_type, after_parsed = from_base64(after)
            if after_type != prefix:
                raise TypeError("Argument 'after' contains a non-existing value.")

            start = int(after_parsed) + 1
        if before:
            before_type, before_parsed = from_base64(before)
            if before_type != prefix:
                raise TypeError("Argument 'before' contains a non-existing value.")
            end = int(before_parsed)

        if isinstance(first, int):
            if first < 0:
                raise ValueError("Argument 'first' must be a non-negative integer.")

            if first > max_results:
                raise ValueError(
                    f"Argument 'first' cannot be higher than {max_results}."
                )

            if end is not None:
                start = max(0, end - 1)

            end = start + first
        if isinstance(last, int):
            if last < 0:
                raise ValueError("Argument 'last' must be a non-negative integer.")

            if last > max_results:
                raise ValueError(
                    f"Argument 'last' cannot be higher than {max_results}."
                )

            if end is not None:
                start = max(start, end - last)
            else:
                end = sys.maxsize

        if end is None:
            end = start + max_results

        expected = end - start if end != sys.maxsize else None

        return cls(
            start=start,
            end=end,
            expected=expected,
        )
Get the slice metadata to use on ListConnection.
strawberry/relay/utils.py