edgedb / edgedb-python

The official Python client library for EdgeDB
https://edgedb.com
Apache License 2.0
366 stars 43 forks source link

Unable to set ext::auth::client_token global #472

Closed mrparalon closed 5 months ago

mrparalon commented 5 months ago

Describe the bug

I'm following the instruction about auth extension

Example for js client from docs

const client = createClient().withGlobals({
  "ext::auth::client_token": auth_token,
});

But python client return an error "Illegal name" when I set global like this

client = edgedb.asyncio_client.create_async_client().with_globals({
    "ext::auth::client_token": "example"
    })

It happens in resolve function, because it expects 1 or 2 :: in module path

If it will be useful for someone, I have workaround

client = edgedb.asyncio_client.create_async_client().with_module_aliases(
    {"auth": "ext::auth"}.with_globals({"auth::client_token": edgedb_auth_token}))

Reproduction Include the code that is causing the error:

import edgedb
client = edgedb.asyncio_client.create_async_client().with_globals({
    "ext::auth::client_token": "example"
    })

Expected behavior Setting global works according to docs

Versions (please complete the following information):