strawberry-graphql 0.281.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.
- strawberry/cli/__init__.py +1 -0
- strawberry/cli/commands/dev.py +72 -0
- strawberry/cli/commands/server.py +3 -34
- strawberry/cli/constants.py +1 -1
- strawberry/cli/{debug_server.py → dev_server.py} +2 -2
- strawberry/extensions/mask_errors.py +5 -7
- {strawberry_graphql-0.281.0.dist-info → strawberry_graphql-0.283.0.dist-info}/METADATA +12 -7
- {strawberry_graphql-0.281.0.dist-info → strawberry_graphql-0.283.0.dist-info}/RECORD +11 -11
- {strawberry_graphql-0.281.0.dist-info → strawberry_graphql-0.283.0.dist-info}/WHEEL +1 -1
- strawberry/utils/graphql_lexer.py +0 -35
- {strawberry_graphql-0.281.0.dist-info → strawberry_graphql-0.283.0.dist-info}/entry_points.txt +0 -0
- {strawberry_graphql-0.281.0.dist-info → strawberry_graphql-0.283.0.dist-info/licenses}/LICENSE +0 -0
strawberry/cli/__init__.py
CHANGED
|
@@ -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
|
-
|
|
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)
|
strawberry/cli/constants.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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
|
|
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[
|
|
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,10 +1,11 @@
|
|
|
1
|
-
from collections.abc import Iterator
|
|
2
|
-
from typing import Any
|
|
1
|
+
from collections.abc import Callable, Iterator
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
from graphql.error import GraphQLError
|
|
5
|
-
from graphql.execution import ExecutionResult
|
|
5
|
+
from graphql.execution.execute import ExecutionResult as GraphQLExecutionResult
|
|
6
6
|
|
|
7
7
|
from strawberry.extensions.base_extension import SchemaExtension
|
|
8
|
+
from strawberry.types.execution import ExecutionResult as StrawberryExecutionResult
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
def default_should_mask_error(_: GraphQLError) -> bool:
|
|
@@ -54,10 +55,7 @@ class MaskErrors(SchemaExtension):
|
|
|
54
55
|
|
|
55
56
|
result = self.execution_context.result
|
|
56
57
|
|
|
57
|
-
if isinstance(result,
|
|
58
|
+
if isinstance(result, (GraphQLExecutionResult, StrawberryExecutionResult)):
|
|
58
59
|
self._process_result(result)
|
|
59
60
|
elif result:
|
|
60
61
|
self._process_result(result.initial_result)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
__all__ = ["MaskErrors"]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: strawberry-graphql
|
|
3
|
-
Version: 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[
|
|
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
|
|
130
|
+
To serve the schema using the dev server run the following command:
|
|
126
131
|
|
|
127
132
|
```shell
|
|
128
|
-
strawberry
|
|
133
|
+
strawberry dev app
|
|
129
134
|
```
|
|
130
135
|
|
|
131
|
-
Open the
|
|
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
|
|
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=
|
|
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=
|
|
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=
|
|
32
|
-
strawberry/cli/
|
|
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
|
|
@@ -99,7 +100,7 @@ strawberry/extensions/directives.py,sha256=MYAA6lhlmWZM5q8In6Os53LWAUVuVa7AuLtTX
|
|
|
99
100
|
strawberry/extensions/disable_introspection.py,sha256=7FmktNvc9CzOJG9xf_nYG3LThs0cv-g2P-Kzlerna7w,717
|
|
100
101
|
strawberry/extensions/disable_validation.py,sha256=WaA7x6Q-K4IMnvx35OQ1UtokIKaxkWvO_OJO9fFM_vA,750
|
|
101
102
|
strawberry/extensions/field_extension.py,sha256=VUwUBbf57Vp_Ukc3Rh9eZDRuF2ubzRRipzsU-w5bAFc,5561
|
|
102
|
-
strawberry/extensions/mask_errors.py,sha256=
|
|
103
|
+
strawberry/extensions/mask_errors.py,sha256=_tCJUxnGRSf5uM2irg8OBVxzKfenT3C1_TD4sOj-5SQ,1892
|
|
103
104
|
strawberry/extensions/max_aliases.py,sha256=qaV9rqHTqfhh7YdFnXVvjf14wmAiXBtKHGAxb1Yv4DQ,2547
|
|
104
105
|
strawberry/extensions/max_tokens.py,sha256=53Gb0tSj-G7so_vLokdmtUal4KCXQBYLJi1LSIvdkXE,1045
|
|
105
106
|
strawberry/extensions/parser_cache.py,sha256=oi6Svpy21_YP-d9G3nv_5HzJPw5FyBhWplCYnzcKwO8,1291
|
|
@@ -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.
|
|
241
|
-
strawberry_graphql-0.
|
|
242
|
-
strawberry_graphql-0.
|
|
243
|
-
strawberry_graphql-0.
|
|
244
|
-
strawberry_graphql-0.
|
|
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,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"]
|
{strawberry_graphql-0.281.0.dist-info → strawberry_graphql-0.283.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{strawberry_graphql-0.281.0.dist-info → strawberry_graphql-0.283.0.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|