def test_directive_value():
    """Tests if directive value is detected by type instead of by arg-name `value`."""

    @strawberry.type
    class Cake:
        frosting: Optional[str] = None
        flavor: str = "Chocolate"

    @strawberry.type
    class Query:
        @strawberry.field
        def cake(self) -> Cake:
            return Cake()

    @strawberry.directive(
        locations=[DirectiveLocation.FIELD],
        description="Add frostring with ``flavor`` to a cake.",
    )
    def add_frosting(flavor: str, v: DirectiveValue[Cake], value: str):
        assert isinstance(v, Cake)
        assert value == "foo"  # Check if value can be used as an argument
        v.frosting = flavor
        return v

    schema = strawberry.Schema(query=Query, directives=[add_frosting])
    result = schema.execute_sync(
        """query {
            cake @addFrosting(flavor: "Vanilla", value: "foo") {
                frosting
                flavor
            }
        }
        """
    )
    assert result.data == {"cake": {"frosting": "Vanilla", "flavor": "Chocolate"}}
Tests if directive value is detected by type instead of by arg-name `value`.
tests/schema/test_directives.py