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
tests/test_inspect.py
.py
from strawberry.utils.inspect import in_async_context def test_in_async_context_sync(): assert not in_async_context() async def test_in_async_context_async(): assert in_async_context() async def test_in_async_context_async_with_inner_sync_function(): def inner_sync_function(): assert in_async_...
17
357
strawberry
tests/d.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Annotated import strawberry if TYPE_CHECKING: from tests.c import C @strawberry.type class D: id: strawberry.ID @strawberry.field async def c_list( self, ) -> list[Annotated[C, strawberry.lazy("tests.c")]]: # pragma:...
22
392
strawberry
tests/test_forward_references.py
.py
# type: ignore from __future__ import annotations import textwrap from typing import Annotated import strawberry from strawberry.printer import print_schema from strawberry.scalars import JSON from strawberry.types.base import StrawberryList, StrawberryOptional from tests.a import A from tests.d import D def test_f...
272
6,053
strawberry
tests/a.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Annotated import strawberry if TYPE_CHECKING: from tests.b import B @strawberry.type class A: id: strawberry.ID @strawberry.field async def b(self) -> Annotated[B, strawberry.lazy("tests.b")]: from tests.b import B ...
32
677
strawberry
tests/test_auto.py
.py
from typing import Annotated, Any, cast, get_args import strawberry from strawberry.annotation import StrawberryAnnotation from strawberry.types.auto import StrawberryAuto, auto from strawberry.types.base import StrawberryList @strawberry.type class ExampleType: some_var: str def test_singleton(): assert g...
55
1,536
strawberry
tests/test_aio.py
.py
from strawberry.utils.aio import ( aenumerate, aislice, asyncgen_to_list, resolve_awaitable, ) async def test_aenumerate(): async def gen(): yield "a" yield "b" yield "c" yield "d" res = [(i, v) async for i, v in aenumerate(gen())] assert res == [(0, "a"), ...
90
2,026
strawberry
tests/conftest.py
.py
import pathlib import sys import pytest from strawberry.utils import IS_GQL_32 def pytest_emoji_xfailed(config: pytest.Config) -> tuple[str, str]: return "🤷‍♂️ ", "XFAIL 🤷‍♂️ " def pytest_emoji_skipped(config: pytest.Config) -> tuple[str, str]: return "🦘 ", "SKIPPED 🦘" pytest_plugins = ("tests.plugi...
58
1,397
strawberry
tests/b.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Annotated import strawberry if TYPE_CHECKING: from tests.a import A @strawberry.type class B: id: strawberry.ID @strawberry.field async def a(self) -> Annotated[A, strawberry.lazy("tests.a"), object()]: from tests.a impor...
44
935
strawberry
tests/sanic/test_file_upload.py
.py
from __future__ import annotations from io import BytesIO from typing import TYPE_CHECKING import pytest import strawberry from strawberry.file_uploads import Upload if TYPE_CHECKING: from sanic import Sanic @strawberry.type class Query: @strawberry.field def index(self) -> str: return "Hello ...
99
2,390
strawberry
tests/litestar/test_response_status.py
.py
import strawberry # TODO: move this to common tests def test_set_custom_http_response_status(): from litestar import Litestar from litestar.testing import TestClient from strawberry.litestar import make_graphql_controller @strawberry.type class Query: @strawberry.field def abc(se...
50
1,574
strawberry
tests/litestar/app.py
.py
from typing import Any from litestar import Litestar, Request from litestar.di import Provide from strawberry.litestar import make_graphql_controller from tests.views.schema import schema def custom_context_dependency() -> str: return "Hi!" async def get_root_value(request: Request = None): return request...
37
888
strawberry
tests/litestar/test_response_headers.py
.py
import strawberry # TODO: move this to common tests def test_set_response_headers(): from litestar import Litestar from litestar.testing import TestClient from strawberry.litestar import make_graphql_controller @strawberry.type class Query: @strawberry.field def abc(self, info: s...
66
2,092
strawberry
tests/litestar/test_context.py
.py
import strawberry def test_base_context(): from strawberry.litestar import BaseContext base_context = BaseContext() assert base_context.request is None def test_with_class_context_getter(): from litestar import Litestar from litestar.di import Provide from litestar.testing import TestClient...
218
6,741
strawberry
tests/litestar/conftest.py
.py
import pytest @pytest.fixture def test_client(): from litestar.testing import TestClient from tests.litestar.app import create_app app = create_app() return TestClient(app) @pytest.fixture def test_client_keep_alive(): from litestar.testing import TestClient from tests.litestar.app import...
22
423
strawberry
tests/exceptions/test_exception_handler.py
.py
import os import sys from strawberry.exceptions import MissingFieldAnnotationError from strawberry.exceptions.handler import ( reset_exception_handler, setup_exception_handler, strawberry_exception_handler, ) def test_exception_handler(mocker): print_mock = mocker.patch("rich.print", autospec=True) ...
92
2,557
strawberry
tests/exceptions/test_threading_exception_handler.py
.py
import os import threading from strawberry.exceptions import MissingFieldAnnotationError from strawberry.exceptions.handler import ( reset_exception_handler, setup_exception_handler, strawberry_threading_exception_handler, ) def test_exception_handler(mocker): print_mock = mocker.patch("rich.print", ...
98
2,719
strawberry
tests/exceptions/test_exception_source.py
.py
import sys from pathlib import Path import pytest from strawberry.exceptions.exception_source import ExceptionSource pytestmark = pytest.mark.skipif( sys.platform == "win32", reason="Test is meant to run on Unix systems" ) def test_returns_relative_path(mocker): mocker.patch.object(Path, "cwd", return_valu...
41
958
strawberry
tests/exceptions/classes/test_exception_class_missing_optional_dependencies_error.py
.py
import pytest from strawberry.exceptions import MissingOptionalDependenciesError def test_missing_optional_dependencies_error(): with pytest.raises(MissingOptionalDependenciesError) as exc_info: raise MissingOptionalDependenciesError assert exc_info.value.message == "Some optional dependencies are m...
58
1,973
strawberry
tests/file_uploads/test_utils.py
.py
from io import BytesIO from strawberry.file_uploads.utils import replace_placeholders_with_files def test_does_deep_copy(): operations = { "query": "mutation($file: Upload!) { upload_file(file: $file) { id } }", "variables": {"file": None}, } files_map = {} files = {} result = re...
134
4,528
strawberry
tests/python_312/test_python_generics.py
.py
"""These tests are for Generics that don't expose any generic parts to the schema.""" import sys import textwrap import pytest import strawberry pytestmark = pytest.mark.skipif( sys.version_info < (3, 12), reason="These are tests for Python 3.12+" ) def test_does_not_create_a_new_type_when_no_generic_field_exp...
182
4,319
strawberry
tests/python_312/test_inspect.py
.py
import pytest import strawberry from strawberry.utils.inspect import get_specialized_type_var_map @pytest.mark.parametrize("value", [object, type(None), int, str, type("Foo", (), {})]) def test_get_specialized_type_var_map_non_generic(value: type): assert get_specialized_type_var_map(value) is None def test_get...
146
3,083
strawberry
tests/python_312/test_generic_objects.py
.py
import datetime import sys from typing import Annotated import pytest import strawberry from strawberry.types.base import ( StrawberryList, StrawberryOptional, StrawberryTypeVar, get_object_definition, ) from strawberry.types.union import StrawberryUnion pytestmark = pytest.mark.skipif( sys.versio...
643
17,700
strawberry
tests/python_312/test_generics_schema.py
.py
import sys import textwrap import warnings from enum import Enum from typing import Any, Self import pytest import strawberry pytestmark = pytest.mark.skipif( sys.version_info < (3, 12), reason="These are tests for Python 3.12+" ) def test_supports_generic_simple_type(): @strawberry.type class Edge[T]: ...
1,239
25,512
strawberry
tests/extensions/test_custom_objects_for_setting_attribute.py
.py
import pytest from strawberry.extensions.tracing.opentelemetry import OpenTelemetryExtension @pytest.fixture def otel_ext(): return OpenTelemetryExtension() class SimpleObject: def __init__(self, value): self.value = value def __str__(self): return f"SimpleObject({self.value})" class...
141
3,759
strawberry
tests/extensions/test_pyinstrument.py
.py
import tempfile import time from pathlib import Path import strawberry from strawberry.extensions import pyinstrument def function_called_by_us_a(): time.sleep(0.1) return function_called_by_us_b() def function_called_by_us_b(): time.sleep(0.1) return function_called_by_us_c() def function_called...
54
1,287
strawberry
tests/extensions/tracing/test_apollo_federation.py
.py
import base64 from unittest.mock import Mock, patch import pytest import strawberry from strawberry.extensions.tracing.apollo_federation import ( ApolloFederationTracingExtension, ApolloFederationTracingExtensionSync, ) @pytest.fixture def mock_request_with_ftv1_header(): """Create a mock request with F...
661
17,698
strawberry
tests/extensions/tracing/test_opentelemetry.py
.py
from unittest.mock import Mock from opentelemetry.trace import Span, TracerProvider from strawberry.extensions import LifecycleStep from strawberry.extensions.tracing.opentelemetry import ( OpenTelemetryExtension, OpenTelemetryExtensionSync, ) def test_span_holder_initialization(): extension = OpenTelem...
32
1,143
strawberry
tests/django/test_dataloaders.py
.py
import json import pytest from asgiref.sync import sync_to_async from pytest_mock import MockerFixture import strawberry from strawberry.dataloader import DataLoader pytestmark = [pytest.mark.asyncio] def _prepare_db(): from .app.models import Example return [ Example.objects.create(name=f"This is...
89
2,263
strawberry
tests/django/django_settings.py
.py
SECRET_KEY = 1 INSTALLED_APPS = ["tests.django.app"] ROOT_URLCONF = "tests.django.app.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [], "APP_DIRS": True, } ] DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory...
19
514
strawberry
tests/django/test_extensions.py
.py
def test_extensions(graphql_client): query = "{ hello }" response = graphql_client.query(query) assert response.extensions["example"] == "example"
7
161
strawberry
tests/django/conftest.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from strawberry.django.test import GraphQLTestClient @pytest.fixture def graphql_client() -> GraphQLTestClient: from django.test.client import Client from strawberry.django.test import GraphQLTestClient...
18
361
strawberry
tests/django/app/models.py
.py
from django.db import models class Example(models.Model): # noqa: DJ008 name = models.CharField(max_length=100)
6
119
strawberry
tests/django/app/urls.py
.py
from django.urls import path from strawberry.django.views import GraphQLView as BaseGraphQLView from tests.views.schema import Query, schema class GraphQLView(BaseGraphQLView): def get_root_value(self, request) -> Query: return Query() urlpatterns = [ path("graphql/", GraphQLView.as_view(schema=sch...
15
329
strawberry
tests/test_printer/test_defer_stream.py
.py
from __future__ import annotations import textwrap import strawberry from strawberry.schema.config import StrawberryConfig from tests.conftest import skip_if_gql_32 pytestmark = skip_if_gql_32("GraphQL 3.3.0 is required for incremental execution") @strawberry.type class Query: hello: str def test_does_not_pr...
49
1,220
strawberry
tests/test_printer/test_basic.py
.py
import textwrap from uuid import UUID import pytest import strawberry from strawberry import UNSET, Maybe, Some from strawberry.printer import print_schema from strawberry.scalars import JSON from strawberry.schema.config import StrawberryConfig from strawberry.utils import IS_GQL_32 from tests.conftest import skip_i...
524
12,414
strawberry
tests/test_printer/test_schema_directives.py
.py
import textwrap from enum import Enum from typing import Annotated, Any import strawberry from strawberry import BasePermission, Info from strawberry.permission import PermissionExtension from strawberry.printer import print_schema from strawberry.schema.config import StrawberryConfig from strawberry.schema_directive ...
873
22,823
strawberry
tests/test_printer/test_one_of.py
.py
from __future__ import annotations import textwrap import strawberry from strawberry.schema_directives import OneOf @strawberry.input(directives=[OneOf()]) class ExampleInputTagged: a: str | None b: int | None @strawberry.type class ExampleResult: a: str | None b: int | None @strawberry.type cla...
51
902
strawberry
tests/fastapi/app.py
.py
from typing import Any from fastapi import BackgroundTasks, Depends, FastAPI, Request, WebSocket from strawberry.fastapi import GraphQLRouter from tests.views.schema import schema def custom_context_dependency() -> str: return "Hi!" async def get_context( background_tasks: BackgroundTasks, request: Re...
41
977
strawberry
tests/fastapi/test_router.py
.py
import pytest import strawberry def test_include_router_prefix(): from fastapi import FastAPI from starlette.testclient import TestClient from strawberry.fastapi import GraphQLRouter @strawberry.type class Query: @strawberry.field def abc(self) -> str: return "abc" ...
73
1,850
strawberry
tests/fastapi/test_async.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest import strawberry if TYPE_CHECKING: from starlette.testclient import TestClient @pytest.fixture def test_client() -> TestClient: from starlette.testclient import TestClient from tests.fastapi.app import create_app ...
34
792
strawberry
tests/fastapi/test_openapi.py
.py
import strawberry @strawberry.type class Query: abc: str def test_enable_graphiql_view_and_allow_queries_via_get(): from fastapi import FastAPI from strawberry.fastapi import GraphQLRouter app = FastAPI() schema = strawberry.Schema(query=Query) graphql_app = GraphQLRouter[None, None](schem...
51
1,432
strawberry
tests/fastapi/test_context.py
.py
import asyncio from collections.abc import AsyncGenerator import pytest import strawberry from strawberry.exceptions import InvalidCustomContext from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL from strawberry.subscriptions.protocols.graphql_transport_ws import ( types as tr...
342
11,005
strawberry
tests/fields/test_field_descriptions.py
.py
import strawberry def test_field_descriptions(): description = "this description is super cool" field = strawberry.field(description=description) assert field.description == description
10
202
strawberry
tests/fields/test_field_defaults.py
.py
import pytest import strawberry from strawberry.exceptions import ( FieldWithResolverAndDefaultFactoryError, FieldWithResolverAndDefaultValueError, InvalidDefaultFactoryError, ) from strawberry.types.field import StrawberryField def test_field_with_default(): @strawberry.type class Query: ...
83
2,200
strawberry
tests/fields/test_field_basics.py
.py
import strawberry def test_type_add_type_definition_with_fields(): @strawberry.type class Query: name: str age: int definition = Query.__strawberry_definition__ assert definition.name == "Query" assert len(definition.fields) == 2 assert definition.fields[0].python_name == "n...
38
947
strawberry
tests/fields/test_permissions.py
.py
from typing import Any import pytest from asgiref.sync import sync_to_async import strawberry from strawberry.permission import BasePermission def test_permission_classes_basic_fields(): class IsAuthenticated(BasePermission): message = "User is not authenticated" def has_permission( ...
84
2,244
strawberry
tests/fields/test_field_names.py
.py
import strawberry def test_field_name_standard(): standard_field = strawberry.field() assert standard_field.python_name is None assert standard_field.graphql_name is None def test_field_name_standard_on_schema(): @strawberry.type() class Query: normal_field: int [field] = Query.__s...
42
1,026
strawberry
tests/fields/test_field_exceptions.py
.py
import textwrap from typing import Any import pytest import strawberry from strawberry.annotation import StrawberryAnnotation from strawberry.exceptions import ( FieldWithResolverAndDefaultFactoryError, FieldWithResolverAndDefaultValueError, ) from strawberry.extensions.field_extension import FieldExtension f...
69
2,048
strawberry
tests/fields/test_arguments.py
.py
from typing import Annotated import pytest import strawberry from strawberry import UNSET from strawberry.exceptions import ( InvalidArgumentTypeError, MultipleStrawberryArgumentsError, ) from strawberry.types.base import StrawberryList, StrawberryOptional def test_basic_arguments(): @strawberry.type ...
506
13,929
strawberry
tests/fields/test_resolvers.py
.py
import dataclasses import textwrap import types from typing import Any, ClassVar, ForwardRef, no_type_check import pytest import strawberry from strawberry.exceptions import ( MissingArgumentsAnnotationsError, MissingFieldAnnotationError, MissingReturnAnnotationError, ) from strawberry.parent import Paren...
738
21,795
strawberry
tests/codemods/test_imports.py
.py
from libcst.codemod import CodemodTest from strawberry.codemods.update_imports import UpdateImportsCodemod class TestConvertConstantCommand(CodemodTest): TRANSFORM = UpdateImportsCodemod def test_update_field(self) -> None: before = """ from strawberry.field import something """ ...
177
4,795
strawberry
tests/codemods/test_replace_scalar_wrappers.py
.py
from libcst.codemod import CodemodTest from strawberry.codemods.replace_scalar_wrappers import ReplaceScalarWrappers class TestReplaceScalarWrappers(CodemodTest): TRANSFORM = ReplaceScalarWrappers def test_replace_date(self) -> None: before = """ from strawberry.schema.types.base_scalars...
172
4,124
strawberry
tests/codemods/test_annotated_unions_pipe.py
.py
from libcst.codemod import CodemodTest from strawberry.codemods.annotated_unions import ConvertUnionToAnnotatedUnion class TestConvertConstantCommand(CodemodTest): TRANSFORM = ConvertUnionToAnnotatedUnion def test_update_union(self) -> None: before = """ AUnion = strawberry.union(name="A...
132
3,599
strawberry
tests/codemods/test_annotated_unions.py
.py
from libcst.codemod import CodemodTest from strawberry.codemods.annotated_unions import ConvertUnionToAnnotatedUnion class TestConvertConstantCommand(CodemodTest): TRANSFORM = ConvertUnionToAnnotatedUnion def test_update_union(self) -> None: before = """ AUnion = strawberry.union(name="A...
147
4,149
strawberry
tests/codemods/test_maybe_optional.py
.py
from libcst.codemod import CodemodTest from strawberry.codemods.maybe_optional import ConvertMaybeToOptional class TestConvertMaybeToOptional(CodemodTest): TRANSFORM = ConvertMaybeToOptional def test_simple_maybe(self) -> None: before = """ from strawberry import Maybe field...
179
4,413
strawberry
tests/tools/test_merge_types.py
.py
from textwrap import dedent import pytest import strawberry from strawberry.tools import merge_types @strawberry.type class Person: @strawberry.field def name(self) -> str: return "Eve" @strawberry.field def age(self) -> int: return 42 @strawberry.type class SimpleGreeter: @st...
91
2,340
strawberry
tests/tools/test_create_type.py
.py
from textwrap import dedent import pytest import strawberry from strawberry.annotation import StrawberryAnnotation from strawberry.tools import create_type from strawberry.types.base import get_object_definition from strawberry.types.field import StrawberryField def test_create_type(): @strawberry.field def...
249
6,939
strawberry
tests/codegen/test_print_operation.py
.py
from pathlib import Path import pytest from strawberry.codegen import QueryCodegen from strawberry.codegen.plugins.print_operation import PrintOperationPlugin HERE = Path(__file__).parent QUERIES = list(HERE.glob("queries/*.graphql")) @pytest.mark.parametrize("query", QUERIES, ids=[x.name for x in QUERIES]) def te...
23
569
strawberry
tests/codegen/lazy_type.py
.py
import strawberry @strawberry.type class LaziestType: something: bool
7
76
strawberry
tests/codegen/test_relay_node_id_codegen.py
.py
from pathlib import Path import pytest from pytest_snapshot.plugin import Snapshot import strawberry from strawberry.codegen import QueryCodegen, QueryCodegenPlugin from strawberry.codegen.plugins.python import PythonPlugin from strawberry.codegen.plugins.typescript import TypeScriptPlugin from strawberry.relay impor...
85
2,174
strawberry
tests/codegen/test_query_codegen.py
.py
# - 1. test fragments # - 2. test variables # - 3. test input objects # - 4. test mutations (raise?) # - 5. test subscriptions (raise) from pathlib import Path import pytest from pytest_snapshot.plugin import Snapshot from strawberry.codegen import QueryCodegen, QueryCodegenPlugin from strawberry.codegen.exceptions ...
86
2,415
strawberry
tests/codegen/conftest.py
.py
import datetime import decimal import enum import random from typing import ( TYPE_CHECKING, Annotated, Generic, NewType, TypeVar, ) from uuid import UUID import pytest import strawberry if TYPE_CHECKING: from .lazy_type import LaziestType JSON = strawberry.scalar(NewType("JSON", str)) @st...
175
3,793
strawberry
tests/codegen/snapshots/python/mutation_with_object.py
.py
from typing import List, Optional from enum import Enum class AddBlogPostsResultAddBlogPostsPosts: title: str class AddBlogPostsResultAddBlogPosts: posts: list[AddBlogPostsResultAddBlogPostsPosts] class AddBlogPostsResult: add_blog_posts: AddBlogPostsResultAddBlogPosts class Color(Enum): RED = "RED"...
28
667
strawberry
tests/codegen/snapshots/python/mutation-fragment.py
.py
class IdFragment: # typename: BlogPost id: str class addBookResult: add_book: IdFragment class addBookVariables: input: str
10
142
strawberry
tests/codegen/snapshots/python/mutation.py
.py
class addBookResultAddBook: id: str class addBookResult: add_book: addBookResultAddBook class addBookVariables: input: str
9
137
strawberry
tests/codegen/snapshots/python/interface_fragments.py
.py
from typing import Union class OperationNameResultInterfaceBlogPost: # typename: BlogPost id: str title: str class OperationNameResultInterfaceImage: # typename: Image id: str url: str OperationNameResultInterface = Union[OperationNameResultInterfaceBlogPost, OperationNameResultInterfaceImage...
17
394
strawberry
tests/codegen/snapshots/python/enum.py
.py
from enum import Enum class Color(Enum): RED = "RED" GREEN = "GREEN" BLUE = "BLUE" class OperationNameResult: enum: Color
10
140
strawberry
tests/codegen/snapshots/python/with_directives.py
.py
class OperationNameResultPerson: name: str class OperationNameResult: person: OperationNameResultPerson
6
113
strawberry
tests/codegen/snapshots/python/union_with_typename_and_fragment.py
.py
from typing import Optional, Union class AnimalProjection: # typename: Animal age: int class OperationNameResultUnionPerson: # typename: Person name: str OperationNameResultUnion = Union[AnimalProjection, OperationNameResultUnionPerson] class OperationNameResultOptionalUnionPerson: # typename: P...
22
567
strawberry
tests/codegen/snapshots/python/custom_scalar.py
.py
from typing import NewType JSON = NewType("JSON", str) class OperationNameResult: json: JSON
7
99
strawberry
tests/codegen/snapshots/python/alias.py
.py
class OperationNameResultLazy: # alias for something lazy: bool class OperationNameResult: id: str # alias for id second_id: str # alias for float a_float: float lazy: OperationNameResultLazy
12
225
strawberry
tests/codegen/snapshots/python/generic_types.py
.py
from typing import List class ListLifeGenericResultListLifeItems1: name: str age: int class ListLifeGenericResultListLifeItems2: name: str age: int class ListLifeGenericResultListLife: items1: list[ListLifeGenericResultListLifeItems1] items2: list[ListLifeGenericResultListLifeItems2] class L...
17
387
strawberry
tests/codegen/snapshots/python/interface_fragments_with_spread.py
.py
from typing import Union class PartialBlogPost: # typename: BlogPost title: str class OperationNameResultInterfaceBlogPost: # typename: BlogPost id: str title: str class OperationNameResultInterfaceImage: # typename: Image id: str url: str OperationNameResultInterface = Union[Operati...
21
458
strawberry
tests/codegen/snapshots/python/union.py
.py
from typing import Optional, Union class OperationNameResultUnionAnimal: # typename: Animal age: int class OperationNameResultUnionPerson: # typename: Person name: str OperationNameResultUnion = Union[OperationNameResultUnionAnimal, OperationNameResultUnionPerson] class OperationNameResultOptionalUn...
26
700
strawberry
tests/codegen/snapshots/python/interface_single_fragment.py
.py
class OperationNameResultInterfaceBlogPost: # typename: BlogPost id: str title: str class OperationNameResult: interface: OperationNameResultInterfaceBlogPost
8
176
strawberry
tests/codegen/snapshots/python/fragment.py
.py
class PersonName: # typename: Person name: str class OperationNameResult: person: PersonName
7
106
strawberry
tests/codegen/snapshots/python/union_with_one_type.py
.py
class OperationNameResultUnionAnimal: # typename: Animal age: int name: str class OperationNameResult: union: OperationNameResultUnionAnimal
8
158
strawberry
tests/codegen/snapshots/python/optional_and_lists.py
.py
from typing import List, Optional class OperationNameResult: optional_int: Optional[int] list_of_int: list[int] list_of_optional_int: list[Optional[int]] optional_list_of_optional_int: Optional[list[Optional[int]]]
8
232
strawberry
tests/codegen/snapshots/python/nullable_list_of_non_scalars.py
.py
from typing import List, Optional class OperationNameResultOptionalListOfPeople: name: str age: int class OperationNameResult: optional_list_of_people: Optional[list[OperationNameResultOptionalListOfPeople]]
9
222
strawberry
tests/codegen/snapshots/python/union_return.py
.py
class OperationNameResultGetPersonOrAnimalPerson: # typename: Person name: str age: int class OperationNameResult: get_person_or_animal: OperationNameResultGetPersonOrAnimalPerson
8
197
strawberry
tests/codegen/snapshots/python/basic.py
.py
from uuid import UUID from datetime import date, datetime, time from decimal import Decimal class OperationNameResultLazy: something: bool class OperationNameResult: id: str integer: int float: float boolean: bool uuid: UUID date: date datetime: datetime time: time decimal: Dec...
19
359
strawberry
tests/codegen/snapshots/python/variables.py
.py
from typing import List, Optional class OperationNameResult: with_inputs: bool class PersonInput: name: str age: Optional[int] = None class ExampleInput: id: str name: str age: int person: Optional[PersonInput] people: list[PersonInput] optional_people: Optional[list[PersonInput]]...
24
513
strawberry
tests/codegen/snapshots/python/multiple_types.py
.py
from typing import List class OperationNameResultPerson: name: str class OperationNameResultListOfPeople: name: str class OperationNameResult: person: OperationNameResultPerson list_of_people: list[OperationNameResultListOfPeople]
12
250
strawberry
tests/codegen/snapshots/python/interface.py
.py
class OperationNameResultInterface: id: str class OperationNameResult: interface: OperationNameResultInterface
6
120
strawberry
tests/codegen/snapshots/python/multiple_types_optional.py
.py
from typing import Optional class OperationNameResultOptionalPerson: name: str class OperationNameResult: optional_person: Optional[OperationNameResultOptionalPerson]
8
177
strawberry
tests/codegen/snapshots/relay/python/relay_list.py
.py
from typing import List class RelayListResultUsers: id: str name: str class RelayListResult: users: list[RelayListResultUsers]
9
141
strawberry
tests/codegen/snapshots/relay/python/relay_fragment.py
.py
class UserFields: # typename: User id: str name: str class RelayFragmentResult: node: UserFields
8
114
strawberry
tests/codegen/snapshots/relay/python/relay_variables.py
.py
class RelayVariablesResultNode: id: str name: str class RelayVariablesResult: node: RelayVariablesResultNode class RelayVariablesVariables: nodeId: str
10
170
strawberry
tests/codegen/snapshots/relay/python/relay_node_id.py
.py
class GetNodeWithIDResultNodeUser: # typename: User id: str name: str class GetNodeWithIDResult: node: GetNodeWithIDResultNodeUser
8
148
strawberry
tests/codegen/snapshots/relay/python/relay_alias.py
.py
class RelayAliasResultNode: # alias for id nodeId: str # alias for name userName: str class RelayAliasResult: node: RelayAliasResultNode
9
158
strawberry
tests/codegen/snapshots/relay/python/relay_nested_nodes.py
.py
class RelayNestedNodesResultPostAuthor: id: str name: str class RelayNestedNodesResultPost: id: str title: str author: RelayNestedNodesResultPostAuthor class RelayNestedNodesResult: post: RelayNestedNodesResultPost
12
241
strawberry
tests/experimental/pydantic/utils.py
.py
import pytest from strawberry.experimental.pydantic._compat import IS_PYDANTIC_V2 needs_pydantic_v2 = pytest.mark.skipif( not IS_PYDANTIC_V2, reason="requires Pydantic v2" ) needs_pydantic_v1 = pytest.mark.skipif(IS_PYDANTIC_V2, reason="requires Pydantic v1")
9
266
strawberry
tests/experimental/pydantic/test_private_fields_from_pydantic.py
.py
import warnings from typing import Any, Optional import pytest from pydantic import BaseModel import strawberry def test_private_field_from_pydantic_with_extra(): """Test that Private fields can be populated via the extra dict in from_pydantic.""" class UserModel(BaseModel): name: str age: ...
364
12,124
strawberry
tests/experimental/pydantic/test_basic.py
.py
import dataclasses import warnings from enum import Enum from typing import Annotated, Any import pydantic import pytest import strawberry from strawberry.experimental.pydantic.exceptions import MissingFieldsListError from strawberry.schema_directive import Location from strawberry.types.base import ( StrawberryL...
942
26,608
strawberry
tests/experimental/pydantic/test_error_extension.py
.py
from pydantic import BaseModel, Field import strawberry from strawberry.experimental.pydantic import input as pydantic_input from strawberry.extensions import PydanticErrorExtension class UserModel(BaseModel): age: int = Field(gt=18) score: int = Field(gt=50) @pydantic_input(model=UserModel) class UserInpu...
76
1,610
strawberry
tests/experimental/pydantic/test_field_extensions.py
.py
"""Test that field extensions work properly with pydantic types.""" from collections.abc import Callable from typing import Any from pydantic import BaseModel import strawberry from strawberry.experimental.pydantic import type as pyd_type from strawberry.extensions.field_extension import FieldExtension class Track...
309
9,031
strawberry
tests/experimental/pydantic/test_conversion.py
.py
import base64 import dataclasses import re from enum import Enum from typing import Any, NewType, TypeVar import pytest from pydantic import BaseModel, Field, ValidationError import strawberry from strawberry.experimental.pydantic._compat import ( IS_PYDANTIC_V2, CompatModelField, PydanticCompat, ) from s...
1,334
34,655
strawberry
tests/experimental/pydantic/test_fields.py
.py
import re from typing import Literal import pydantic import pytest from pydantic import BaseModel, ValidationError, conlist import strawberry from strawberry.experimental.pydantic._compat import IS_PYDANTIC_V1 from strawberry.types.base import StrawberryObjectDefinition, StrawberryOptional from tests.experimental.pyd...
232
6,262
strawberry
tests/experimental/pydantic/test_error_type.py
.py
import pydantic import pytest import strawberry from strawberry.experimental.pydantic.exceptions import MissingFieldsListError from strawberry.types.base import ( StrawberryList, StrawberryObjectDefinition, StrawberryOptional, ) def test_basic_error_type_fields(): class UserModel(pydantic.BaseModel):...
354
11,316
strawberry
tests/experimental/pydantic/schema/test_basic.py
.py
import textwrap from enum import Enum import pydantic import strawberry from tests.experimental.pydantic.utils import needs_pydantic_v1 def test_basic_type_field_list(): class UserModel(pydantic.BaseModel): age: int password: str | None @strawberry.experimental.pydantic.type(UserModel) ...
559
13,007