repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
graphene
graphene/utils/tests/test_crunch.py
.py
from pytest import mark from ..crunch import crunch @mark.parametrize( "description,uncrunched,crunched", [ ["number primitive", 0, [0]], ["boolean primitive", True, [True]], ["string primitive", "string", ["string"]], ["empty array", [], [[]]], ["single-item array", [...
52
1,758
graphene
graphene/utils/tests/test_resolve_only_args.py
.py
from .. import deprecated from ..resolve_only_args import resolve_only_args def test_resolve_only_args(mocker): mocker.patch.object(deprecated, "warn_deprecation") def resolver(root, **args): return root, args wrapped_resolver = resolve_only_args(resolver) result = wrapped_resolver(1, 2, a=3...
14
357
graphene
graphene/utils/tests/test_orderedtype.py
.py
from ..orderedtype import OrderedType def test_orderedtype(): one = OrderedType() two = OrderedType() three = OrderedType() assert one < two < three def test_orderedtype_eq(): one = OrderedType() two = OrderedType() assert one == one assert one != two def test_orderedtype_hash():...
42
747
graphene
graphene/utils/tests/test_module_loading.py
.py
from pytest import raises from graphene import ObjectType, String from ..module_loading import import_string, lazy_import def test_import_string(): MyString = import_string("graphene.String") assert MyString == String MyObjectTypeMeta = import_string("graphene.ObjectType", "__doc__") assert MyObjec...
70
1,870
graphene
graphene/utils/tests/test_str_converters.py
.py
# coding: utf-8 from ..str_converters import to_camel_case, to_snake_case def test_snake_case(): assert to_snake_case("snakesOnAPlane") == "snakes_on_a_plane" assert to_snake_case("SnakesOnAPlane") == "snakes_on_a_plane" assert to_snake_case("SnakesOnA_Plane") == "snakes_on_a__plane" assert to_snake_c...
20
847
graphene
graphene/utils/tests/test_deduplicator.py
.py
import datetime import graphene from graphene import relay from graphene.types.resolver import dict_resolver from ..deduplicator import deflate def test_does_not_modify_object_without_typename_and_id(): response = {"foo": "bar"} deflated_response = deflate(response) assert deflated_response == {"foo": "...
180
5,052
graphene
graphene/test/__init__.py
.py
from graphql.error import GraphQLError from graphene.types.schema import Schema def default_format_error(error): if isinstance(error, GraphQLError): return error.formatted return {"message": str(error)} def format_execution_result(execution_result, format_error): if execution_result: re...
40
1,286
graphene
graphene/types/definitions.py
.py
from enum import Enum as PyEnum from graphql import ( GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLScalarType, GraphQLUnionType, ) class GrapheneGraphQLType: """ A class for extending the base GraphQLType with the related graphene_type ...
63
1,595
graphene
graphene/types/mutation.py
.py
from typing import TYPE_CHECKING from ..utils.deprecated import warn_deprecation from ..utils.get_unbound_function import get_unbound_function from ..utils.props import props from .field import Field from .objecttype import ObjectType, ObjectTypeOptions from .utils import yank_fields_from_attrs from .interface import ...
135
5,127
graphene
graphene/types/json.py
.py
import json from graphql import Undefined from graphql.language.ast import StringValueNode from .scalars import Scalar class JSONString(Scalar): """ Allows use of a JSON String for input / output from the GraphQL schema. Use of this type is *not recommended* as you lose the benefits of having a defined...
33
851
graphene
graphene/types/mountedtype.py
.py
from ..utils.orderedtype import OrderedType from .unmountedtype import UnmountedType class MountedType(OrderedType): @classmethod def mounted(cls, unmounted): # noqa: N802 """ Mount the UnmountedType instance """ assert isinstance( unmounted, UnmountedType ...
21
555
graphene
graphene/types/enum.py
.py
from enum import Enum as PyEnum from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta from .base import BaseOptions, BaseType from .unmountedtype import UnmountedType def eq_enum(self, other): if isinstance(other, self.__class__): return self is other return self.value is other def h...
119
3,818
graphene
graphene/types/field.py
.py
import inspect from collections.abc import Mapping from functools import partial from .argument import Argument, to_arguments from .mountedtype import MountedType from .resolver import default_resolver from .structures import NonNull from .unmountedtype import UnmountedType from .utils import get_type from ..utils.dep...
140
5,472
graphene
graphene/types/argument.py
.py
from itertools import chain from graphql import Undefined from .dynamic import Dynamic from .mountedtype import MountedType from .structures import NonNull from .utils import get_type class Argument(MountedType): """ Makes an Argument available on a Field in the GraphQL schema. Arguments will be parsed ...
121
4,196
graphene
graphene/types/utils.py
.py
import inspect from functools import partial from ..utils.module_loading import import_string from .mountedtype import MountedType from .unmountedtype import UnmountedType def get_field_as(value, _as=None): """ Get type mounted """ if isinstance(value, MountedType): return value elif isin...
51
1,316
graphene
graphene/types/objecttype.py
.py
from typing import TYPE_CHECKING from .base import BaseOptions, BaseType, BaseTypeMeta from .field import Field from .interface import Interface from .utils import yank_fields_from_attrs from dataclasses import make_dataclass, field # For static type checking with type checker if TYPE_CHECKING: from typing impor...
160
5,802
graphene
graphene/types/uuid.py
.py
from uuid import UUID as _UUID from graphql.error import GraphQLError from graphql.language.ast import StringValueNode from graphql import Undefined from .scalars import Scalar class UUID(Scalar): """ Leverages the internal Python implementation of UUID (uuid.UUID) to provide native UUID objects in fiel...
38
1,021
graphene
graphene/types/inputobjecttype.py
.py
from typing import TYPE_CHECKING from .base import BaseOptions, BaseType from .inputfield import InputField from .unmountedtype import UnmountedType from .utils import yank_fields_from_attrs # For static type checking with type checker if TYPE_CHECKING: from typing import Dict, Callable # NOQA class InputObjec...
117
4,715
graphene
graphene/types/dynamic.py
.py
import inspect from functools import partial from .mountedtype import MountedType class Dynamic(MountedType): """ A Dynamic Type let us get the type in runtime when we generate the schema. So we can have lazy fields. """ def __init__(self, type_, with_schema=False, _creation_counter=None): ...
23
675
graphene
graphene/types/__init__.py
.py
from graphql import GraphQLResolveInfo as ResolveInfo from .argument import Argument from .base64 import Base64 from .context import Context from .datetime import Date, DateTime, Time from .decimal import Decimal from .dynamic import Dynamic from .enum import Enum from .field import Field from .inputfield import Input...
54
1,122
graphene
graphene/types/datetime.py
.py
import datetime from dateutil.parser import isoparse from graphql.error import GraphQLError from graphql.language import StringValueNode, print_ast from .scalars import Scalar class Date(Scalar): """ The `Date` scalar type represents a Date value as specified by [iso8601](https://en.wikipedia.org/w...
112
3,519
graphene
graphene/types/union.py
.py
from typing import TYPE_CHECKING from .base import BaseOptions, BaseType from .unmountedtype import UnmountedType # For static type checking with type checker if TYPE_CHECKING: from .objecttype import ObjectType # NOQA from typing import Iterable, Type # NOQA class UnionOptions(BaseOptions): types = (...
79
2,582
graphene
graphene/types/scalars.py
.py
from typing import Any from graphql import Undefined from graphql.language.ast import ( BooleanValueNode, FloatValueNode, IntValueNode, StringValueNode, ) from .base import BaseOptions, BaseType from .unmountedtype import UnmountedType class ScalarOptions(BaseOptions): pass class Scalar(Unmoun...
195
5,194
graphene
graphene/types/inputfield.py
.py
from graphql import Undefined from .mountedtype import MountedType from .structures import NonNull from .utils import get_type class InputField(MountedType): """ Makes a field available on an ObjectType in the GraphQL schema. Any type can be mounted as a Input Field except Interface and Union: - Obj...
75
2,752
graphene
graphene/types/schema.py
.py
from enum import Enum as PyEnum import inspect from functools import partial from graphql import ( default_type_resolver, get_introspection_query, graphql, graphql_sync, introspection_types, parse, print_schema, subscribe, validate, ExecutionResult, GraphQLArgument, Grap...
536
20,621
graphene
graphene/types/context.py
.py
class Context: """ Context can be used to make a convenient container for attributes to provide for execution for resolvers of a GraphQL operation like a query. .. code:: python from graphene import Context context = Context(loaders=build_dataloaders(), request=my_web_request) ...
26
791
graphene
graphene/types/generic.py
.py
from graphql.language.ast import ( BooleanValueNode, FloatValueNode, IntValueNode, ListValueNode, ObjectValueNode, StringValueNode, ) from graphene.types.scalars import MAX_INT, MIN_INT from .scalars import Scalar class GenericScalar(Scalar): """ The `GenericScalar` scalar type repre...
48
1,297
graphene
graphene/types/structures.py
.py
from .unmountedtype import UnmountedType from .utils import get_type class Structure(UnmountedType): """ A structure is a GraphQL type instance that wraps a main type with certain structure. """ def __init__(self, of_type, *args, **kwargs): super(Structure, self).__init__(*args, **kwargs)...
100
3,121
graphene
graphene/types/decimal.py
.py
from decimal import Decimal as _Decimal from graphql import Undefined from graphql.language.ast import StringValueNode, IntValueNode from .scalars import Scalar class Decimal(Scalar): """ The `Decimal` scalar type represents a python Decimal. """ @staticmethod def serialize(dec): if isi...
35
861
graphene
graphene/types/interface.py
.py
from typing import TYPE_CHECKING from .base import BaseOptions, BaseType from .field import Field from .utils import yank_fields_from_attrs # For static type checking with type checker if TYPE_CHECKING: from typing import Dict, Iterable, Type # NOQA class InterfaceOptions(BaseOptions): fields = None # typ...
77
2,428
graphene
graphene/types/resolver.py
.py
def attr_resolver(attname, default_value, root, info, **args): return getattr(root, attname, default_value) def dict_resolver(attname, default_value, root, info, **args): return root.get(attname, default_value) def dict_or_attr_resolver(attname, default_value, root, info, **args): resolver = dict_resolv...
25
696
graphene
graphene/types/base64.py
.py
from binascii import Error as _Error from base64 import b64decode, b64encode from graphql.error import GraphQLError from graphql.language import StringValueNode, print_ast from .scalars import Scalar class Base64(Scalar): """ The `Base64` scalar type represents a base64-encoded String. """ @staticm...
44
1,368
graphene
graphene/types/unmountedtype.py
.py
from ..utils.orderedtype import OrderedType class UnmountedType(OrderedType): """ This class acts a proxy for a Graphene Type, so it can be mounted dynamically as Field, InputField or Argument. Instead of writing: .. code:: python from graphene import ObjectType, Field, String ...
88
2,344
graphene
graphene/types/base.py
.py
from typing import Type, Optional from ..utils.subclass_with_meta import SubclassWithMeta, SubclassWithMeta_Meta from ..utils.trim_docstring import trim_docstring class BaseOptions: name: Optional[str] = None description: Optional[str] = None _frozen: bool = False def __init__(self, class_type: Typ...
49
1,386
graphene
graphene/types/tests/test_objecttype.py
.py
from pytest import raises from ..field import Field from ..interface import Interface from ..objecttype import ObjectType from ..scalars import String from ..schema import Schema from ..structures import NonNull from ..unmountedtype import UnmountedType class MyType(Interface): pass class Container(ObjectType)...
310
8,250
graphene
graphene/types/tests/test_generic.py
.py
from ..generic import GenericScalar from ..objecttype import ObjectType from ..schema import Schema class Query(ObjectType): generic = GenericScalar(input=GenericScalar()) def resolve_generic(self, info, input=None): return input schema = Schema(query=Query) def test_generic_query_variable(): ...
85
2,226
graphene
graphene/types/tests/test_dynamic.py
.py
from functools import partial from ..dynamic import Dynamic from ..scalars import String from ..structures import List, NonNull def test_dynamic(): dynamic = Dynamic(lambda: String) assert dynamic.get_type() == String assert str(dynamic.get_type()) == "String" def test_nonnull(): dynamic = Dynamic(...
39
989
graphene
graphene/types/tests/test_enum.py
.py
from textwrap import dedent from ..argument import Argument from ..enum import Enum, PyEnum from ..field import Field from ..inputfield import InputField from ..inputobjecttype import InputObjectType from ..mutation import Mutation from ..scalars import String from ..schema import ObjectType, Schema def test_enum_co...
616
13,726
graphene
graphene/types/tests/test_uuid.py
.py
from ..objecttype import ObjectType from ..schema import Schema from ..uuid import UUID from ..structures import NonNull class Query(ObjectType): uuid = UUID(input=UUID()) required_uuid = UUID(input=NonNull(UUID), required=True) def resolve_uuid(self, info, input): return input def resolve_r...
84
2,413
graphene
graphene/types/tests/test_inputfield.py
.py
from functools import partial from pytest import raises from ..inputfield import InputField from ..structures import NonNull from .utils import MyLazyType def test_inputfield_required(): MyType = object() field = InputField(MyType, required=True) assert isinstance(field.type, NonNull) assert field.t...
48
1,344
graphene
graphene/types/tests/test_scalars_serialization.py
.py
from graphql import Undefined from ..scalars import Boolean, Float, Int, String def test_serializes_output_int(): assert Int.serialize(1) == 1 assert Int.serialize(0) == 0 assert Int.serialize(-1) == -1 assert Int.serialize(0.1) == 0 assert Int.serialize(1.1) == 1 assert Int.serialize(-1.1) ==...
52
1,767
graphene
graphene/types/tests/test_datetime.py
.py
import datetime from graphql import GraphQLError from pytest import fixture from ..datetime import Date, DateTime, Time from ..objecttype import ObjectType from ..schema import Schema class Query(ObjectType): datetime = DateTime(_in=DateTime(name="in")) date = Date(_in=Date(name="in")) time = Time(_at=...
275
7,482
graphene
graphene/types/tests/test_argument.py
.py
from functools import partial from pytest import raises from ..argument import Argument, to_arguments from ..field import Field from ..inputfield import InputField from ..scalars import String from ..structures import NonNull def test_argument(): arg = Argument(String, default_value="a", description="desc", nam...
113
2,784
graphene
graphene/types/tests/test_scalar.py
.py
from ..objecttype import ObjectType, Field from ..scalars import Scalar, Int, BigInt, Float, String, Boolean from ..schema import Schema from graphql import Undefined from graphql.language.ast import IntValueNode def test_scalar(): class JSONScalar(Scalar): """Documentation""" assert JSONScalar._meta...
309
10,292
graphene
graphene/types/tests/test_mutation.py
.py
from pytest import raises from ..argument import Argument from ..dynamic import Dynamic from ..mutation import Mutation from ..objecttype import ObjectType from ..scalars import String from ..schema import Schema from ..structures import NonNull from ..interface import Interface class MyType(Interface): pass d...
221
5,708
graphene
graphene/types/tests/test_resolver.py
.py
from ..resolver import ( attr_resolver, dict_resolver, dict_or_attr_resolver, get_default_resolver, set_default_resolver, ) args = {} context = None info = None demo_dict = {"attr": "value"} class demo_obj: attr = "value" def test_attr_resolver(): resolved = attr_resolver("attr", None,...
59
1,384
graphene
graphene/types/tests/test_base64.py
.py
import base64 from graphql import GraphQLError from ..objecttype import ObjectType from ..scalars import String from ..schema import Schema from ..base64 import Base64 class Query(ObjectType): base64 = Base64(_in=Base64(name="input"), _match=String(name="match")) bytes_as_base64 = Base64() string_as_bas...
98
2,798
graphene
graphene/types/tests/test_decimal.py
.py
import decimal from ..decimal import Decimal from ..objecttype import ObjectType from ..schema import Schema class Query(ObjectType): decimal = Decimal(input=Decimal()) def resolve_decimal(self, info, input): return input schema = Schema(query=Query) def test_decimal_string_query(): decimal_...
69
2,165
graphene
graphene/types/tests/test_definition.py
.py
import copy from ..argument import Argument from ..definitions import GrapheneGraphQLType from ..enum import Enum from ..field import Field from ..inputfield import InputField from ..inputobjecttype import InputObjectType from ..interface import Interface from ..objecttype import ObjectType from ..scalars import Boole...
331
9,009
graphene
graphene/types/tests/test_union.py
.py
from pytest import raises from ..field import Field from ..objecttype import ObjectType from ..union import Union from ..unmountedtype import UnmountedType class MyObjectType1(ObjectType): pass class MyObjectType2(ObjectType): pass def test_generate_union(): class MyUnion(Union): """Documenta...
59
1,453
graphene
graphene/types/tests/test_field.py
.py
from functools import partial from pytest import raises from ..argument import Argument from ..field import Field from ..scalars import String from ..structures import NonNull from .utils import MyLazyType class MyInstance: value = "value" value_func = staticmethod(lambda: "value_func") def value_metho...
148
4,104
graphene
graphene/types/tests/test_base.py
.py
from ..base import BaseOptions, BaseType class CustomOptions(BaseOptions): pass class CustomType(BaseType): @classmethod def __init_subclass_with_meta__(cls, **options): _meta = CustomOptions(cls) super(CustomType, cls).__init_subclass_with_meta__(_meta=_meta, **options) def test_baset...
64
1,688
graphene
graphene/types/tests/test_json.py
.py
from ..json import JSONString from ..objecttype import ObjectType from ..schema import Schema class Query(ObjectType): json = JSONString(input=JSONString()) def resolve_json(self, info, input): return input schema = Schema(query=Query) def test_jsonstring_query(): json_value = '{"key": "value...
81
2,347
graphene
graphene/types/tests/test_structures.py
.py
from functools import partial from pytest import raises from ..scalars import String from ..structures import List, NonNull from .utils import MyLazyType def test_list(): _list = List(String) assert _list.of_type == String assert str(_list) == "[String]" def test_list_with_unmounted_type(): with r...
130
3,184
graphene
graphene/types/tests/test_interface.py
.py
from ..field import Field from ..interface import Interface from ..objecttype import ObjectType from ..scalars import String from ..schema import Schema from ..unmountedtype import UnmountedType class MyType: pass class MyScalar(UnmountedType): def get_type(self): return MyType def test_generate_i...
205
5,077
graphene
graphene/types/tests/test_type_map.py
.py
from graphql import Undefined from graphql.type import ( GraphQLArgument, GraphQLEnumType, GraphQLEnumValue, GraphQLField, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLNonNull, GraphQLObjectType, GraphQLString, ) from ..dynamic import Dynamic from ..en...
334
10,417
graphene
graphene/types/tests/test_mountedtype.py
.py
from ..field import Field from ..scalars import String class CustomField(Field): def __init__(self, *args, **kwargs): self.metadata = kwargs.pop("metadata", None) super(CustomField, self).__init__(*args, **kwargs) def test_mounted_type(): unmounted = String() mounted = Field.mounted(unmo...
24
650
graphene
graphene/types/tests/test_subscribe_async.py
.py
from pytest import mark from graphene import ObjectType, Int, String, Schema, Field class Query(ObjectType): hello = String() def resolve_hello(root, info): return "Hello, world!" class Subscription(ObjectType): count_to_ten = Field(Int) async def subscribe_count_to_ten(root, info): ...
79
2,136
graphene
graphene/types/tests/test_schema.py
.py
from textwrap import dedent from pytest import raises from graphql.type import GraphQLObjectType, GraphQLSchema from ..field import Field from ..objecttype import ObjectType from ..scalars import String from ..schema import Schema class MyOtherType(ObjectType): field = String() class Query(ObjectType): i...
75
1,621
graphene
graphene/types/tests/test_inputobjecttype.py
.py
from graphql import Undefined from ..argument import Argument from ..field import Field from ..inputfield import InputField from ..inputobjecttype import InputObjectType from ..objecttype import ObjectType from ..scalars import Boolean, String from ..schema import Schema from ..unmountedtype import UnmountedType from ...
170
4,892
graphene
graphene/types/tests/test_query.py
.py
import json from functools import partial from graphql import ( GraphQLError, GraphQLResolveInfo as ResolveInfo, Source, execute, parse, ) from ..context import Context from ..dynamic import Dynamic from ..field import Field from ..inputfield import InputField from ..inputobjecttype import InputOb...
500
13,427
graphene
graphene/types/tests/conftest.py
.py
import pytest from graphql import Undefined from graphene.types.inputobjecttype import set_input_object_type_default_value @pytest.fixture() def set_default_input_object_type_to_undefined(): """This fixture is used to change the default value of optional inputs in InputObjectTypes for specific tests""" set_i...
13
418
graphene
examples/simple_example.py
.py
import graphene class Patron(graphene.ObjectType): id = graphene.ID() name = graphene.String() age = graphene.Int() class Query(graphene.ObjectType): patron = graphene.Field(Patron) def resolve_patron(root, info): return Patron(id=1, name="Syrus", age=27) schema = graphene.Schema(quer...
38
690
graphene
examples/complex_example.py
.py
import graphene class GeoInput(graphene.InputObjectType): lat = graphene.Float(required=True) lng = graphene.Float(required=True) @property def latlng(self): return f"({self.lat},{self.lng})" class Address(graphene.ObjectType): latlng = graphene.String() class Query(graphene.ObjectTyp...
70
1,461
graphene
examples/context_example.py
.py
import graphene class User(graphene.ObjectType): id = graphene.ID() name = graphene.String() class Query(graphene.ObjectType): me = graphene.Field(User) def resolve_me(root, info): return info.context["user"] schema = graphene.Schema(query=Query) query = """ query something{ me ...
36
698
graphene
examples/starwars/data.py
.py
human_data = {} droid_data = {} def setup(): from .schema import Human, Droid global human_data, droid_data luke = Human( id="1000", name="Luke Skywalker", friends=["1002", "1003", "2000", "2001"], appears_in=[4, 5, 6], home_planet="Tatooine", ) vader = Hu...
96
1,881
graphene
examples/starwars/schema.py
.py
import graphene from .data import get_character, get_droid, get_hero, get_human class Episode(graphene.Enum): NEWHOPE = 4 EMPIRE = 5 JEDI = 6 class Character(graphene.Interface): id = graphene.ID() name = graphene.String() friends = graphene.List(lambda: Character) appears_in = graphene...
53
1,197
graphene
examples/starwars/tests/test_query.py
.py
from graphene.test import Client from ..data import setup from ..schema import schema setup() client = Client(schema) def test_hero_name_query(): result = client.execute(""" query HeroNameQuery { hero { name } } """) assert result == {"data": {"hero": {"n...
252
6,013
graphene
examples/starwars_relay/data.py
.py
data = {} def setup(): global data from .schema import Ship, Faction xwing = Ship(id="1", name="X-Wing") ywing = Ship(id="2", name="Y-Wing") awing = Ship(id="3", name="A-Wing") # Yeah, technically it's Corellian. But it flew in the service of the rebels, # so for the purposes of this ...
72
1,593
graphene
examples/starwars_relay/schema.py
.py
import graphene from graphene import relay from .data import create_ship, get_empire, get_faction, get_rebels, get_ship class Ship(graphene.ObjectType): """A ship in the Star Wars saga""" class Meta: interfaces = (relay.Node,) name = graphene.String(description="The name of the ship.") @cl...
79
1,955
graphene
examples/starwars_relay/tests/test_mutation.py
.py
from graphene.test import Client from ..data import setup from ..schema import schema setup() client = Client(schema) def test_mutations(): result = client.execute(""" mutation MyMutation { introduceShip(input:{clientMutationId:"abc", shipName: "Peter", factionId: "1"}) { ship { ...
53
1,486
graphene
examples/starwars_relay/tests/test_connections.py
.py
from graphene.test import Client from ..data import setup from ..schema import schema setup() client = Client(schema) def test_correct_fetch_first_ship_rebels(): result = client.execute(""" query RebelsShipsQuery { rebels { name, ships(first: 1) { pageInf...
54
1,337
graphene
examples/starwars_relay/tests/test_objectidentification.py
.py
import textwrap from graphene.test import Client from ..data import setup from ..schema import schema setup() client = Client(schema) def test_str_schema(): assert str(schema).strip() == textwrap.dedent( '''\ type Query { rebels: Faction empire: Faction node( ...
180
4,108
strawberry
setup.py
.py
#!/usr/bin/env python # we use uv for our build, but this file seems to be required # in order to get GitHub dependencies graph to work import setuptools if __name__ == "__main__": setuptools.setup(name="strawberry-graphql")
10
232
strawberry
noxfile.py
.py
import itertools from collections.abc import Callable from typing import Any import nox nox.options.reuse_existing_virtualenvs = True nox.options.error_on_external_run = True nox.options.default_venv_backend = "uv" PYTHON_VERSIONS = ["3.14", "3.13", "3.12", "3.11", "3.10"] GQL_CORE_VERSIONS = [ "3.2.6", "3....
236
6,137
strawberry
strawberry/schema_directives.py
.py
from strawberry.schema_directive import Location, schema_directive @schema_directive(locations=[Location.INPUT_OBJECT], name="oneOf") class OneOf: ... __all__ = ["OneOf"]
9
175
strawberry
strawberry/parent.py
.py
import re from typing import Annotated, Any, ForwardRef, TypeVar _parent_re = re.compile(r"^(?:strawberry\.)?Parent\[(.*)\]$") class StrawberryParent: ... T = TypeVar("T") Parent = Annotated[T, StrawberryParent()] """Represents a parameter holding the parent resolver's value. This can be used when defining a res...
63
1,362
strawberry
strawberry/resolvers.py
.py
from collections.abc import Callable from typing import Any def is_default_resolver(func: Callable[..., Any]) -> bool: """Check whether the function is a default resolver or a user provided one.""" return getattr(func, "_is_default", False) __all__ = ["is_default_resolver"]
11
287
strawberry
strawberry/permission.py
.py
from __future__ import annotations import abc import inspect from functools import cached_property from inspect import iscoroutinefunction from typing import ( TYPE_CHECKING, Any, ) from strawberry.exceptions import StrawberryGraphQLError from strawberry.exceptions.permission_fail_silently_requires_optional i...
234
7,497
strawberry
strawberry/__main__.py
.py
from .cli import run if __name__ == "__main__": run()
5
59
strawberry
strawberry/__init__.py
.py
"""Strawberry is a Python library for GraphQL. Strawberry is a Python library for GraphQL that aims to stay close to the GraphQL specification and allow for a more natural way of defining GraphQL schemas. """ from . import experimental, federation, relay from .directive import directive, directive_field from .parent ...
65
1,586
strawberry
strawberry/scalars.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any, NewType, get_origin if TYPE_CHECKING: from collections.abc import Mapping from strawberry.types.scalar import ScalarDefinition, ScalarWrapper ID = NewType("ID", str) """Represent the GraphQL `ID` scalar type.""" JSON = NewType("JSON...
50
1,216
strawberry
strawberry/directive.py
.py
from __future__ import annotations import dataclasses from functools import cached_property from typing import ( TYPE_CHECKING, Annotated, Any, Generic, TypeVar, ) from graphql import DirectiveLocation from strawberry.types.field import StrawberryField from strawberry.types.fields.resolver import...
144
3,582
strawberry
strawberry/schema_directive.py
.py
import dataclasses from collections.abc import Callable from enum import Enum from typing import TypeVar from typing_extensions import dataclass_transform from strawberry.types.field import StrawberryField, field from strawberry.types.object_type import _wrap_dataclass from strawberry.types.type_resolver import _get_f...
77
2,009
strawberry
strawberry/annotation.py
.py
from __future__ import annotations import sys import typing import warnings from collections import abc from enum import Enum from types import UnionType from typing import ( TYPE_CHECKING, Annotated, Any, ForwardRef, TypeVar, Union, cast, get_args, get_origin, ) from typing_extensi...
472
16,595
strawberry
strawberry/dataloader.py
.py
from __future__ import annotations import asyncio import dataclasses from abc import ABC, abstractmethod from asyncio import create_task, gather, get_event_loop from asyncio.futures import Future from dataclasses import dataclass from typing import ( TYPE_CHECKING, Any, Generic, TypeVar, overload, ...
306
8,940
strawberry
strawberry/streamable.py
.py
from collections.abc import AsyncGenerator from typing import Annotated, TypeVar class StrawberryStreamable: ... T = TypeVar("T") Streamable = Annotated[AsyncGenerator[T, None], StrawberryStreamable()] """Represents a list that can be streamed using @stream. Example: ```python import strawberry @strawberry.typ...
36
611
strawberry
strawberry/chalice/views.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from chalice.app import Request, Response from cross_web import ChaliceHTTPRequestAdapter, HTTPException from strawberry.http.sync_base_view import SyncBaseHTTPView from strawberry.http.temporal_response import TemporalResponse from strawberry.http....
85
2,732
strawberry
strawberry/sanic/utils.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Any, cast if TYPE_CHECKING: from sanic.request import File, Request def convert_request_to_files_dict(request: Request) -> dict[str, Any]: """Converts the request.files dictionary to a dictionary of sanic Request objects. `request.fil...
40
981
strawberry
strawberry/sanic/views.py
.py
from __future__ import annotations from typing import ( TYPE_CHECKING, TypeGuard, ) from cross_web import HTTPException, SanicHTTPRequestAdapter from sanic.request import Request from sanic.response import HTTPResponse, html from sanic.views import HTTPMethodView from strawberry.http.async_base_view import A...
168
4,925
strawberry
strawberry/sanic/context.py
.py
from typing_extensions import TypedDict from sanic.request import Request from strawberry.http.temporal_response import TemporalResponse class StrawberrySanicContext(TypedDict): request: Request response: TemporalResponse __all__ = ["StrawberrySanicContext"]
14
273
strawberry
strawberry/litestar/__init__.py
.py
from .controller import ( BaseContext, HTTPContextType, WebSocketContextType, make_graphql_controller, ) __all__ = [ "BaseContext", "HTTPContextType", "WebSocketContextType", "make_graphql_controller", ]
14
237
strawberry
strawberry/litestar/controller.py
.py
"""Litestar integration for strawberry-graphql.""" from __future__ import annotations import json from datetime import timedelta from typing import ( TYPE_CHECKING, Any, ClassVar, TypeAlias, TypedDict, TypeGuard, ) from cross_web import HTTPException, LitestarRequestAdapter from litestar impo...
437
13,000
strawberry
strawberry/exceptions/unresolved_field_type.py
.py
from __future__ import annotations from functools import cached_property from typing import TYPE_CHECKING from strawberry.exceptions.utils.source_finder import SourceFinder from .exception import StrawberryException if TYPE_CHECKING: from strawberry.types.field import StrawberryField from strawberry.types.o...
61
1,864
strawberry
strawberry/exceptions/multiple_strawberry_fields.py
.py
from __future__ import annotations from functools import cached_property from typing import TYPE_CHECKING from .exception import StrawberryException from .utils.source_finder import SourceFinder if TYPE_CHECKING: from .exception_source import ExceptionSource class MultipleStrawberryFieldsError(StrawberryExcept...
43
1,399
strawberry
strawberry/exceptions/exception_source.py
.py
from dataclasses import dataclass from pathlib import Path @dataclass class ExceptionSource: path: Path code: str start_line: int end_line: int error_line: int error_column: int error_column_end: int @property def path_relative_to_cwd(self) -> Path: if self.path.is_absolut...
21
404
strawberry
strawberry/exceptions/conflicting_arguments.py
.py
from __future__ import annotations from functools import cached_property from typing import TYPE_CHECKING from .exception import StrawberryException from .utils.source_finder import SourceFinder if TYPE_CHECKING: from strawberry.types.fields.resolver import StrawberryResolver from .exception_source import E...
56
1,568
strawberry
strawberry/exceptions/syntax.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from pygments.lexers import PythonLexer from rich.segment import Segment from rich.syntax import Syntax as RichSyntax if TYPE_CHECKING: from rich.console import Console, ConsoleOptions, RenderResult class Syntax(RichSyntax): def __init__( ...
63
1,724
strawberry
strawberry/exceptions/scalar_already_registered.py
.py
from __future__ import annotations from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING from strawberry.exceptions.utils.source_finder import SourceFinder from .exception import StrawberryException if TYPE_CHECKING: from strawberry.types.scalar import ScalarDefinition ...
57
1,835
strawberry
strawberry/exceptions/__init__.py
.py
from __future__ import annotations from functools import cached_property from typing import TYPE_CHECKING from graphql import GraphQLError from .conflicting_arguments import ConflictingArgumentsError from .duplicated_type_name import DuplicatedTypeName from .exception import StrawberryException, UnableToFindExceptio...
203
6,703