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 |
|---|---|---|---|---|---|
strawberry | strawberry/exceptions/private_strawberry_field.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 PrivateStrawberryFieldError(StrawberryExceptio... | 42 | 1,315 |
strawberry | strawberry/exceptions/invalid_superclass_interface.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 collections.abc import Iterable
from strawberry.types.base import StrawberryObjectDefiniti... | 42 | 1,280 |
strawberry | strawberry/exceptions/exception.py | .py | from __future__ import annotations
from abc import ABC, abstractmethod
from functools import cached_property
from typing import TYPE_CHECKING
from strawberry.utils.str_converters import to_kebab_case
if TYPE_CHECKING:
from rich.console import RenderableType
from .exception_source import ExceptionSource
cl... | 123 | 3,429 |
strawberry | strawberry/exceptions/invalid_union_type.py | .py | from __future__ import annotations
from functools import cached_property
from inspect import getframeinfo, stack
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 strawber... | 107 | 3,591 |
strawberry | strawberry/exceptions/missing_return_annotation.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... | 47 | 1,389 |
strawberry | strawberry/exceptions/permission_fail_silently_requires_optional.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.field import StrawberryField
from .exception_source import ExceptionSource
cl... | 53 | 1,729 |
strawberry | strawberry/exceptions/duplicated_type_name.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 rich.console import RenderableType
from .exception_source import ExceptionSource
class D... | 76 | 2,185 |
strawberry | strawberry/exceptions/object_is_not_an_enum.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 enum import Enum
from .exception_source import ExceptionSource
class ObjectIsNotAnEnumEr... | 41 | 1,250 |
strawberry | strawberry/exceptions/object_is_not_a_class.py | .py | from __future__ import annotations
from enum import Enum
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 ObjectIsNotClassError(St... | 66 | 1,995 |
strawberry | strawberry/exceptions/missing_field_annotation.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 MissingFieldAnnotationError(StrawberryExceptio... | 42 | 1,319 |
strawberry | strawberry/exceptions/missing_dependencies.py | .py | from __future__ import annotations
class MissingOptionalDependenciesError(Exception):
"""Some optional dependencies that are required for a particular task are missing."""
def __init__(
self,
*,
packages: list[str] | None = None,
extras: list[str] | None = None,
) -> None:... | 27 | 797 |
strawberry | strawberry/exceptions/missing_arguments_annotations.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... | 65 | 1,994 |
strawberry | strawberry/exceptions/handler.py | .py | import os
import sys
import threading
from collections.abc import Callable
from types import TracebackType
from typing import Any, cast
from .exception import StrawberryException, UnableToFindExceptionSource
original_threading_exception_hook = threading.excepthook
# Signature of ``sys.excepthook`` / ``threading.exc... | 95 | 2,900 |
strawberry | strawberry/exceptions/invalid_argument_type.py | .py | from __future__ import annotations
from functools import cached_property
from typing import TYPE_CHECKING
from strawberry.types.base import get_object_definition
from .exception import StrawberryException
from .utils.source_finder import SourceFinder
if TYPE_CHECKING:
from strawberry.types.arguments import Stra... | 68 | 2,200 |
strawberry | strawberry/exceptions/utils/source_finder.py | .py | from __future__ import annotations
import importlib
import importlib.util
import sys
from dataclasses import dataclass
from functools import cached_property
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
from strawberry.exceptions.exception_source import ExceptionSource
if TYPE_CHECKING:
fr... | 672 | 22,487 |
strawberry | strawberry/printer/printer.py | .py | from __future__ import annotations
import dataclasses
from itertools import chain
from typing import (
TYPE_CHECKING,
Any,
TypeVar,
cast,
overload,
)
from graphql import GraphQLInputField, GraphQLObjectType, GraphQLSchema, is_union_type
from graphql.language.printer import print_ast
from graphql.t... | 666 | 19,712 |
strawberry | strawberry/printer/__init__.py | .py | from .printer import print_schema
__all__ = ["print_schema"]
| 4 | 62 |
strawberry | strawberry/printer/ast_from_value.py | .py | from __future__ import annotations
import dataclasses
import re
from collections.abc import Mapping
from math import isfinite
from typing import TYPE_CHECKING, Any, cast
from graphql.language import (
BooleanValueNode,
EnumValueNode,
FloatValueNode,
IntValueNode,
ListValueNode,
NameNode,
N... | 276 | 8,252 |
strawberry | strawberry/file_uploads/utils.py | .py | import copy
from collections.abc import Mapping
from typing import Any
def replace_placeholders_with_files(
operations_with_placeholders: dict[str, Any],
files_map: Mapping[str, Any],
files: Mapping[str, Any],
) -> dict[str, Any]:
# TODO: test this with missing variables in operations_with_placeholder... | 37 | 1,181 |
strawberry | strawberry/file_uploads/__init__.py | .py | from .scalars import Upload, UploadDefinition
__all__ = ["Upload", "UploadDefinition"]
| 4 | 88 |
strawberry | strawberry/file_uploads/scalars.py | .py | from typing import NewType
from strawberry.types.scalar import scalar
Upload = NewType("Upload", bytes)
UploadDefinition = scalar(
name="Upload",
description="Represents a file upload.",
serialize=lambda v: v,
parse_value=lambda v: v,
)
__all__ = ["Upload", "UploadDefinition"]
| 15 | 298 |
strawberry | strawberry/aiohttp/views.py | .py | from __future__ import annotations
import asyncio
from datetime import timedelta
from json.decoder import JSONDecodeError
from typing import (
TYPE_CHECKING,
TypeGuard,
)
from aiohttp import ClientConnectionResetError, http, web
from cross_web import AiohttpHTTPRequestAdapter, HTTPException
from strawberry.h... | 195 | 6,617 |
strawberry | strawberry/aiohttp/test/__init__.py | .py | from .client import GraphQLTestClient
__all__ = ["GraphQLTestClient"]
| 4 | 71 |
strawberry | strawberry/aiohttp/test/client.py | .py | from __future__ import annotations
from typing import Any
from strawberry.test.client import BaseGraphQLTestClient, Response
class GraphQLTestClient(BaseGraphQLTestClient):
async def query(
self,
query: str,
variables: dict[str, Any] | None = None,
headers: dict[str, object] | No... | 48 | 1,265 |
strawberry | strawberry/extensions/utils.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from graphql import GraphQLResolveInfo
def is_introspection_key(key: str | int) -> bool:
# from: https://spec.graphql.org/June2018/#sec-Schema
# > All types and directives defined within a schema must not have a name w... | 41 | 982 |
strawberry | strawberry/extensions/base_extension.py | .py | from __future__ import annotations
from collections.abc import Callable
from enum import Enum
from typing import TYPE_CHECKING, Any
from strawberry.types import StreamExecutionResult
from strawberry.utils.await_maybe import AsyncIteratorOrIterator, AwaitableOrValue
if TYPE_CHECKING:
from graphql import GraphQLRe... | 98 | 2,988 |
strawberry | strawberry/extensions/max_tokens.py | .py | from collections.abc import Iterator
from strawberry.extensions.base_extension import SchemaExtension
class MaxTokensLimiter(SchemaExtension):
"""Add a validator to limit the number of tokens in a GraphQL document.
Example:
```python
import strawberry
from strawberry.extensions import MaxTokensL... | 43 | 1,045 |
strawberry | strawberry/extensions/runner.py | .py | from __future__ import annotations
import inspect
from typing import TYPE_CHECKING, Any
from strawberry.extensions.context import (
ExecutingContextManager,
OperationContextManager,
ParsingContextManager,
StreamResultContextManager,
ValidationContextManager,
)
from strawberry.utils.await_maybe imp... | 67 | 2,090 |
strawberry | strawberry/extensions/__init__.py | .py | from .add_validation_rules import AddValidationRules
from .base_extension import LifecycleStep, SchemaExtension
from .disable_introspection import DisableIntrospection
from .disable_validation import DisableValidation
from .field_extension import FieldExtension
from .mask_errors import MaskErrors
from .max_aliases impo... | 30 | 938 |
strawberry | strawberry/extensions/parser_cache.py | .py | from collections.abc import Callable, Iterator
from functools import cache, lru_cache
from typing import Any
from graphql.language.parser import parse
from strawberry.extensions.base_extension import SchemaExtension
@cache
def _get_parse_cache(maxsize: int | None) -> Callable[..., Any]:
# Shared LRU caches keye... | 58 | 1,900 |
strawberry | strawberry/extensions/disable_validation.py | .py | from collections.abc import Iterator
from strawberry.extensions.base_extension import SchemaExtension
class DisableValidation(SchemaExtension):
"""Disable query validation.
Example:
```python
import strawberry
from strawberry.extensions import DisableValidation
schema = strawberry.Schema(
... | 35 | 750 |
strawberry | strawberry/extensions/context.py | .py | from __future__ import annotations
import contextlib
import inspect
import types
from asyncio import iscoroutinefunction
from typing import (
TYPE_CHECKING,
Any,
NamedTuple,
)
from strawberry.extensions import SchemaExtension
if TYPE_CHECKING:
from collections.abc import AsyncIterator, Callable, Iter... | 214 | 6,970 |
strawberry | strawberry/extensions/query_depth_limiter.py | .py | # This is a Python port of https://github.com/stems/graphql-depth-limit
# which is licensed under the terms of the MIT license, reproduced below.
#
# -----------
#
# MIT License
#
# Copyright (c) 2017 Stem
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated... | 328 | 10,201 |
strawberry | strawberry/extensions/disable_introspection.py | .py | from graphql.validation import NoSchemaIntrospectionCustomRule
from strawberry.extensions import AddValidationRules
class DisableIntrospection(AddValidationRules):
"""Disable introspection queries.
Example:
```python
import strawberry
from strawberry.extensions import DisableIntrospection
... | 37 | 717 |
strawberry | strawberry/extensions/pydantic_error_extension.py | .py | from collections.abc import Iterator
from strawberry.extensions.base_extension import SchemaExtension
try:
from pydantic import ValidationError as PydanticValidationError
_PYDANTIC_AVAILABLE = True
except ImportError:
_PYDANTIC_AVAILABLE = False
class PydanticErrorExtension(SchemaExtension):
def on... | 43 | 1,161 |
strawberry | strawberry/extensions/max_aliases.py | .py | from collections.abc import Mapping
from graphql import (
FieldNode,
FragmentDefinitionNode,
FragmentSpreadNode,
GraphQLError,
InlineFragmentNode,
OperationDefinitionNode,
ValidationContext,
ValidationRule,
)
from strawberry.extensions.add_validation_rules import AddValidationRules
c... | 115 | 3,545 |
strawberry | strawberry/extensions/mask_errors.py | .py | from collections.abc import Callable, Iterator
from typing import Protocol, runtime_checkable
from graphql import ExecutionResult as GraphQLExecutionResult
from graphql.error import GraphQLError
from strawberry.extensions.base_extension import SchemaExtension
from strawberry.types.execution import (
ExecutionResu... | 92 | 3,192 |
strawberry | strawberry/extensions/validation_cache.py | .py | from collections.abc import Callable, Iterator
from functools import cache, lru_cache
from typing import Any
from strawberry.extensions.base_extension import SchemaExtension
@cache
def _get_validate_cache(maxsize: int | None) -> Callable[..., Any]:
# Shared LRU caches keyed by ``maxsize``. Multiple ``ValidationC... | 64 | 2,184 |
strawberry | strawberry/extensions/pyinstrument.py | .py | from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
from pyinstrument import Profiler
from strawberry.extensions.base_extension import SchemaExtension
if TYPE_CHECKING:
from collections.abc import Iterator
class PyInstrument(SchemaExtension):
"""Extension to profil... | 35 | 753 |
strawberry | strawberry/extensions/directives.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from strawberry.extensions import SchemaExtension
from strawberry.types.nodes import convert_arguments
from strawberry.utils.await_maybe import await_maybe
if TYPE_CHECKING:
from collections.abc import Callable
from graphql import Dire... | 98 | 3,134 |
strawberry | strawberry/extensions/add_validation_rules.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
from strawberry.extensions.base_extension import SchemaExtension
if TYPE_CHECKING:
from collections.abc import Iterator
from graphql import ASTValidationRule
class AddValidationRules(SchemaExtension):
"""Add graphql-core validation ru... | 55 | 1,358 |
strawberry | strawberry/extensions/field_extension.py | .py | from __future__ import annotations
import itertools
from collections.abc import Awaitable, Callable
from functools import cached_property
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from typing import TypeAlias
from strawberry.types import Info
from strawberry.types.field import StrawberryFie... | 186 | 6,701 |
strawberry | strawberry/extensions/tracing/datadog.py | .py | from __future__ import annotations
import hashlib
from functools import cached_property
from inspect import isawaitable
from typing import TYPE_CHECKING, Any
import ddtrace
from packaging import version
from strawberry.extensions import LifecycleStep, SchemaExtension
from strawberry.extensions.tracing.utils import s... | 187 | 5,759 |
strawberry | strawberry/extensions/tracing/utils.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from strawberry.extensions.utils import is_introspection_field
from strawberry.resolvers import is_default_resolver
if TYPE_CHECKING:
from collections.abc import Callable
from graphql import GraphQLResolveInfo
def should_skip_tracing... | 26 | 686 |
strawberry | strawberry/extensions/tracing/__init__.py | .py | import importlib
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from .apollo import ApolloTracingExtension, ApolloTracingExtensionSync
from .apollo_federation import (
ApolloFederationTracingExtension,
ApolloFederationTracingExtensionSync,
)
from .datadog import DatadogTracingE... | 45 | 1,530 |
strawberry | strawberry/extensions/tracing/opentelemetry.py | .py | from __future__ import annotations
from collections.abc import Callable
from copy import deepcopy
from inspect import isawaitable
from typing import (
TYPE_CHECKING,
Any,
)
from opentelemetry import trace
from opentelemetry.trace import SpanKind
from strawberry.extensions import LifecycleStep, SchemaExtensio... | 206 | 7,284 |
strawberry | strawberry/extensions/tracing/apollo.py | .py | from __future__ import annotations
import dataclasses
import time
from datetime import datetime, timezone
from inspect import isawaitable
from typing import TYPE_CHECKING, Any
from strawberry.extensions import SchemaExtension
from strawberry.extensions.utils import get_path_from_info
from .utils import should_skip_t... | 220 | 6,721 |
strawberry | strawberry/extensions/tracing/apollo_federation.py | .py | """Apollo Federation Tracing (FTV1) Extension.
This extension provides support for Apollo Federation's inline tracing format (ftv1).
When a request includes the 'apollo-federation-include-trace: ftv1' header,
this extension will include trace data in the response under extensions.ftv1.
Usage
-----
Use the async vers... | 532 | 17,967 |
strawberry | strawberry/django/apps.py | .py | from django.apps import AppConfig # pragma: no cover
class StrawberryConfig(AppConfig): # pragma: no cover
name = "strawberry"
| 6 | 135 |
strawberry | strawberry/django/__init__.py | .py | from typing import Any
try:
# import modules and objects from external strawberry-graphql-django
# package so that it can be used through strawberry.django namespace
from strawberry_django import * # noqa: F403
except ModuleNotFoundError:
import importlib
def __getattr__(name: str) -> Any:
... | 21 | 811 |
strawberry | strawberry/django/views.py | .py | from __future__ import annotations
import json
from typing import (
TYPE_CHECKING,
Any,
TypeGuard,
)
from asgiref.sync import markcoroutinefunction
from cross_web import (
AsyncDjangoHTTPRequestAdapter,
DjangoHTTPRequestAdapter,
HTTPException,
)
from django.core.serializers.json import DjangoJ... | 253 | 7,896 |
strawberry | strawberry/django/context.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from django.http import HttpRequest, HttpResponse
@dataclass
class StrawberryDjangoContext:
request: HttpRequest
response: HttpResponse
def __getitem__(self, key: str) -> Any... | 26 | 655 |
strawberry | strawberry/django/test/client.py | .py | from typing import Any
from strawberry.test import BaseGraphQLTestClient
class GraphQLTestClient(BaseGraphQLTestClient):
def request(
self,
body: dict[str, object],
headers: dict[str, object] | None = None,
files: dict[str, object] | None = None,
) -> Any:
if files:
... | 24 | 604 |
strawberry | strawberry/fastapi/__init__.py | .py | from strawberry.fastapi.context import BaseContext
from strawberry.fastapi.router import GraphQLRouter
__all__ = ["BaseContext", "GraphQLRouter"]
| 5 | 147 |
strawberry | strawberry/fastapi/router.py | .py | from __future__ import annotations
from datetime import timedelta
from inspect import signature
from typing import (
TYPE_CHECKING,
Any,
TypeGuard,
cast,
)
from typing_extensions import TypeVar
from cross_web import HTTPException, StarletteRequestAdapter
from fastapi import APIRouter, Depends, params
... | 322 | 11,794 |
strawberry | strawberry/fastapi/context.py | .py | from typing import Any, Union
from starlette.background import BackgroundTasks
from starlette.requests import Request
from starlette.responses import Response
from starlette.websockets import WebSocket
CustomContext = Union["BaseContext", dict[str, Any]]
MergedContext = Union[
"BaseContext", dict[str, Any | Backg... | 24 | 653 |
strawberry | strawberry/quart/views.py | .py | import asyncio
from collections.abc import AsyncGenerator, Callable, Mapping, Sequence
from datetime import timedelta
from json.decoder import JSONDecodeError
from typing import TYPE_CHECKING, ClassVar, TypeGuard, Union
from cross_web import HTTPException, QuartHTTPRequestAdapter
from quart import Request, Response, W... | 178 | 6,493 |
strawberry | strawberry/codemods/maybe_optional.py | .py | from __future__ import annotations
import libcst as cst
import libcst.matchers as m
from libcst._nodes.expression import BaseExpression # noqa: TC002
from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand
from libcst.codemod.visitors import AddImportsVisitor
class ConvertMaybeToOptional(VisitorBasedC... | 119 | 4,401 |
strawberry | strawberry/codemods/annotated_unions.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING
import libcst as cst
import libcst.matchers as m
from libcst._nodes.expression import BaseExpression, Call # noqa: TC002
from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand
from libcst.codemod.visitors import AddImportsVisitor, Rem... | 190 | 5,975 |
strawberry | strawberry/codemods/__init__.py | .py | from .annotated_unions import ConvertUnionToAnnotatedUnion
from .maybe_optional import ConvertMaybeToOptional
from .replace_scalar_wrappers import ReplaceScalarWrappers
from .update_imports import UpdateImportsCodemod
__all__ = [
"ConvertMaybeToOptional",
"ConvertUnionToAnnotatedUnion",
"ReplaceScalarWrapp... | 12 | 356 |
strawberry | strawberry/codemods/update_imports.py | .py | from __future__ import annotations
import libcst as cst
import libcst.matchers as m
from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand
from libcst.codemod.visitors import AddImportsVisitor, RemoveImportsVisitor
class UpdateImportsCodemod(VisitorBasedCodemodCommand):
def __init__(self, context:... | 135 | 4,622 |
strawberry | strawberry/codemods/replace_scalar_wrappers.py | .py | from __future__ import annotations
import libcst as cst
import libcst.matchers as m
from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand
from libcst.codemod.visitors import AddImportsVisitor
# Mapping from old scalar wrapper names to their replacements
# Format: old_name -> (module, import_name, usag... | 155 | 5,951 |
strawberry | strawberry/tools/__init__.py | .py | from .create_type import create_type
from .merge_types import merge_types
__all__ = [
"create_type",
"merge_types",
]
| 8 | 127 |
strawberry | strawberry/tools/create_type.py | .py | import types
from collections.abc import Sequence
import strawberry
from strawberry.types.field import StrawberryField
def create_type( # noqa: PLR0917
name: str,
fields: list[StrawberryField],
is_input: bool = False,
is_interface: bool = False,
description: str | None = None,
directives: Se... | 82 | 2,312 |
strawberry | strawberry/tools/merge_types.py | .py | import warnings
from collections import Counter
from itertools import chain
import strawberry
from strawberry.types.base import has_object_definition
def merge_types(name: str, types: tuple[type, ...]) -> type:
"""Merge multiple Strawberry types into one.
For example, given two queries `A` and `B`, one can ... | 39 | 1,023 |
strawberry | strawberry/codegen/types.py | .py | from __future__ import annotations
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, TypeAlias
if TYPE_CHECKING:
from collections.abc import Mapping
from enum import EnumMeta
from typing import Literal
from strawberry.types.unset import UnsetType
@dataclass
class GraphQLOpt... | 229 | 4,171 |
strawberry | strawberry/codegen/exceptions.py | .py | class CodegenError(Exception):
pass
class NoOperationProvidedError(CodegenError):
pass
class NoOperationNameProvidedError(CodegenError):
pass
class MultipleOperationsProvidedError(CodegenError):
pass
__all__ = [
"CodegenError",
"MultipleOperationsProvidedError",
"NoOperationNameProvi... | 23 | 365 |
strawberry | strawberry/codegen/__init__.py | .py | from .query_codegen import (
CodegenFile,
CodegenResult,
ConsolePlugin,
QueryCodegen,
QueryCodegenPlugin,
)
__all__ = [
"CodegenFile",
"CodegenResult",
"ConsolePlugin",
"QueryCodegen",
"QueryCodegenPlugin",
]
| 16 | 250 |
strawberry | strawberry/codegen/query_codegen.py | .py | from __future__ import annotations
from collections.abc import Callable, Iterable, Mapping, Sequence
from dataclasses import MISSING, dataclass
from enum import Enum
from functools import cmp_to_key, partial
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
cast,
)
from typing_extensions im... | 931 | 30,807 |
strawberry | strawberry/codegen/plugins/typescript.py | .py | from __future__ import annotations
import textwrap
from typing import TYPE_CHECKING, ClassVar
from strawberry.codegen import CodegenFile, QueryCodegenPlugin
from strawberry.codegen.types import (
GraphQLEnum,
GraphQLList,
GraphQLObjectType,
GraphQLOptional,
GraphQLScalar,
GraphQLUnion,
)
if T... | 125 | 3,865 |
strawberry | strawberry/codegen/plugins/print_operation.py | .py | from __future__ import annotations
import textwrap
from typing import TYPE_CHECKING
from strawberry.codegen import CodegenFile, QueryCodegenPlugin
from strawberry.codegen.types import (
GraphQLBoolValue,
GraphQLEnumValue,
GraphQLField,
GraphQLFieldSelection,
GraphQLFragmentSpread,
GraphQLFragm... | 213 | 6,786 |
strawberry | strawberry/codegen/plugins/python.py | .py | from __future__ import annotations
import textwrap
from collections import defaultdict
from dataclasses import dataclass
from typing import TYPE_CHECKING, ClassVar
from strawberry.codegen import CodegenFile, QueryCodegenPlugin
from strawberry.codegen.types import (
GraphQLEnum,
GraphQLEnumValue,
GraphQLLi... | 216 | 6,890 |
strawberry | strawberry/experimental/__init__.py | .py | try:
from . import pydantic
except ModuleNotFoundError:
pass
else:
__all__ = ["pydantic"]
| 7 | 102 |
strawberry | strawberry/experimental/pydantic/utils.py | .py | from __future__ import annotations
import dataclasses
from typing import (
TYPE_CHECKING,
Any,
NamedTuple,
cast,
)
from strawberry.experimental.pydantic._compat import (
CompatModelField,
PydanticCompat,
is_model_instance,
smart_deepcopy,
)
from strawberry.experimental.pydantic.excepti... | 135 | 4,040 |
strawberry | strawberry/experimental/pydantic/_compat.py | .py | import dataclasses
import sys
from collections.abc import Callable
from dataclasses import dataclass
from decimal import Decimal
from functools import cached_property
from typing import TYPE_CHECKING, Any, Optional
from uuid import UUID
import pydantic
from pydantic import BaseModel
from pydantic.version import VERSIO... | 362 | 10,456 |
strawberry | strawberry/experimental/pydantic/fields.py | .py | import builtins
from types import UnionType
from typing import (
Annotated,
Any,
Union,
)
from typing import GenericAlias as TypingGenericAlias # type: ignore
from strawberry.experimental.pydantic._compat import (
PydanticCompat,
get_args,
get_origin,
is_model_class,
)
from strawberry.expe... | 69 | 2,086 |
strawberry | strawberry/experimental/pydantic/exceptions.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from pydantic import BaseModel
from pydantic.typing import NoArgAnyCallable
class MissingFieldsListError(Exception):
def __init__(self, type: type[BaseModel]) -> None:
message = (
f"List of fie... | 56 | 1,486 |
strawberry | strawberry/experimental/pydantic/error_type.py | .py | from __future__ import annotations
import dataclasses
import warnings
from typing import (
TYPE_CHECKING,
Any,
Optional,
cast,
)
from strawberry.experimental.pydantic._compat import (
CompatModelField,
PydanticCompat,
is_model_class,
)
from strawberry.experimental.pydantic.utils import (
... | 144 | 4,237 |
strawberry | strawberry/experimental/pydantic/object_type.py | .py | from __future__ import annotations
import dataclasses
import sys
from typing import (
TYPE_CHECKING,
Any,
Optional,
cast,
)
from strawberry.annotation import StrawberryAnnotation
from strawberry.experimental.pydantic._compat import (
CompatModelField,
PydanticCompat,
)
from strawberry.experime... | 363 | 13,195 |
strawberry | strawberry/experimental/pydantic/__init__.py | .py | from .error_type import error_type
from .exceptions import UnregisteredTypeException
from .object_type import input, interface, type # noqa: A004
__all__ = [
"UnregisteredTypeException",
"error_type",
"input",
"interface",
"type",
]
| 12 | 255 |
strawberry | strawberry/experimental/pydantic/conversion_types.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, TypeVar
from typing_extensions import Protocol
from pydantic import BaseModel
if TYPE_CHECKING:
from strawberry.types.base import StrawberryObjectDefinition
PydanticModel = TypeVar("PydanticModel", bound=BaseModel)
class StrawberryType... | 35 | 912 |
strawberry | strawberry/experimental/pydantic/conversion.py | .py | from __future__ import annotations
import copy
import dataclasses
from typing import TYPE_CHECKING, Any, cast
from strawberry.types.base import (
StrawberryList,
StrawberryOptional,
has_object_definition,
)
from strawberry.types.enum import StrawberryEnumDefinition
from strawberry.types.union import Straw... | 137 | 4,960 |
strawberry | strawberry/execution/is_awaitable.py | .py | """Optimized is_awaitable implementation for GraphQL execution.
This module provides a highly optimized is_awaitable function that adds a fast path
for common synchronous types, significantly improving performance when dealing with
large result sets containing primitive values.
"""
from __future__ import annotations
... | 60 | 1,705 |
strawberry | strawberry/execution/__init__.py | .py | """Execution utilities for Strawberry GraphQL."""
from .is_awaitable import optimized_is_awaitable
__all__ = ["optimized_is_awaitable"]
| 6 | 138 |
strawberry | strawberry/http/types.py | .py | from collections.abc import Mapping
from typing import Any, Literal
from typing_extensions import TypedDict
HTTPMethod = Literal[
"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE"
]
QueryParams = Mapping[str, str | None]
class FormData(TypedDict):
files: Mapping[str, Any]
form: Mapping... | 18 | 385 |
strawberry | strawberry/http/exceptions.py | .py | class NonTextMessageReceived(Exception):
pass
class NonJsonMessageReceived(Exception):
pass
class WebSocketDisconnected(Exception):
pass
__all__ = [
"NonJsonMessageReceived",
"NonTextMessageReceived",
"WebSocketDisconnected",
]
| 18 | 258 |
strawberry | strawberry/http/__init__.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Literal
from typing_extensions import TypedDict
from strawberry.schema._graphql_core import (
GraphQLIncrementalExecutionResults,
ResultType,
)
class GraphQLHTTPResponse(TypedDict, total=False):
data: dict[str, ... | 58 | 1,523 |
strawberry | strawberry/http/ides.py | .py | import pathlib
from typing import Literal
GraphQL_IDE = Literal["graphiql", "apollo-sandbox", "pathfinder"]
def get_graphql_ide_html(
graphql_ide: GraphQL_IDE | None = "graphiql",
) -> str:
here = pathlib.Path(__file__).parents[1]
if graphql_ide == "apollo-sandbox":
path = here / "static/apollo-... | 23 | 571 |
strawberry | strawberry/http/temporal_response.py | .py | from dataclasses import dataclass, field
@dataclass
class TemporalResponse:
status_code: int = 200
headers: dict[str, str] = field(default_factory=dict)
__all__ = ["TemporalResponse"]
| 11 | 196 |
strawberry | strawberry/http/sync_base_view.py | .py | import abc
import json
from collections.abc import Callable
from typing import Generic
from cross_web import HTTPException, SyncHTTPRequestAdapter
from graphql import GraphQLError
from strawberry.exceptions import MissingQueryError
from strawberry.file_uploads.utils import replace_placeholders_with_files
from strawbe... | 289 | 10,514 |
strawberry | strawberry/http/typevars.py | .py | from typing_extensions import TypeVar
Request = TypeVar("Request", contravariant=True)
Response = TypeVar("Response")
SubResponse = TypeVar("SubResponse")
WebSocketRequest = TypeVar("WebSocketRequest")
WebSocketResponse = TypeVar("WebSocketResponse")
Context = TypeVar("Context", default=None)
RootValue = TypeVar("Root... | 21 | 489 |
strawberry | strawberry/http/streaming.py | .py | from __future__ import annotations
import abc
import asyncio
import contextlib
from collections.abc import AsyncGenerator, Callable, Iterable, Mapping
from typing import TYPE_CHECKING, Any, ClassVar
from strawberry.types.graphql import OperationType
if TYPE_CHECKING:
from strawberry.http import GraphQLHTTPRespon... | 293 | 9,662 |
strawberry | strawberry/http/base.py | .py | import json
from collections.abc import Mapping, Sequence
from functools import cached_property
from typing import Any, Generic
from typing_extensions import Protocol
from cross_web import HTTPException
from strawberry.http import GraphQLRequestData, GraphQLRequestProtocol
from strawberry.http.ides import GraphQL_IDE... | 147 | 4,723 |
strawberry | strawberry/http/parse_content_type.py | .py | from email.message import Message
def parse_content_type(content_type: str) -> tuple[str, dict[str, str]]:
"""Parse a content type header into a mime-type and a dictionary of parameters."""
email = Message()
email["content-type"] = content_type
params = email.get_params()
assert params
mime... | 16 | 381 |
strawberry | strawberry/http/async_base_view.py | .py | import abc
import asyncio
import json
from collections.abc import AsyncGenerator, Callable, Mapping, Sequence
from datetime import timedelta
from typing import (
Any,
Generic,
TypeGuard,
cast,
overload,
)
from cross_web import AsyncHTTPRequestAdapter, HTTPException
from graphql import GraphQLError
... | 643 | 22,744 |
strawberry | strawberry/asgi/__init__.py | .py | from __future__ import annotations
from datetime import timedelta
from json import JSONDecodeError
from typing import (
TYPE_CHECKING,
TypeGuard,
)
from cross_web import HTTPException, StarletteRequestAdapter
from starlette import status
from starlette.requests import Request
from starlette.responses import (... | 219 | 7,188 |
strawberry | strawberry/asgi/test/client.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING, Any
from strawberry.test import BaseGraphQLTestClient
if TYPE_CHECKING:
from collections.abc import Mapping
from typing import Literal
class GraphQLTestClient(BaseGraphQLTestClient):
def _build_body(
self,
... | 55 | 1,440 |
strawberry | strawberry/relay/types.py | .py | from __future__ import annotations
import dataclasses
import inspect
import itertools
import sys
from collections.abc import (
AsyncIterable,
AsyncIterator,
Awaitable,
Iterable,
Iterator,
Sequence,
)
from typing import (
TYPE_CHECKING,
Annotated,
Any,
ClassVar,
ForwardRef,
... | 962 | 30,341 |
strawberry | strawberry/relay/utils.py | .py | from __future__ import annotations
import base64
import dataclasses
import sys
from typing import TYPE_CHECKING, Any
from typing_extensions import Self, assert_never
from strawberry.types.base import StrawberryObjectDefinition
from strawberry.types.nodes import InlineFragment
if TYPE_CHECKING:
import strawberry
... | 193 | 5,516 |
strawberry | strawberry/relay/fields.py | .py | from __future__ import annotations
import asyncio
import dataclasses
import inspect
from collections import defaultdict
from collections.abc import (
AsyncIterable,
AsyncIterator,
Awaitable,
Callable,
Iterable,
Iterator,
Mapping,
Sequence,
)
from typing import (
TYPE_CHECKING,
A... | 517 | 18,697 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.