graphql / graphql.github.io

GraphQL Documentation at graphql.org
https://graphql.org
MIT License
838 stars 1.44k forks source link

Code sample for ariadne-codegen is outdated. #1392

Open alexdev-wb opened 1 year ago

alexdev-wb commented 1 year ago

Description

Code sample for ariadne-codegen is outdated.

Motivation

Relevant code sample for ariadne-codegen.

Collaboration

Replace the code with something like this:

import asyncio
from graphql_client import Client

async def fetch_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

asyncio.run(fetch_gql())
Urigo commented 1 year ago

thanks! could you submit a PR with a fix?