strawberry-graphql 0.223.0__tar.gz → 0.224.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/PKG-INFO +1 -1
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/pyproject.toml +1 -1
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/__init__.py +1 -1
- strawberry_graphql-0.224.0/strawberry/experimental/pydantic/_compat.py +286 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/error_type.py +3 -2
- strawberry_graphql-0.224.0/strawberry/experimental/pydantic/fields.py +88 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/object_type.py +16 -8
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/utils.py +5 -9
- strawberry_graphql-0.223.0/strawberry/experimental/pydantic/_compat.py +0 -103
- strawberry_graphql-0.223.0/strawberry/experimental/pydantic/fields.py +0 -199
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/LICENSE +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/README.md +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/__main__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/aiohttp/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/aiohttp/handlers/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/aiohttp/handlers/graphql_transport_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/aiohttp/handlers/graphql_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/aiohttp/test/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/aiohttp/test/client.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/aiohttp/views.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/annotation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/arguments.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/asgi/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/asgi/handlers/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/asgi/handlers/graphql_transport_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/asgi/handlers/graphql_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/asgi/test/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/asgi/test/client.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/auto.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/chalice/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/chalice/views.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/handlers/base.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/handlers/graphql_transport_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/handlers/graphql_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/handlers/http_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/handlers/ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/router.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/channels/testing.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/app.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/codegen.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/export_schema.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/schema_codegen.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/server.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/upgrade/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/upgrade/_fake_progress.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/commands/upgrade/_run_codemod.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/constants.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/debug_server.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/utils/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/cli/utils/load_schema.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/exceptions.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/plugins/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/plugins/print_operation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/plugins/python.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/plugins/typescript.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/query_codegen.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codegen/types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codemods/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/codemods/annotated_unions.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/custom_scalar.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/dataloader.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/directive.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/django/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/django/apps.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/django/context.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/django/test/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/django/test/client.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/django/views.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/enum.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/conflicting_arguments.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/duplicated_type_name.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/exception.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/exception_source.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/invalid_argument_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/invalid_union_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/missing_arguments_annotations.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/missing_field_annotation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/missing_return_annotation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/not_a_strawberry_enum.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/object_is_not_a_class.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/object_is_not_an_enum.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/permission_fail_silently_requires_optional.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/private_strawberry_field.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/scalar_already_registered.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/syntax.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/unresolved_field_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/utils/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/exceptions/utils/source_finder.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/conversion.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/conversion_types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/exceptions.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/ext/LICENSE +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/ext/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/ext/dataclasses/LICENSE +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/ext/dataclasses/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/ext/dataclasses/dataclasses.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/ext/mypy_plugin.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/add_validation_rules.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/base_extension.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/context.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/directives.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/disable_validation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/field_extension.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/mask_errors.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/max_aliases.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/max_tokens.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/parser_cache.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/pyinstrument.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/query_depth_limiter.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/runner.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/tracing/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/tracing/apollo.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/tracing/datadog.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/tracing/opentelemetry.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/tracing/sentry.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/tracing/utils.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/utils.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/extensions/validation_cache.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/fastapi/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/fastapi/context.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/fastapi/handlers/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/fastapi/handlers/graphql_transport_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/fastapi/handlers/graphql_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/fastapi/router.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/argument.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/enum.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/field.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/mutation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/object_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/scalar.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/schema.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/schema_directive.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/schema_directives.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/federation/union.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/field.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/field_extensions/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/field_extensions/input_mutation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/file_uploads/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/file_uploads/scalars.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/file_uploads/utils.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/flask/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/flask/views.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/async_base_view.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/base.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/exceptions.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/ides.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/sync_base_view.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/temporal_response.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/http/typevars.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/lazy_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/litestar/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/litestar/controller.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/litestar/handlers/graphql_transport_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/litestar/handlers/graphql_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/mutation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/object_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/parent.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/permission.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/printer/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/printer/ast_from_value.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/printer/printer.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/private.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/py.typed +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/quart/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/quart/views.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/relay/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/relay/exceptions.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/relay/fields.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/relay/types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/relay/utils.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/resolvers.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/sanic/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/sanic/context.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/sanic/utils.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/sanic/views.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/scalars.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/base.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/compat.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/config.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/exceptions.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/execute.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/name_converter.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/schema.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/schema_converter.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/types/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/types/base_scalars.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/types/concrete_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema/types/scalar.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema_codegen/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/schema_directive.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/starlite/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/starlite/controller.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/starlite/handlers/graphql_transport_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/starlite/handlers/graphql_ws_handler.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/static/apollo-sandbox.html +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/static/graphiql.html +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/static/pathfinder.html +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/protocols/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/protocols/graphql_transport_ws/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/protocols/graphql_transport_ws/types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/protocols/graphql_ws/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/protocols/graphql_ws/handlers.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/subscriptions/protocols/graphql_ws/types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/test/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/test/client.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/tools/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/tools/create_type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/tools/merge_types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/type.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/execution.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/fields/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/fields/resolver.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/graphql.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/info.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/nodes.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/type_resolver.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/types/types.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/union.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/unset.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/__init__.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/aio.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/await_maybe.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/dataclasses.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/debug.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/deprecations.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/graphql_lexer.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/importer.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/inspect.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/logging.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/operation.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/str_converters.py +0 -0
- {strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/utils/typing.py +0 -0
@@ -0,0 +1,286 @@
|
|
1
|
+
import dataclasses
|
2
|
+
from dataclasses import dataclass
|
3
|
+
from decimal import Decimal
|
4
|
+
from functools import cached_property
|
5
|
+
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Type
|
6
|
+
from uuid import UUID
|
7
|
+
|
8
|
+
import pydantic
|
9
|
+
from pydantic import BaseModel
|
10
|
+
from pydantic.version import VERSION as PYDANTIC_VERSION
|
11
|
+
|
12
|
+
from strawberry.experimental.pydantic.exceptions import UnsupportedTypeError
|
13
|
+
|
14
|
+
if TYPE_CHECKING:
|
15
|
+
from pydantic.fields import FieldInfo
|
16
|
+
|
17
|
+
IS_PYDANTIC_V2: bool = PYDANTIC_VERSION.startswith("2.")
|
18
|
+
IS_PYDANTIC_V1: bool = not IS_PYDANTIC_V2
|
19
|
+
|
20
|
+
|
21
|
+
@dataclass
|
22
|
+
class CompatModelField:
|
23
|
+
name: str
|
24
|
+
type_: Any
|
25
|
+
outer_type_: Any
|
26
|
+
default: Any
|
27
|
+
default_factory: Optional[Callable[[], Any]]
|
28
|
+
required: bool
|
29
|
+
alias: Optional[str]
|
30
|
+
allow_none: bool
|
31
|
+
has_alias: bool
|
32
|
+
description: Optional[str]
|
33
|
+
_missing_type: Any
|
34
|
+
is_v1: bool
|
35
|
+
|
36
|
+
@property
|
37
|
+
def has_default_factory(self) -> bool:
|
38
|
+
return self.default_factory is not self._missing_type
|
39
|
+
|
40
|
+
@property
|
41
|
+
def has_default(self) -> bool:
|
42
|
+
return self.default is not self._missing_type
|
43
|
+
|
44
|
+
|
45
|
+
ATTR_TO_TYPE_MAP = {
|
46
|
+
"NoneStr": Optional[str],
|
47
|
+
"NoneBytes": Optional[bytes],
|
48
|
+
"StrBytes": None,
|
49
|
+
"NoneStrBytes": None,
|
50
|
+
"StrictStr": str,
|
51
|
+
"ConstrainedBytes": bytes,
|
52
|
+
"conbytes": bytes,
|
53
|
+
"ConstrainedStr": str,
|
54
|
+
"constr": str,
|
55
|
+
"EmailStr": str,
|
56
|
+
"PyObject": None,
|
57
|
+
"ConstrainedInt": int,
|
58
|
+
"conint": int,
|
59
|
+
"PositiveInt": int,
|
60
|
+
"NegativeInt": int,
|
61
|
+
"ConstrainedFloat": float,
|
62
|
+
"confloat": float,
|
63
|
+
"PositiveFloat": float,
|
64
|
+
"NegativeFloat": float,
|
65
|
+
"ConstrainedDecimal": Decimal,
|
66
|
+
"condecimal": Decimal,
|
67
|
+
"UUID1": UUID,
|
68
|
+
"UUID3": UUID,
|
69
|
+
"UUID4": UUID,
|
70
|
+
"UUID5": UUID,
|
71
|
+
"FilePath": None,
|
72
|
+
"DirectoryPath": None,
|
73
|
+
"Json": None,
|
74
|
+
"JsonWrapper": None,
|
75
|
+
"SecretStr": str,
|
76
|
+
"SecretBytes": bytes,
|
77
|
+
"StrictBool": bool,
|
78
|
+
"StrictInt": int,
|
79
|
+
"StrictFloat": float,
|
80
|
+
"PaymentCardNumber": None,
|
81
|
+
"ByteSize": None,
|
82
|
+
"AnyUrl": str,
|
83
|
+
"AnyHttpUrl": str,
|
84
|
+
"HttpUrl": str,
|
85
|
+
"PostgresDsn": str,
|
86
|
+
"RedisDsn": str,
|
87
|
+
}
|
88
|
+
|
89
|
+
ATTR_TO_TYPE_MAP_Pydantic_V2 = {
|
90
|
+
"EmailStr": str,
|
91
|
+
"SecretStr": str,
|
92
|
+
"SecretBytes": bytes,
|
93
|
+
"AnyUrl": str,
|
94
|
+
}
|
95
|
+
|
96
|
+
ATTR_TO_TYPE_MAP_Pydantic_Core_V2 = {
|
97
|
+
"MultiHostUrl": str,
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
def get_fields_map_for_v2() -> Dict[Any, Any]:
|
102
|
+
import pydantic_core
|
103
|
+
|
104
|
+
fields_map = {
|
105
|
+
getattr(pydantic, field_name): type
|
106
|
+
for field_name, type in ATTR_TO_TYPE_MAP_Pydantic_V2.items()
|
107
|
+
if hasattr(pydantic, field_name)
|
108
|
+
}
|
109
|
+
fields_map.update(
|
110
|
+
{
|
111
|
+
getattr(pydantic_core, field_name): type
|
112
|
+
for field_name, type in ATTR_TO_TYPE_MAP_Pydantic_Core_V2.items()
|
113
|
+
if hasattr(pydantic_core, field_name)
|
114
|
+
}
|
115
|
+
)
|
116
|
+
|
117
|
+
return fields_map
|
118
|
+
|
119
|
+
|
120
|
+
class PydanticV2Compat:
|
121
|
+
@property
|
122
|
+
def PYDANTIC_MISSING_TYPE(self) -> Any:
|
123
|
+
from pydantic_core import PydanticUndefined
|
124
|
+
|
125
|
+
return PydanticUndefined
|
126
|
+
|
127
|
+
def get_model_fields(self, model: Type[BaseModel]) -> Dict[str, CompatModelField]:
|
128
|
+
field_info: dict[str, FieldInfo] = model.model_fields
|
129
|
+
new_fields = {}
|
130
|
+
# Convert it into CompatModelField
|
131
|
+
for name, field in field_info.items():
|
132
|
+
new_fields[name] = CompatModelField(
|
133
|
+
name=name,
|
134
|
+
type_=field.annotation,
|
135
|
+
outer_type_=field.annotation,
|
136
|
+
default=field.default,
|
137
|
+
default_factory=field.default_factory,
|
138
|
+
required=field.is_required(),
|
139
|
+
alias=field.alias,
|
140
|
+
# v2 doesn't have allow_none
|
141
|
+
allow_none=False,
|
142
|
+
has_alias=field is not None,
|
143
|
+
description=field.description,
|
144
|
+
_missing_type=self.PYDANTIC_MISSING_TYPE,
|
145
|
+
is_v1=False,
|
146
|
+
)
|
147
|
+
return new_fields
|
148
|
+
|
149
|
+
@cached_property
|
150
|
+
def fields_map(self) -> Dict[Any, Any]:
|
151
|
+
return get_fields_map_for_v2()
|
152
|
+
|
153
|
+
def get_basic_type(self, type_: Any) -> Type[Any]:
|
154
|
+
if type_ in self.fields_map:
|
155
|
+
type_ = self.fields_map[type_]
|
156
|
+
|
157
|
+
if type_ is None:
|
158
|
+
raise UnsupportedTypeError()
|
159
|
+
|
160
|
+
if is_new_type(type_):
|
161
|
+
return new_type_supertype(type_)
|
162
|
+
|
163
|
+
return type_
|
164
|
+
|
165
|
+
|
166
|
+
class PydanticV1Compat:
|
167
|
+
@property
|
168
|
+
def PYDANTIC_MISSING_TYPE(self) -> Any:
|
169
|
+
return dataclasses.MISSING
|
170
|
+
|
171
|
+
def get_model_fields(self, model: Type[BaseModel]) -> Dict[str, CompatModelField]:
|
172
|
+
new_fields = {}
|
173
|
+
# Convert it into CompatModelField
|
174
|
+
for name, field in model.__fields__.items(): # type: ignore[attr-defined]
|
175
|
+
new_fields[name] = CompatModelField(
|
176
|
+
name=name,
|
177
|
+
type_=field.type_,
|
178
|
+
outer_type_=field.outer_type_,
|
179
|
+
default=field.default,
|
180
|
+
default_factory=field.default_factory,
|
181
|
+
required=field.required,
|
182
|
+
alias=field.alias,
|
183
|
+
allow_none=field.allow_none,
|
184
|
+
has_alias=field.has_alias,
|
185
|
+
description=field.field_info.description,
|
186
|
+
_missing_type=self.PYDANTIC_MISSING_TYPE,
|
187
|
+
is_v1=True,
|
188
|
+
)
|
189
|
+
return new_fields
|
190
|
+
|
191
|
+
@cached_property
|
192
|
+
def fields_map(self) -> Dict[Any, Any]:
|
193
|
+
if IS_PYDANTIC_V2:
|
194
|
+
return {
|
195
|
+
getattr(pydantic.v1, field_name): type
|
196
|
+
for field_name, type in ATTR_TO_TYPE_MAP.items()
|
197
|
+
if hasattr(pydantic.v1, field_name)
|
198
|
+
}
|
199
|
+
|
200
|
+
return {
|
201
|
+
getattr(pydantic, field_name): type
|
202
|
+
for field_name, type in ATTR_TO_TYPE_MAP.items()
|
203
|
+
if hasattr(pydantic, field_name)
|
204
|
+
}
|
205
|
+
|
206
|
+
def get_basic_type(self, type_: Any) -> Type[Any]:
|
207
|
+
if IS_PYDANTIC_V1:
|
208
|
+
ConstrainedInt = pydantic.ConstrainedInt
|
209
|
+
ConstrainedFloat = pydantic.ConstrainedFloat
|
210
|
+
ConstrainedStr = pydantic.ConstrainedStr
|
211
|
+
ConstrainedList = pydantic.ConstrainedList
|
212
|
+
else:
|
213
|
+
ConstrainedInt = pydantic.v1.ConstrainedInt
|
214
|
+
ConstrainedFloat = pydantic.v1.ConstrainedFloat
|
215
|
+
ConstrainedStr = pydantic.v1.ConstrainedStr
|
216
|
+
ConstrainedList = pydantic.v1.ConstrainedList
|
217
|
+
|
218
|
+
if lenient_issubclass(type_, ConstrainedInt):
|
219
|
+
return int
|
220
|
+
if lenient_issubclass(type_, ConstrainedFloat):
|
221
|
+
return float
|
222
|
+
if lenient_issubclass(type_, ConstrainedStr):
|
223
|
+
return str
|
224
|
+
if lenient_issubclass(type_, ConstrainedList):
|
225
|
+
return List[self.get_basic_type(type_.item_type)] # type: ignore
|
226
|
+
|
227
|
+
if type_ in self.fields_map:
|
228
|
+
type_ = self.fields_map[type_]
|
229
|
+
|
230
|
+
if type_ is None:
|
231
|
+
raise UnsupportedTypeError()
|
232
|
+
|
233
|
+
if is_new_type(type_):
|
234
|
+
return new_type_supertype(type_)
|
235
|
+
|
236
|
+
return type_
|
237
|
+
|
238
|
+
|
239
|
+
class PydanticCompat:
|
240
|
+
def __init__(self, is_v2: bool):
|
241
|
+
if is_v2:
|
242
|
+
self._compat = PydanticV2Compat()
|
243
|
+
else:
|
244
|
+
self._compat = PydanticV1Compat() # type: ignore[assignment]
|
245
|
+
|
246
|
+
@classmethod
|
247
|
+
def from_model(cls, model: Type[BaseModel]) -> "PydanticCompat":
|
248
|
+
if hasattr(model, "model_fields"):
|
249
|
+
return cls(is_v2=True)
|
250
|
+
|
251
|
+
return cls(is_v2=False)
|
252
|
+
|
253
|
+
def __getattr__(self, name: str) -> Any:
|
254
|
+
return getattr(self._compat, name)
|
255
|
+
|
256
|
+
|
257
|
+
if IS_PYDANTIC_V2:
|
258
|
+
from typing_extensions import get_args, get_origin
|
259
|
+
|
260
|
+
from pydantic._internal._typing_extra import is_new_type
|
261
|
+
from pydantic._internal._utils import lenient_issubclass, smart_deepcopy
|
262
|
+
|
263
|
+
def new_type_supertype(type_: Any) -> Any:
|
264
|
+
return type_.__supertype__
|
265
|
+
else:
|
266
|
+
from pydantic.typing import ( # type: ignore[no-redef]
|
267
|
+
get_args,
|
268
|
+
get_origin,
|
269
|
+
is_new_type,
|
270
|
+
new_type_supertype,
|
271
|
+
)
|
272
|
+
from pydantic.utils import ( # type: ignore[no-redef]
|
273
|
+
lenient_issubclass,
|
274
|
+
smart_deepcopy,
|
275
|
+
)
|
276
|
+
|
277
|
+
|
278
|
+
__all__ = [
|
279
|
+
"PydanticCompat",
|
280
|
+
"is_new_type",
|
281
|
+
"lenient_issubclass",
|
282
|
+
"get_origin",
|
283
|
+
"get_args",
|
284
|
+
"new_type_supertype",
|
285
|
+
"smart_deepcopy",
|
286
|
+
]
|
@@ -19,7 +19,7 @@ from pydantic import BaseModel
|
|
19
19
|
from strawberry.auto import StrawberryAuto
|
20
20
|
from strawberry.experimental.pydantic._compat import (
|
21
21
|
CompatModelField,
|
22
|
-
|
22
|
+
PydanticCompat,
|
23
23
|
lenient_issubclass,
|
24
24
|
)
|
25
25
|
from strawberry.experimental.pydantic.utils import (
|
@@ -72,7 +72,8 @@ def error_type(
|
|
72
72
|
all_fields: bool = False,
|
73
73
|
) -> Callable[..., Type]:
|
74
74
|
def wrap(cls: Type) -> Type:
|
75
|
-
|
75
|
+
compat = PydanticCompat.from_model(model)
|
76
|
+
model_fields = compat.get_model_fields(model)
|
76
77
|
fields_set = set(fields) if fields else set()
|
77
78
|
|
78
79
|
if fields:
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import builtins
|
2
|
+
from typing import Any, Union
|
3
|
+
from typing_extensions import Annotated
|
4
|
+
|
5
|
+
from pydantic import BaseModel
|
6
|
+
|
7
|
+
from strawberry.experimental.pydantic._compat import (
|
8
|
+
PydanticCompat,
|
9
|
+
get_args,
|
10
|
+
get_origin,
|
11
|
+
lenient_issubclass,
|
12
|
+
)
|
13
|
+
from strawberry.experimental.pydantic.exceptions import (
|
14
|
+
UnregisteredTypeException,
|
15
|
+
)
|
16
|
+
from strawberry.types.types import StrawberryObjectDefinition
|
17
|
+
|
18
|
+
try:
|
19
|
+
from types import UnionType as TypingUnionType
|
20
|
+
except ImportError:
|
21
|
+
import sys
|
22
|
+
|
23
|
+
if sys.version_info < (3, 10):
|
24
|
+
TypingUnionType = ()
|
25
|
+
else:
|
26
|
+
raise
|
27
|
+
|
28
|
+
try:
|
29
|
+
from typing import GenericAlias as TypingGenericAlias # type: ignore
|
30
|
+
except ImportError:
|
31
|
+
import sys
|
32
|
+
|
33
|
+
# python < 3.9 does not have GenericAlias (list[int], tuple[str, ...] and so on)
|
34
|
+
# we do this under a conditional to avoid a mypy :)
|
35
|
+
if sys.version_info < (3, 9):
|
36
|
+
TypingGenericAlias = ()
|
37
|
+
else:
|
38
|
+
raise
|
39
|
+
|
40
|
+
|
41
|
+
def replace_pydantic_types(type_: Any, is_input: bool) -> Any:
|
42
|
+
if lenient_issubclass(type_, BaseModel):
|
43
|
+
attr = "_strawberry_input_type" if is_input else "_strawberry_type"
|
44
|
+
if hasattr(type_, attr):
|
45
|
+
return getattr(type_, attr)
|
46
|
+
else:
|
47
|
+
raise UnregisteredTypeException(type_)
|
48
|
+
return type_
|
49
|
+
|
50
|
+
|
51
|
+
def replace_types_recursively(
|
52
|
+
type_: Any, is_input: bool, compat: PydanticCompat
|
53
|
+
) -> Any:
|
54
|
+
"""Runs the conversions recursively into the arguments of generic types if any"""
|
55
|
+
basic_type = compat.get_basic_type(type_)
|
56
|
+
replaced_type = replace_pydantic_types(basic_type, is_input)
|
57
|
+
|
58
|
+
origin = get_origin(type_)
|
59
|
+
|
60
|
+
if not origin or not hasattr(type_, "__args__"):
|
61
|
+
return replaced_type
|
62
|
+
|
63
|
+
converted = tuple(
|
64
|
+
replace_types_recursively(t, is_input=is_input, compat=compat)
|
65
|
+
for t in get_args(replaced_type)
|
66
|
+
)
|
67
|
+
|
68
|
+
if isinstance(replaced_type, TypingGenericAlias):
|
69
|
+
return TypingGenericAlias(origin, converted)
|
70
|
+
if isinstance(replaced_type, TypingUnionType):
|
71
|
+
return Union[converted]
|
72
|
+
|
73
|
+
# TODO: investigate if we could move the check for annotated to the top
|
74
|
+
if origin is Annotated and converted:
|
75
|
+
converted = (converted[0],)
|
76
|
+
|
77
|
+
replaced_type = replaced_type.copy_with(converted)
|
78
|
+
|
79
|
+
if isinstance(replaced_type, StrawberryObjectDefinition):
|
80
|
+
# TODO: Not sure if this is necessary. No coverage in tests
|
81
|
+
# TODO: Unnecessary with StrawberryObject
|
82
|
+
replaced_type = builtins.type(
|
83
|
+
replaced_type.name,
|
84
|
+
(),
|
85
|
+
{"__strawberry_definition__": replaced_type},
|
86
|
+
)
|
87
|
+
|
88
|
+
return replaced_type
|
@@ -19,9 +19,8 @@ from typing import (
|
|
19
19
|
from strawberry.annotation import StrawberryAnnotation
|
20
20
|
from strawberry.auto import StrawberryAuto
|
21
21
|
from strawberry.experimental.pydantic._compat import (
|
22
|
-
IS_PYDANTIC_V1,
|
23
22
|
CompatModelField,
|
24
|
-
|
23
|
+
PydanticCompat,
|
25
24
|
)
|
26
25
|
from strawberry.experimental.pydantic.conversion import (
|
27
26
|
convert_pydantic_model_to_strawberry_class,
|
@@ -44,10 +43,12 @@ if TYPE_CHECKING:
|
|
44
43
|
from graphql import GraphQLResolveInfo
|
45
44
|
|
46
45
|
|
47
|
-
def get_type_for_field(field: CompatModelField, is_input: bool): # noqa: ANN201
|
46
|
+
def get_type_for_field(field: CompatModelField, is_input: bool, compat: PydanticCompat): # noqa: ANN201
|
48
47
|
outer_type = field.outer_type_
|
49
|
-
|
50
|
-
|
48
|
+
|
49
|
+
replaced_type = replace_types_recursively(outer_type, is_input, compat=compat)
|
50
|
+
|
51
|
+
if field.is_v1:
|
51
52
|
# only pydantic v1 has this Optional logic
|
52
53
|
should_add_optional: bool = field.allow_none
|
53
54
|
if should_add_optional:
|
@@ -62,9 +63,10 @@ def _build_dataclass_creation_fields(
|
|
62
63
|
existing_fields: Dict[str, StrawberryField],
|
63
64
|
auto_fields_set: Set[str],
|
64
65
|
use_pydantic_alias: bool,
|
66
|
+
compat: PydanticCompat,
|
65
67
|
) -> DataclassCreationFields:
|
66
68
|
field_type = (
|
67
|
-
get_type_for_field(field, is_input)
|
69
|
+
get_type_for_field(field, is_input, compat=compat)
|
68
70
|
if field.name in auto_fields_set
|
69
71
|
else existing_fields[field.name].type
|
70
72
|
)
|
@@ -129,7 +131,8 @@ def type(
|
|
129
131
|
use_pydantic_alias: bool = True,
|
130
132
|
) -> Callable[..., Type[StrawberryTypeFromPydantic[PydanticModel]]]:
|
131
133
|
def wrap(cls: Any) -> Type[StrawberryTypeFromPydantic[PydanticModel]]:
|
132
|
-
|
134
|
+
compat = PydanticCompat.from_model(model)
|
135
|
+
model_fields = compat.get_model_fields(model)
|
133
136
|
original_fields_set = set(fields) if fields else set()
|
134
137
|
|
135
138
|
if fields:
|
@@ -182,7 +185,12 @@ def type(
|
|
182
185
|
|
183
186
|
all_model_fields: List[DataclassCreationFields] = [
|
184
187
|
_build_dataclass_creation_fields(
|
185
|
-
field,
|
188
|
+
field,
|
189
|
+
is_input,
|
190
|
+
extra_fields_dict,
|
191
|
+
auto_fields_set,
|
192
|
+
use_pydantic_alias,
|
193
|
+
compat=compat,
|
186
194
|
)
|
187
195
|
for field_name, field in model_fields.items()
|
188
196
|
if field_name in fields_set
|
{strawberry_graphql-0.223.0 → strawberry_graphql-0.224.0}/strawberry/experimental/pydantic/utils.py
RENAMED
@@ -14,9 +14,8 @@ from typing import (
|
|
14
14
|
)
|
15
15
|
|
16
16
|
from strawberry.experimental.pydantic._compat import (
|
17
|
-
PYDANTIC_MISSING_TYPE,
|
18
17
|
CompatModelField,
|
19
|
-
|
18
|
+
PydanticCompat,
|
20
19
|
smart_deepcopy,
|
21
20
|
)
|
22
21
|
from strawberry.experimental.pydantic.exceptions import (
|
@@ -83,12 +82,8 @@ def get_default_factory_for_field(
|
|
83
82
|
Returns optionally a NoArgAnyCallable representing a default_factory parameter
|
84
83
|
"""
|
85
84
|
# replace dataclasses.MISSING with our own UNSET to make comparisons easier
|
86
|
-
default_factory =
|
87
|
-
|
88
|
-
if field.default_factory is not PYDANTIC_MISSING_TYPE
|
89
|
-
else UNSET
|
90
|
-
)
|
91
|
-
default = field.default if field.default is not PYDANTIC_MISSING_TYPE else UNSET
|
85
|
+
default_factory = field.default_factory if field.has_default_factory else UNSET
|
86
|
+
default = field.default if field.has_default else UNSET
|
92
87
|
|
93
88
|
has_factory = default_factory is not None and default_factory is not UNSET
|
94
89
|
has_default = default is not None and default is not UNSET
|
@@ -126,8 +121,9 @@ def get_default_factory_for_field(
|
|
126
121
|
def ensure_all_auto_fields_in_pydantic(
|
127
122
|
model: Type[BaseModel], auto_fields: Set[str], cls_name: str
|
128
123
|
) -> None:
|
124
|
+
compat = PydanticCompat.from_model(model)
|
129
125
|
# Raise error if user defined a strawberry.auto field not present in the model
|
130
|
-
non_existing_fields = list(auto_fields - get_model_fields(model).keys())
|
126
|
+
non_existing_fields = list(auto_fields - compat.get_model_fields(model).keys())
|
131
127
|
|
132
128
|
if non_existing_fields:
|
133
129
|
raise AutoFieldsNotInBaseModelError(
|
@@ -1,103 +0,0 @@
|
|
1
|
-
import dataclasses
|
2
|
-
from dataclasses import dataclass
|
3
|
-
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Type
|
4
|
-
|
5
|
-
from pydantic import BaseModel
|
6
|
-
from pydantic.version import VERSION as PYDANTIC_VERSION
|
7
|
-
|
8
|
-
if TYPE_CHECKING:
|
9
|
-
from pydantic.fields import FieldInfo
|
10
|
-
|
11
|
-
IS_PYDANTIC_V2: bool = PYDANTIC_VERSION.startswith("2.")
|
12
|
-
IS_PYDANTIC_V1: bool = not IS_PYDANTIC_V2
|
13
|
-
|
14
|
-
|
15
|
-
@dataclass
|
16
|
-
class CompatModelField:
|
17
|
-
name: str
|
18
|
-
type_: Any
|
19
|
-
outer_type_: Any
|
20
|
-
default: Any
|
21
|
-
default_factory: Optional[Callable[[], Any]]
|
22
|
-
required: bool
|
23
|
-
alias: Optional[str]
|
24
|
-
allow_none: bool
|
25
|
-
has_alias: bool
|
26
|
-
description: Optional[str]
|
27
|
-
|
28
|
-
|
29
|
-
if IS_PYDANTIC_V2:
|
30
|
-
from typing_extensions import get_args, get_origin
|
31
|
-
|
32
|
-
from pydantic._internal._typing_extra import is_new_type
|
33
|
-
from pydantic._internal._utils import lenient_issubclass, smart_deepcopy
|
34
|
-
from pydantic_core import PydanticUndefined
|
35
|
-
|
36
|
-
PYDANTIC_MISSING_TYPE = PydanticUndefined
|
37
|
-
|
38
|
-
def new_type_supertype(type_: Any) -> Any:
|
39
|
-
return type_.__supertype__
|
40
|
-
|
41
|
-
def get_model_fields(model: Type[BaseModel]) -> Dict[str, CompatModelField]:
|
42
|
-
field_info: dict[str, FieldInfo] = model.model_fields
|
43
|
-
new_fields = {}
|
44
|
-
# Convert it into CompatModelField
|
45
|
-
for name, field in field_info.items():
|
46
|
-
new_fields[name] = CompatModelField(
|
47
|
-
name=name,
|
48
|
-
type_=field.annotation,
|
49
|
-
outer_type_=field.annotation,
|
50
|
-
default=field.default,
|
51
|
-
default_factory=field.default_factory,
|
52
|
-
required=field.is_required(),
|
53
|
-
alias=field.alias,
|
54
|
-
# v2 doesn't have allow_none
|
55
|
-
allow_none=False,
|
56
|
-
has_alias=field is not None,
|
57
|
-
description=field.description,
|
58
|
-
)
|
59
|
-
return new_fields
|
60
|
-
|
61
|
-
else:
|
62
|
-
from pydantic.typing import ( # type: ignore[no-redef]
|
63
|
-
get_args,
|
64
|
-
get_origin,
|
65
|
-
is_new_type,
|
66
|
-
new_type_supertype,
|
67
|
-
)
|
68
|
-
from pydantic.utils import ( # type: ignore[no-redef]
|
69
|
-
lenient_issubclass,
|
70
|
-
smart_deepcopy,
|
71
|
-
)
|
72
|
-
|
73
|
-
PYDANTIC_MISSING_TYPE = dataclasses.MISSING # type: ignore[assignment]
|
74
|
-
|
75
|
-
def get_model_fields(model: Type[BaseModel]) -> Dict[str, CompatModelField]:
|
76
|
-
new_fields = {}
|
77
|
-
# Convert it into CompatModelField
|
78
|
-
for name, field in model.__fields__.items(): # type: ignore[attr-defined]
|
79
|
-
new_fields[name] = CompatModelField(
|
80
|
-
name=name,
|
81
|
-
type_=field.type_,
|
82
|
-
outer_type_=field.outer_type_,
|
83
|
-
default=field.default,
|
84
|
-
default_factory=field.default_factory,
|
85
|
-
required=field.required,
|
86
|
-
alias=field.alias,
|
87
|
-
allow_none=field.allow_none,
|
88
|
-
has_alias=field.has_alias,
|
89
|
-
description=field.field_info.description,
|
90
|
-
)
|
91
|
-
return new_fields
|
92
|
-
|
93
|
-
|
94
|
-
__all__ = [
|
95
|
-
"smart_deepcopy",
|
96
|
-
"lenient_issubclass",
|
97
|
-
"get_args",
|
98
|
-
"get_origin",
|
99
|
-
"is_new_type",
|
100
|
-
"new_type_supertype",
|
101
|
-
"get_model_fields",
|
102
|
-
"PYDANTIC_MISSING_TYPE",
|
103
|
-
]
|