Can anybody help me figure out whats wrong with th...
# prisma-whats-new
g
Can anybody help me figure out whats wrong with this json syntax
Copy code
mutation addClientCompany($name: String!, $clientCompanyId: ID!) {
  createModel(name: $name, clientCompanyId: $clientCompanyId, strategicObjectives: [{name: "Urgency", scaleWeights: {low: {medium: 55.6, high: 63.8}}}]) {
    id
    name
  }
}
n
@gmuresan you need to escape the double quotes
g
the problem seems to be with the scaleWeights field
the type if JSON but its telling me its not valid json
n
shouldn't the keys all be enclosed with "?
g
that doesnt work in the playground either
n
alright let's try to make it work in the playground first then
g
“Expected Name, found string “low"
n
so
strategicObjectives
is a field of type JSON-list?
g
no thats a relation
n
ah so that's a nested create
g
this mutation was working before I added the scaleWeights parameter
n
in the playground, can you try this
scaleWeights: "{\"low\": {\"medium\": 55.6, \"high\": 63.8}}"
g
that works
thanks
n
sure! what GraphQL client are you using?
g
apollo
n
are you using a variable for
scaleWeights
?
g
no in this case this is the default value for scaleWeights
n
alright then this can be copied 1-1
g
actually I misunderstood your question. I am using a variable because I need to use this default value in multiple places
n
I mean a GraphQL variable
g
I think I need to use \\\” for each quote then
yea not a grapqhl variable
just a JS variable
n
heh
well yea depending on how exactly you're using it you might need additional escaping 😛