strawberry-graphql 0.282.0__py3-none-any.whl → 0.283.0__py3-none-any.whl

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.

Potentially problematic release.


This version of strawberry-graphql might be problematic. Click here for more details.

@@ -1,6 +1,7 @@
1
1
  try:
2
2
  from .app import app
3
3
  from .commands.codegen import codegen as codegen
4
+ from .commands.dev import dev as dev
4
5
  from .commands.export_schema import export_schema as export_schema
5
6
  from .commands.locate_definition import (
6
7
  locate_definition as locate_definition,
@@ -0,0 +1,72 @@
1
+ import os
2
+ import sys
3
+ from enum import Enum
4
+ from typing import Annotated
5
+
6
+ import rich
7
+ import typer
8
+
9
+ from strawberry.cli.app import app
10
+ from strawberry.cli.constants import DEV_SERVER_SCHEMA_ENV_VAR_KEY
11
+ from strawberry.cli.utils import load_schema
12
+
13
+
14
+ class LogLevel(str, Enum):
15
+ critical = "critical"
16
+ error = "error"
17
+ warning = "warning"
18
+ info = "info"
19
+ debug = "debug"
20
+ trace = "trace"
21
+
22
+
23
+ @app.command(help="Starts the dev server")
24
+ def dev(
25
+ schema: str,
26
+ host: Annotated[
27
+ str, typer.Option("-h", "--host", help="Host to bind the server to.")
28
+ ] = "0.0.0.0", # noqa: S104
29
+ port: Annotated[
30
+ int, typer.Option("-p", "--port", help="Port to bind the server to.")
31
+ ] = 8000,
32
+ log_level: Annotated[
33
+ LogLevel,
34
+ typer.Option(
35
+ "--log-level", help="Passed to uvicorn to determine the server log level."
36
+ ),
37
+ ] = LogLevel.error,
38
+ app_dir: Annotated[
39
+ str,
40
+ typer.Option(
41
+ "--app-dir",
42
+ help="Look for the schema module in the specified directory, by adding this to the PYTHONPATH. Defaults to the current working directory.",
43
+ ),
44
+ ] = ".",
45
+ ) -> None:
46
+ try:
47
+ import starlette # noqa: F401
48
+ import uvicorn
49
+ except ImportError:
50
+ rich.print(
51
+ "[red]Error: The dev server requires additional packages, install them by running:\n"
52
+ r"pip install 'strawberry-graphql\[cli]'"
53
+ )
54
+ raise typer.Exit(1) from None
55
+
56
+ sys.path.insert(0, app_dir)
57
+ load_schema(schema, app_dir=app_dir)
58
+
59
+ os.environ[DEV_SERVER_SCHEMA_ENV_VAR_KEY] = schema
60
+ asgi_app = "strawberry.cli.dev_server:app"
61
+
62
+ end = " 🍓\n" if sys.platform != "win32" else "\n"
63
+ rich.print(f"Running strawberry on http://{host}:{port}/graphql", end=end)
64
+
65
+ uvicorn.run(
66
+ asgi_app,
67
+ host=host,
68
+ port=port,
69
+ log_level=log_level,
70
+ reload=True,
71
+ reload_dirs=[app_dir],
72
+ )
@@ -1,13 +1,8 @@
1
- import os
2
- import sys
3
1
  from enum import Enum
4
2
 
5
- import rich
6
3
  import typer
7
4
 
8
5
  from strawberry.cli.app import app
9
- from strawberry.cli.constants import DEBUG_SERVER_SCHEMA_ENV_VAR_KEY
10
- from strawberry.cli.utils import load_schema
11
6
 
12
7
 
13
8
  class LogLevel(str, Enum):
@@ -40,33 +35,7 @@ def server(
40
35
  ),
41
36
  ),
42
37
  ) -> None:
43
- sys.path.insert(0, app_dir)
44
-
45
- try:
46
- import starlette # noqa: F401
47
- import uvicorn
48
- except ImportError:
49
- rich.print(
50
- "[red]Error: The debug server requires additional packages, "
51
- "install them by running:\n"
52
- r"pip install 'strawberry-graphql\[debug-server]'"
53
- )
54
- raise typer.Exit(1) # noqa: B904
55
-
56
- load_schema(schema, app_dir=app_dir)
57
-
58
- os.environ[DEBUG_SERVER_SCHEMA_ENV_VAR_KEY] = schema
59
- app = "strawberry.cli.debug_server:app"
60
-
61
- # Windows doesn't support UTF-8 by default
62
- endl = " 🍓\n" if sys.platform != "win32" else "\n"
63
- print(f"Running strawberry on http://{host}:{port}/graphql", end=endl) # noqa: T201
64
-
65
- uvicorn.run(
66
- app,
67
- host=host,
68
- port=port,
69
- log_level=log_level,
70
- reload=True,
71
- reload_dirs=[app_dir],
38
+ typer.echo(
39
+ "The `strawberry server` command is deprecated, use `strawberry dev` instead."
72
40
  )
41
+ raise typer.Exit(1)
@@ -1 +1 @@
1
- DEBUG_SERVER_SCHEMA_ENV_VAR_KEY = "STRAWBERRY_DEBUG_SERVER_SCHEMA"
1
+ DEV_SERVER_SCHEMA_ENV_VAR_KEY = "STRAWBERRY_DEV_SERVER_SCHEMA"
@@ -6,7 +6,7 @@ from starlette.middleware.cors import CORSMiddleware
6
6
 
7
7
  from strawberry import Schema
8
8
  from strawberry.asgi import GraphQL
9
- from strawberry.cli.constants import DEBUG_SERVER_SCHEMA_ENV_VAR_KEY
9
+ from strawberry.cli.constants import DEV_SERVER_SCHEMA_ENV_VAR_KEY
10
10
  from strawberry.utils.importer import import_module_symbol
11
11
 
12
12
  app = Starlette(debug=True)
@@ -14,7 +14,7 @@ app.add_middleware(
14
14
  CORSMiddleware, allow_headers=["*"], allow_origins=["*"], allow_methods=["*"]
15
15
  )
16
16
 
17
- schema_import_string = os.environ[DEBUG_SERVER_SCHEMA_ENV_VAR_KEY]
17
+ schema_import_string = os.environ[DEV_SERVER_SCHEMA_ENV_VAR_KEY]
18
18
  schema_symbol = import_module_symbol(schema_import_string, default_symbol_name="schema")
19
19
 
20
20
  assert isinstance(schema_symbol, Schema)
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: strawberry-graphql
3
- Version: 0.282.0
3
+ Version: 0.283.0
4
4
  Summary: A library for creating GraphQL APIs
5
5
  License: MIT
6
+ License-File: LICENSE
6
7
  Keywords: graphql,api,rest,starlette,async
7
8
  Author: Patrick Arminio
8
9
  Author-email: patrick.arminio@gmail.com
@@ -51,6 +52,7 @@ Requires-Dist: pygments (>=2.3,<3.0) ; extra == "debug-server"
51
52
  Requires-Dist: pyinstrument (>=4.0.0) ; extra == "pyinstrument"
52
53
  Requires-Dist: python-dateutil (>=2.7,<3.0)
53
54
  Requires-Dist: python-multipart (>=0.0.7) ; extra == "asgi"
55
+ Requires-Dist: python-multipart (>=0.0.7) ; extra == "cli"
54
56
  Requires-Dist: python-multipart (>=0.0.7) ; extra == "debug-server"
55
57
  Requires-Dist: python-multipart (>=0.0.7) ; extra == "fastapi"
56
58
  Requires-Dist: quart (>=0.19.3) ; extra == "quart"
@@ -59,11 +61,14 @@ Requires-Dist: rich (>=12.0.0) ; extra == "debug"
59
61
  Requires-Dist: rich (>=12.0.0) ; extra == "debug-server"
60
62
  Requires-Dist: sanic (>=20.12.2) ; extra == "sanic"
61
63
  Requires-Dist: starlette (>=0.18.0) ; extra == "asgi"
64
+ Requires-Dist: starlette (>=0.18.0) ; extra == "cli"
62
65
  Requires-Dist: starlette (>=0.18.0) ; extra == "debug-server"
63
66
  Requires-Dist: typer (>=0.7.0) ; extra == "cli"
64
67
  Requires-Dist: typer (>=0.7.0) ; extra == "debug-server"
65
68
  Requires-Dist: typing-extensions (>=4.5.0)
69
+ Requires-Dist: uvicorn (>=0.11.6) ; extra == "cli"
66
70
  Requires-Dist: uvicorn (>=0.11.6) ; extra == "debug-server"
71
+ Requires-Dist: websockets (>=15.0.1,<16) ; extra == "cli"
67
72
  Requires-Dist: websockets (>=15.0.1,<16) ; extra == "debug-server"
68
73
  Project-URL: Changelog, https://strawberry.rocks/changelog
69
74
  Project-URL: Documentation, https://strawberry.rocks/
@@ -92,7 +97,7 @@ The quick start method provides a server and CLI to get going quickly. Install
92
97
  with:
93
98
 
94
99
  ```shell
95
- pip install "strawberry-graphql[debug-server]"
100
+ pip install "strawberry-graphql[cli]"
96
101
  ```
97
102
 
98
103
  ## Getting Started
@@ -122,13 +127,13 @@ schema = strawberry.Schema(query=Query)
122
127
  This will create a GraphQL schema defining a `User` type and a single query
123
128
  field `user` that will return a hardcoded user.
124
129
 
125
- To run the debug server run the following command:
130
+ To serve the schema using the dev server run the following command:
126
131
 
127
132
  ```shell
128
- strawberry server app
133
+ strawberry dev app
129
134
  ```
130
135
 
131
- Open the debug server by clicking on the following link:
136
+ Open the dev server by clicking on the following link:
132
137
  [http://0.0.0.0:8000/graphql](http://0.0.0.0:8000/graphql)
133
138
 
134
139
  This will open GraphiQL where you can test the API.
@@ -185,7 +190,7 @@ get started follow these steps:
185
190
  ```shell
186
191
  git clone https://github.com/strawberry-graphql/strawberry
187
192
  cd strawberry
188
- poetry install --with integrations
193
+ poetry install
189
194
  poetry run pytest
190
195
  ```
191
196
 
@@ -17,19 +17,20 @@ strawberry/channels/handlers/http_handler.py,sha256=EmRVgn0AHG9-dNUOU_rgKf0Ppsh8
17
17
  strawberry/channels/handlers/ws_handler.py,sha256=846Nj9bdcRJ1jezIa-Dmn3S_cgi8W-JTLt6mITG8ff4,6172
18
18
  strawberry/channels/router.py,sha256=DKIbl4zuRBhfvViUVpyu0Rf_WRT41E6uZC-Yic9Ltvo,2024
19
19
  strawberry/channels/testing.py,sha256=dc9mvSm9YdNOUgQk5ou5K4iE2h6TP5quKnk4Xdtn-IY,6558
20
- strawberry/cli/__init__.py,sha256=9rqBIeRSi0P0JljMWO43KC3inm4BBf0CX5pEWQWnTos,662
20
+ strawberry/cli/__init__.py,sha256=szPgUPbmZKgoYVY1EsqnUFWi8onJVje3EUx3ACbnfA4,703
21
21
  strawberry/cli/app.py,sha256=tTMBV1pdWqMcwjWO2yn-8oLDhMhfJvUzyQtWs75LWJ0,54
22
22
  strawberry/cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  strawberry/cli/commands/codegen.py,sha256=WbX8uqF-dpQk1QjQm3H4AvNSZ4lIUOTSPghii3attj8,3812
24
+ strawberry/cli/commands/dev.py,sha256=WSyOtaApia746B-X3AyiaPQd4jQ506mNrTGUN0Iq7RI,1968
24
25
  strawberry/cli/commands/export_schema.py,sha256=pyp_Q3BiO7lFH0L3mNPvr7UF8hlhcoUPqqBP4JPWUu0,1049
25
26
  strawberry/cli/commands/locate_definition.py,sha256=aJJ_KeAnV-c8zTdWIhzcHUilUmCpqsmrVy24qHbyWKk,1001
26
27
  strawberry/cli/commands/schema_codegen.py,sha256=G6eV08a51sjVxCm3jn75oPn9hC8YarKiAKOY5bpTuKU,749
27
- strawberry/cli/commands/server.py,sha256=Q55Eog7oseB127Qvy81MJPQb2DcVkACFg4NGJq2Hl24,1953
28
+ strawberry/cli/commands/server.py,sha256=nbIz-0l_EqQkvpSlg5h9eGFtfW3eSjxUt9bLgRelylo,1066
28
29
  strawberry/cli/commands/upgrade/__init__.py,sha256=yj7OxtXhvYdV-P072VFrLnbQmtREnYMLn7iku8gap6k,2596
29
30
  strawberry/cli/commands/upgrade/_fake_progress.py,sha256=fefLgJwTXe4kG9RntdEJdzkPPRBK_pZqnmMH-pxD85Y,484
30
31
  strawberry/cli/commands/upgrade/_run_codemod.py,sha256=LZd5D1PP65bwVZjBvPPVrZ9t-bfvrafZ__HPBrW2WYA,2168
31
- strawberry/cli/constants.py,sha256=oELrG15571w3fG66EGBwtMHmMFbknJigkL385yzQnyI,67
32
- strawberry/cli/debug_server.py,sha256=KANdDHyOybr2SZMs2OAuOf4Haz_SNSHKiiBeemx8fGc,868
32
+ strawberry/cli/constants.py,sha256=MZ8JTo6YyS8t_mRtJJuNCQPiaKzyqjDbncizDb2pG-c,63
33
+ strawberry/cli/dev_server.py,sha256=u6PAAl6Un0SHdsHDWDnQ85VPCY9g5HTNi2VKOFgJl_A,864
33
34
  strawberry/cli/utils/__init__.py,sha256=5h6QMXbY4zbWVGg8xpsKlgWSEsNgn1fcjbRrJjgzdEc,987
34
35
  strawberry/cli/utils/load_schema.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
36
  strawberry/codegen/__init__.py,sha256=qVfUJXv_2HqZTzi02An2V9auAseT9efi1f5APDG5DjA,250
@@ -229,7 +230,6 @@ strawberry/utils/aio.py,sha256=Nry5jxFHvipGS1CwX5VvFS2YQ6_bp-_cewnI6v9A7-A,2226
229
230
  strawberry/utils/await_maybe.py,sha256=YdjfuzjDVjph0VH0WkwvU4ezsjl_fELnGrLC1_bvb_U,449
230
231
  strawberry/utils/dataclasses.py,sha256=1wvVq0vgvjrRSamJ3CBJpkLu1KVweTmw5JLXmagdGes,856
231
232
  strawberry/utils/deprecations.py,sha256=Yrp4xBzp36mQprH8qPHpPMhkCLm527q7XU7pP4aar_0,782
232
- strawberry/utils/graphql_lexer.py,sha256=JUVJrJ6Ax0t7m6-DTWFzf4cvXrC02VPmL1NS2zMEMbY,1255
233
233
  strawberry/utils/importer.py,sha256=NtTgNaNSW4TnlLo_S34nxXq14RxUAec-QlEZ0LON28M,629
234
234
  strawberry/utils/inspect.py,sha256=-aFT65PkQ9KXo5w8Q2uveBJ8jEpi40sTqRipRQVdYR8,3406
235
235
  strawberry/utils/locate_definition.py,sha256=raABxyWE9MkhO5_w5tO8_xKHSZumRJCJt1QY1OgHO-M,1429
@@ -237,8 +237,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
237
237
  strawberry/utils/operation.py,sha256=ZgVOw3K2jQuLjNOYUHauF7itJD0QDNoPw9PBi0IYf6k,1234
238
238
  strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
239
239
  strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
240
- strawberry_graphql-0.282.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
241
- strawberry_graphql-0.282.0.dist-info/METADATA,sha256=V997csv_7Je1S5Bk7JlMN2pVd9eTNENIoCQogatt2MQ,7426
242
- strawberry_graphql-0.282.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
243
- strawberry_graphql-0.282.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
244
- strawberry_graphql-0.282.0.dist-info/RECORD,,
240
+ strawberry_graphql-0.283.0.dist-info/METADATA,sha256=8JyB52vLWMOLDrJaDMa1YT-2qGi7ek_-TCGIn7TbUVA,7652
241
+ strawberry_graphql-0.283.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
242
+ strawberry_graphql-0.283.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
243
+ strawberry_graphql-0.283.0.dist-info/licenses/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
244
+ strawberry_graphql-0.283.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,35 +0,0 @@
1
- from typing import Any, ClassVar
2
-
3
- from pygments import token
4
- from pygments.lexer import RegexLexer
5
-
6
-
7
- class GraphQLLexer(RegexLexer):
8
- """GraphQL Lexer for Pygments, used by the debug server."""
9
-
10
- name = "GraphQL"
11
- aliases: ClassVar[list[str]] = ["graphql", "gql"]
12
- filenames: ClassVar[list[str]] = ["*.graphql", "*.gql"]
13
- mimetypes: ClassVar[list[str]] = ["application/graphql"]
14
-
15
- tokens: ClassVar[dict[str, list[tuple[str, Any]]]] = {
16
- "root": [
17
- (r"#.*", token.Comment.Singline),
18
- (r"\.\.\.", token.Operator),
19
- (r'"[\u0009\u000A\u000D\u0020-\uFFFF]*"', token.String.Double),
20
- (
21
- r"(-?0|-?[1-9][0-9]*)(\.[0-9]+[eE][+-]?[0-9]+|\.[0-9]+|[eE][+-]?[0-9]+)",
22
- token.Number.Float,
23
- ),
24
- (r"(-?0|-?[1-9][0-9]*)", token.Number.Integer),
25
- (r"\$+[_A-Za-z][_0-9A-Za-z]*", token.Name.Variable),
26
- (r"[_A-Za-z][_0-9A-Za-z]+\s?:", token.Text),
27
- (r"(type|query|mutation|@[a-z]+|on|true|false|null)\b", token.Keyword.Type),
28
- (r"[!$():=@\[\]{|}]+?", token.Punctuation),
29
- (r"[_A-Za-z][_0-9A-Za-z]*", token.Keyword),
30
- (r"(\s|,)", token.Text),
31
- ]
32
- }
33
-
34
-
35
- __all__ = ["GraphQLLexer"]