Custom lambda not working on Dedicated Cluster with namespaces and ACL

Update

Alright, further investigation revealed (at least with my understanding) that this is definitely a bug!

I managed to get my custom fetch query, against the /mutate endpoint, working for my namespace if I additionally attach the DG-Auth header with the Admin Key to the request…

const response = await fetch(`https://MY_ENDPOINT/mutate?commitNow=true`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-Dgraph-AccessToken": "MY_TOKEN",
        "DG-Auth": "MY_ADMIN_KEY",
      },
      body: JSON.stringify({
        query: `{ q(func: uid(${input.id})) { uid } }`,
        mutations: [{}],
      }),
    });

const test = await response.json();

Great! This means that if I want custom lambdas to be working, I need to:

  • Login in the frontend to get the access token for the user on the namespace so I can mutate against the /graphql endpoint
  • Either submit the access token as a parameter(!) or run the login mutation inside the lambda resolver again to get another access token.
  • We obviously can’t use the built in functions dql.mutate and dql.query anymore, so we have to write our own wrapper wich performs a custom fetch request where we manually attach the X-Dgraph-AccessToken and the DG-Auth with the admin key as value.

So either I did not get this entirely or this is such a big fail! How can it be that no one ever experienced this before? Am I the only one paying for a Dedicated Cluster and tried namespaces?

Once again the trust in Dgraph is put under test…

1 Like