File: arguments.py

package info (click to toggle)
strawberry-graphql-django 0.67.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,988 kB
  • sloc: python: 27,682; sh: 20; makefile: 20
file content (28 lines) | stat: -rw-r--r-- 672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from typing import Optional

from strawberry import UNSET
from strawberry.annotation import StrawberryAnnotation
from strawberry.types.arguments import StrawberryArgument


def argument(
    name: str,
    type_: type,
    *,
    is_list: bool = False,
    is_optional: bool = False,
    default: object = UNSET,
):
    argument_type = type_
    if is_list:
        argument_type = list[type_]
    if is_optional:
        argument_type = Optional[type_]  # noqa: UP045

    return StrawberryArgument(
        default=default,
        description=None,
        graphql_name=None,
        python_name=name,
        type_annotation=StrawberryAnnotation(argument_type),
    )