Skip to content

Commit 0bd204b

Browse files
jimbob88alexdev-wb
andauthored
Update ariadne client code example. (graphql#2106)
Co-authored-by: Alex Sheplyakov <[email protected]>
1 parent f0e7957 commit 0bd204b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/code/language-support/python/client/ariadne-codegen.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,19 @@ $ ariadne-codegen
4141
And use it in your Python projects:
4242

4343
```python
44+
import asyncio
4445
from graphql_client import Client
4546

46-
with Client("http://example.com/graphql/") as client:
47-
result = client.create_token(username="Admin", password="Example123)
47+
48+
async def create_token_gql():
49+
client = Client("http://example.com/graphql/")
50+
result = await client.create_token(username="Admin", password="Example123")
4851

4952
if result.errors:
5053
error = result.errors[0]
5154
raise ValidationError({error.field: error.message})
5255

53-
auth_token = result.token
56+
return result.token
57+
58+
asyncio.run(create_token_gql())
5459
```

0 commit comments

Comments
 (0)