Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions docs/code_examples/aiohttp_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ async def main():
client = Client(transport=transport)

# Provide a GraphQL query
query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")

# Using `async with` on the client will start a connection on the transport
# and provide a `session` variable to execute queries on this connection
Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/aiohttp_multipart_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ async def main():
) as session:

# Request subscription
subscription = gql(
"""
subscription = gql("""
subscription {
book {
title
author
}
}
"""
)
""")

# Subscribe and receive streaming updates
async for result in session.subscribe(subscription):
Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/aiohttp_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
client = Client(transport=transport)

# Provide a GraphQL query
query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")

# Execute the query on the transport
result = client.execute(query)
Expand Down
12 changes: 4 additions & 8 deletions docs/code_examples/aiohttp_websockets_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,25 @@ async def main():
) as session:

# Execute single query
query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")
result = await session.execute(query)
print(result)

# Request subscription
subscription = gql(
"""
subscription = gql("""
subscription {
somethingChanged {
id
}
}
"""
)
""")
async for result in session.subscribe(subscription):
print(result)

Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/appsync/mutation_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ async def main():
fetch_schema_from_transport=False,
) as session:

query = gql(
"""
query = gql("""
mutation createMessage($message: String!) {
createMessage(input: {message: $message}) {
id
message
createdAt
}
}"""
)
}""")

query.variable_values = {"message": "Hello world!"}

Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/appsync/mutation_iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@ async def main():
fetch_schema_from_transport=False,
) as session:

query = gql(
"""
query = gql("""
mutation createMessage($message: String!) {
createMessage(input: {message: $message}) {
id
message
createdAt
}
}"""
)
}""")

query.variable_values = {"message": "Hello world!"}

Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/appsync/subscription_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ async def main():

async with Client(transport=transport) as session:

subscription = gql(
"""
subscription = gql("""
subscription onCreateMessage {
onCreateMessage {
message
}
}
"""
)
""")

print("Waiting for messages...")

Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/appsync/subscription_iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ async def main():

async with Client(transport=transport) as session:

subscription = gql(
"""
subscription = gql("""
subscription onCreateMessage {
onCreateMessage {
message
}
}
"""
)
""")

print("Waiting for messages...")

Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/fastapi_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

client = Client(transport=transport)

query = gql(
"""
query = gql("""
query getContinentInfo($code: ID!) {
continent(code:$code) {
name
Expand All @@ -34,8 +33,7 @@
}
}
}
"""
)
""")

app = FastAPI()

Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/httpx_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ async def main():
) as session:

# Execute single query
query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")

result = await session.execute(query)
print(result)
Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/httpx_async_trio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ async def main():
) as session:

# Execute single query
query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")

result = await session.execute(query)
print(result)
Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/httpx_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@

client = Client(transport=transport, fetch_schema_from_transport=True)

query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")

result = client.execute(query)
print(result)
6 changes: 2 additions & 4 deletions docs/code_examples/phoenix_channel_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ async def main():
async with Client(transport=transport) as session:

# Execute single query
query = gql(
"""
query = gql("""
query yourQuery {
...
}
"""
)
""")

result = await session.execute(query)
print(result)
Expand Down
6 changes: 2 additions & 4 deletions docs/code_examples/requests_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@

client = Client(transport=transport, fetch_schema_from_transport=True)

query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")

result = client.execute(query)
print(result)
12 changes: 4 additions & 8 deletions docs/code_examples/websockets_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,25 @@ async def main():
) as session:

# Execute single query
query = gql(
"""
query = gql("""
query getContinents {
continents {
code
name
}
}
"""
)
""")
result = await session.execute(query)
print(result)

# Request subscription
subscription = gql(
"""
subscription = gql("""
subscription {
somethingChanged {
id
}
}
"""
)
""")
async for result in session.subscribe(subscription):
print(result)

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "gql"
readme = "README.md"
requires-python = ">=3.8.1"
requires-python = ">=3.10"
dynamic = ["authors", "classifiers", "dependencies", "description", "entry-points", "keywords", "license", "optional-dependencies", "scripts", "version"]

[build-system]
Expand All @@ -20,3 +20,6 @@ asyncio_default_fixture_loop_scope = "function"
ignore_missing_imports = true
check_untyped_defs = true
disallow_incomplete_defs = true

[tool.black]
target-version = ["py310"]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]

dev_requires = [
"black==25.1.0",
"black==26.5.1",
"check-manifest>=0.42,<1",
"flake8==7.1.2",
"isort==6.0.1",
Expand Down
6 changes: 2 additions & 4 deletions tests/custom_scalars/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,9 @@ def test_shift_days_serialized_manually_in_query():

client = Client(schema=schema)

query = gql(
"""{
query = gql("""{
shiftDays(time: "2021-11-12T11:58:13.461161", days: 5)
}"""
)
}""")

result = client.execute(query, parse_result=True)

Expand Down
18 changes: 6 additions & 12 deletions tests/custom_scalars/test_enum_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,10 @@ def test_opposite_color_variable_serialized_manually():

client = Client(schema=schema, parse_results=True)

query = gql(
"""
query = gql("""
query GetOppositeColor($color: Color) {
opposite(color:$color)
}"""
)
}""")

query.variable_values = {
"color": "RED",
Expand All @@ -183,12 +181,10 @@ def test_opposite_color_variable_serialized_by_gql():

client = Client(schema=schema, parse_results=True)

query = gql(
"""
query = gql("""
query GetOppositeColor($color: Color) {
opposite(color:$color)
}"""
)
}""")

query.variable_values = {
"color": RED,
Expand Down Expand Up @@ -306,8 +302,7 @@ def test_parse_results_with_operation_type():

client = Client(schema=schema, parse_results=True)

query = gql(
"""
query = gql("""
query GetAll {
all
}
Expand All @@ -323,8 +318,7 @@ def test_parse_results_with_operation_type():
query GetListOfListOfList {
list_of_list_of_list
}
"""
)
""")

query.variable_values = {
"color": "RED",
Expand Down
Loading
Loading