From 718c9eaffe21cc8537b983ee2a0562f0f7a7c986 Mon Sep 17 00:00:00 2001 From: Alex Sheplyakov Date: Mon, 10 Apr 2023 07:57:27 +0300 Subject: [PATCH] Update ariadne client code example. --- .../language-support/python/client/ariadne-codegen.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/code/language-support/python/client/ariadne-codegen.md b/src/code/language-support/python/client/ariadne-codegen.md index 3e86eab4dc..66c5b84c50 100644 --- a/src/code/language-support/python/client/ariadne-codegen.md +++ b/src/code/language-support/python/client/ariadne-codegen.md @@ -41,14 +41,19 @@ $ ariadne-codegen And use it in your Python projects: ```python +import asyncio from graphql_client import Client -with Client("http://example.com/graphql/") as client: - result = client.create_token(username="Admin", password="Example123) + +async def create_token_gql(): + client = Client("http://example.com/graphql/") + result = await client.create_token(username="Admin", password="Example123") if result.errors: error = result.errors[0] raise ValidationError({error.field: error.message}) - auth_token = result.token + return result.token + +asyncio.run(create_token_gql()) ```