Using pydgraph w/ slash

I am trying to use pydgraph w/ slash graphql as that seems the only way to get atomic transactions and when I do client_stub = pydgraph.DgraphClientStub('localhost:9080') using my slash graphql address, i get a DNS error details = "DNS resolution failed for service for the url when doing a query.

Is there any tutorials or walkthroughs for using slashql w/ pydgraph or even better how to do atomic transactions w/ slash graphql. The documentation for the official client is very limited, there is also no talk about using authenticated queries with it, I assume you pass the metadata argument. There is mention of using headers, but only with alter calls, and there is mention of passing credentials, but no mention what they should look like.

Update:

I did find pydgraph.DgraphClientStub.from_slash_endpoint for using a slashql endpoint in a different area but not in that repo’s documentation. Still could use examples. For example, when trying to do a mutation, I get errors that the ‘Schema not defined for predicate’, and I have to use the type.field notation, but in the examples, it does not do this, I only found this digging in other documentation. But I have yet to figure out how to get mutations to work, I managed to avoid error messages but it isn’t updating my instance db.

@docs , is there some bandwidth for some pydgraph love?

@martinmr / @anurag do we support atomic txn in pydgraph? I wasn’t aware we are.

I did see Transactions and Commits on the brief docs, so I only assume it supports atomic operations, but I can’t get it to do mutations in general.

One point to notice. None of Dgraph’s clients are made to run GraphQL(maybe in the future we could have one, but there are out there really good ones). Feels like you wanna do DQL queries and transactions. Following this docs https://dgraph.io/docs/slash-graphql/advanced-queries/, it shows that is possible to do with cURL. Therefore it is perfectly capable of being used in the Py client (for DQL).

I believe that any Dgraph service doesn’t expose that port. Not sure, I think that all will run at 80.


@docs and @gja - This docs feels odd. It opens a connection in the GraphQL subpath. Which confuses me.

client_stub = pydgraph.DgraphClientStub.from_slash_endpoint("https://frozen-mango-42.eu-central-1.aws.cloud.dgraph.io/graphql", "<api-key>")

Why a DQL query would run in a GraphQL subpath? The previous part of the docs mention that we have /query, /graphql, /mutate and /commit endpoints.

Also in the Ratel part mention that it should connect to the /graphql subpath. This would make the user think that Ratel supports GraphQL.

The various clients take the endpoint as it’s given on Slash GraphQL interface. Technically, everything except for the hostname is simply ignored over there.

yeah I figured that out, but this was the key thing to get it to work ‘from_slash_endpoint()’, it wasn’t in the Pydgraph docs though, I found it in the DQL docs. I also ran into some other issues.

Thanks, i’ll put this in the various clients. Currently, they are in the Slash GraphQL docs, but it makes sense to put it in the individual clients.

1 Like