Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutation query error #2

Open
gleba opened this issue May 12, 2017 · 3 comments
Open

mutation query error #2

gleba opened this issue May 12, 2017 · 3 comments
Labels

Comments

@gleba
Copy link

gleba commented May 12, 2017

The requests with mutations as mutation {set{<9963693899913877966> <state> "4".}}
returned empty and with an error
But make changes.

Output log:

response:  { name: 'ship', state: 3, _uid_: '9963693899913877966' }
mutation query:  mutation {set{<9963693899913877966> <state> "4".}}
mutation query response:  undefined
query:  query { me(id:9963693899913877966) { name, state, _uid_ } }
TypeError: Cannot read property 'uid' of undefined
    at Object.nodeToObject (...\dgraph\converter.js:85:13)
    at run.then.response (...\dgraph\index.js:42:32)
query response:  { me: { _uid_: '9963693899913877966', name: 'ship', state: 4 } }

source code:

    let data: any = {name: "ship", state: 3}
    let respone1: any = await client.set(data)
    console.log("response: ", respone1)

    let mq = `mutation {set{<${data._uid_}> <state> "4".}}`
    console.log("mutation query: ", mq)
    let respone2 = await client.query(mq).catch(console.error)
        .catch(x => console.warn(x))
    console.log("mutation query response: ", respone2)

    let q2 = `query { me(id:${respone1._uid_}) { name, state, _uid_ } }`
    console.log("query: ", q2)
    let respone4 = await client.query(q2)
    console.log("query response: ", respone4)
@reicheltp reicheltp added bug and removed bug labels May 12, 2017
@reicheltp
Copy link
Owner

Hi @gleba,

Mutation queries are currently not supported, as they send another response as queries.

But for now, you can just ignore the error, or modify an existing object by:

await client.set( {_uid_: data._uid_, state: 4} )

Best, Paul

@reicheltp reicheltp added the bug label May 12, 2017
@reicheltp
Copy link
Owner

@gleba What's your usecase to send raw mutation queries? Actuall, the api is designed to be a high level api wrapper around the raw gRPC. Therefore a query is scoped to the right object and on set the uid's are reassigned automatically.

If you like to send some special raw gRPC request, you can do this the following way:

var request = new DgraphClient.Request()
request.query = 'mutation {set{<9963693899913877966> <state> "4".}}'
var response = await client.run(request) 

The response is a structured like this proto https://github.com/dgraph-io/dgraph/blob/release/v0.7.5/protos/graphp/graphresponse.proto#L97-L102

Nevertheless, this is all WIP and designed around my usecases, so if you have some ideas to extend the API, I am curious to hear them.

@gleba gleba changed the title mutarion query error mutation query error May 12, 2017
@gleba
Copy link
Author

gleba commented May 12, 2017

@reicheltp Thank you.
With this understanding of the current API is enough.
My case in research progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants