picosam
08/31/2017, 7:03 PMjson
field within a Schema Extension Function?agartha
08/31/2017, 9:01 PMpicosam
08/31/2017, 9:03 PM.json()
back from Stripe I’d better JSON.stringify(result.json())
then.agartha
08/31/2017, 9:04 PMpicosam
08/31/2017, 9:36 PMpicosam
08/31/2017, 9:37 PMagartha
08/31/2017, 9:37 PMpicosam
08/31/2017, 9:37 PM{"response":{"error":"Syntax error while parsing GraphQL query. Invalid input \"\"{\"id\"\", expected Value or Argument (line 3, column 99):\n updateUser(id: \"cj3dmjxzk47xk0190667es0rx\", stripeId: \"cus_BJdT8zbQ569hza\", stripeData: \"{\"id\":\"cus_BJ
picosam
08/31/2017, 9:38 PMagartha
08/31/2017, 9:38 PMpicosam
08/31/2017, 9:39 PMfunction createStripeCustomer() {
return stripe.customers.create({
email: email,
source: source,
})
}
picosam
08/31/2017, 9:39 PMagartha
08/31/2017, 9:39 PMpicosam
08/31/2017, 9:40 PMreturn createStripeCustomer()
.then(result => {
if (result.error) {
throw new Error(result.error.type + ': ' + result.error.message)
}
return updateGraphcoolUser(userId, result.id, JSON.stringify(result))
})
agartha
08/31/2017, 9:41 PMpicosam
08/31/2017, 9:42 PMJSON.stringify(JSON.stringify(result))
but that just increased the number of slashes in the error lolagartha
08/31/2017, 9:43 PMresult
agartha
08/31/2017, 9:43 PMpicosam
08/31/2017, 9:43 PM"logs":["2017-08-31T21:43:24.995Z: {\"id\":\"cus_BJdjBoxxJZYPYL\",\"object\":\"customer\",\"account_balance\":0,\"created\":1504215804,\"currency\":null
picosam
08/31/2017, 9:44 PMagartha
08/31/2017, 9:44 PMpicosam
08/31/2017, 9:44 PMmutation {
updateUser(id: "${userId}", stripeId: "${stripeId}", stripeData: "${stripeData}") {
id,
stripeData
}
}
picosam
08/31/2017, 9:45 PMstripeData
is a Json field and the other two are `String`sagartha
08/31/2017, 9:46 PM${stripeData}
in the mutationpicosam
08/31/2017, 9:47 PM${stripeData}
significant?agartha
08/31/2017, 9:48 PM""
as stripeData value, followed by the rest of the Json value that can't be interpretedpicosam
08/31/2017, 9:49 PMagartha
08/31/2017, 9:49 PM{ a: 1}
.
JSON.stringify turns that into {"a": "1"}
agartha
08/31/2017, 9:49 PM"{\"a\": \"1\"}"
picosam
08/31/2017, 9:49 PMmutation {
updateUser(id: "${userId}", stripeId: "${stripeId}", stripeData: ${JSON.stringify(stripeData)}) {
id,
stripeData
}
}
picosam
08/31/2017, 9:49 PMpicosam
08/31/2017, 9:50 PMJSON.stringify(result)
picosam
08/31/2017, 9:50 PMagartha
08/31/2017, 9:50 PM""{\"a\": \"1\"}""
which is too much 🙂agartha
08/31/2017, 9:50 PMagartha
08/31/2017, 9:51 PMpicosam
08/31/2017, 9:51 PMpicosam
08/31/2017, 9:51 PMagartha
08/31/2017, 9:51 PMagartha
08/31/2017, 9:52 PMpicosam
08/31/2017, 9:52 PMagartha
08/31/2017, 9:52 PMpicosam
08/31/2017, 9:53 PMpicosam
08/31/2017, 9:53 PMpicosam
08/31/2017, 9:53 PMagartha
08/31/2017, 9:53 PMpicosam
08/31/2017, 9:54 PMpicosam
08/31/2017, 9:54 PMagartha
08/31/2017, 9:54 PMmutation($userId: ID, $stripeId: String, $stripeData: Json) {
updateUser(id: $userId, stripeId: $stripeId, stripeData: $stripeData) {
id,
stripeData
}
}
picosam
08/31/2017, 9:55 PMagartha
08/31/2017, 9:55 PMagartha
08/31/2017, 9:56 PMagartha
08/31/2017, 9:57 PMgraphcool-lib
, so request(...)
becomes api.request(...)
, but it shows you how to use variablesagartha
08/31/2017, 9:57 PMpicosam
08/31/2017, 9:57 PMpicosam
08/31/2017, 9:57 PMagartha
08/31/2017, 9:58 PMapi.request(query)
, or api.request(query, variables)
picosam
08/31/2017, 9:58 PMagartha
08/31/2017, 9:58 PMvariables
being a json object with all the variablespicosam
08/31/2017, 9:58 PMagartha
08/31/2017, 9:59 PMpicosam
08/31/2017, 9:59 PMpicosam
08/31/2017, 9:59 PMagartha
08/31/2017, 9:59 PMpicosam
08/31/2017, 9:59 PMpicosam
08/31/2017, 10:00 PMagartha
08/31/2017, 10:00 PMpicosam
08/31/2017, 10:00 PMagartha
08/31/2017, 10:00 PMpicosam
08/31/2017, 10:01 PMpicosam
08/31/2017, 10:02 PMpicosam
08/31/2017, 10:02 PMagartha
08/31/2017, 10:02 PMpicosam
08/31/2017, 10:03 PMagartha
08/31/2017, 10:04 PM