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

json mutations not working as expected? #43

Open
MarkLyck opened this issue Aug 16, 2017 · 0 comments
Open

json mutations not working as expected? #43

MarkLyck opened this issue Aug 16, 2017 · 0 comments

Comments

@MarkLyck
Copy link

MarkLyck commented Aug 16, 2017

I have no problems with json mutations using react-apollo. But trying to use lokka no matter what I try I get the following error:

Error: GraphQL Error: Argument 'prices' expected type 'Json' but got: [object, Object]. Reason: Not valid JSON (line 5, column 28):
            prices: [object Object]

Here's the code:

const test = {
    test: 'value'
}

client.mutate(`{
        market: updateMarket(
            id: "cj60pwi9v6rh201942t6fq6h7",
            name: "TEST update5",
            prices: ${test}
        ) {
            name
        }
    }`)
        .then((response) => {
            console.log(`RESPONSE: ${JSON.stringify(response)}`)
        })
        .catch(e => console.log(e))

I've tried to stringify it. import it from an actual .json file, stringify then parse it. Putting quotes around it, various types of json data, including arrays. Putting it directly in the `` instead of using a variable.

If I put in e.g. [2] it will say ...but got: [2] instead of [object object] but if I try anything that isn't an array, it will say [object object] (which isn't even what I'm trying to pass)...

I've tried to change the type to an integer and string on graph.cool and changing the variable to a matching type and it works completely fine. It will also change the name just fine if I remove the line with prices.

But I cannot get lokka to update any json... What am I missing here?

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

No branches or pull requests

1 participant