VerachadW / kraph

GraphQL request string builder written in Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List with quotes

eduardostuart opened this issue · comments

Hi,

I'm trying to send a list of items into a mutation. But, I'm receiving a

Cannot parse the unexpected character \".\".\n\

The rendered query doesn't contain quotes (I think that's the problem). Do you have any solutions for that?

Query:

fun updateSomething(mylist: ArrayList<String>): Kraph {
    return Kraph {
        mutation {
            func("updateSomething", args = mapOf("mylist" to mylist)) {
                field("mylist")
            }
        }
    }
}

This will render:

{"query": "mutation { \nupdateSomething(input: { mylist: [item1, item2] }) {\nmylist\n}\n}", "variables": null, "operationName": null}

I am not sure what do you mean by the query doesn't contain quotes since the result look fine for me. Could you explain for that? Also, please attach the full error too.

I mean, the query should be:

{"query": "mutation { \nupdateSomething(input: { mylist: [\"item1\", \"item2\"] }) {\nmylist\n}\n}", "variables": null, "operationName": null}

mylist items with quotes.

mylist: ["item1", "item2"] instead of mylist: [item1, item2]

I see. It means that you pass the array of string into the parameter and it did not escape correctly. This is definitely a bug. I will try to fix it during this weekend.

@eduardostuart It fixed on this branch. I will do cleanup a little bit and try to release as a hotfix in this weekends. Would you mind check it for me?

@VerachadW
Yes, it works. Thanks a lot.

@VerachadW
I'm using version 0.5.0. it doesn't work if the data field contains double quotes character inside and throw syntax error. Please help

mutation {
createProduct(title: “my name is "binh" ") {...}
}