pcooney10
01/26/2018, 6:41 PMError: GraphQL error: Cannot return null for non-nullable type ? I am getting this on the mobile client after firing a resolver mutation. The resolver updates two types in my db, and all fields are getting populated when I go in and look at the databrowserpcooney10
01/26/2018, 6:43 PMtype Purchase @model{
amount: Float!
chargeId: String!
createdAt: DateTime!
currency: String!
description: String!
id: ID! @isUnique
isPaid: Boolean! @defaultValue(value: false)
metadata: Json
outcome: Json
quantity: Int!
source: Json
tickets: [Ticket!]! @relation(name: "TicketPurchase")
updatedAt: DateTime!
user: User @relation(name: "PurchaseOnUser")
}pcooney10
01/26/2018, 6:45 PMtickets, which gets updated after the purchase is successful & the ticketId is generated. Could it be this? Or maybe the @defaultValue(value: false)?matic
01/26/2018, 7:53 PMmatic
01/26/2018, 7:54 PMpcooney10
01/26/2018, 8:20 PMpcooney10
01/26/2018, 8:20 PMpcooney10
01/26/2018, 8:22 PMmatic
01/26/2018, 8:30 PMmatic
01/26/2018, 8:30 PMpcooney10
01/26/2018, 8:32 PMTicket records in my db with the new `purchaseId`'spcooney10
01/26/2018, 8:33 PMcreatePurchase (line 3, column 5), the first of the two mutations calledmatic
01/26/2018, 8:36 PMpcooney10
01/26/2018, 8:36 PMpcooney10
01/26/2018, 8:37 PMmatic
01/26/2018, 8:39 PM{ data: { createPurchase }}, or { error: 'something' } from your resolvers.matic
01/26/2018, 8:41 PMpcooney10
01/26/2018, 8:42 PMpcooney10
01/26/2018, 8:43 PMmatic
01/26/2018, 8:44 PMgraphcool-lib?pcooney10
01/26/2018, 8:45 PMreturn new Promise((resolve, reject) => {
createStripeCharge(amount, currency, description, customer, metadata)
.then(charge => addPurchaseToCustomer(userId, charge, quantity))
.then(response => response.json())
.then(resp => createTicketForCustomer(eventId, resp.data.createPurchase.id, ticketOptionId, userId))
.then(response => response.json())
.then(resp => { resolve(resp) })
.catch(err => {
console.log(err)
reject(err)
})
})
to this: ?
return new Promise((resolve, reject) => {
createStripeCharge(amount, currency, description, customer, metadata)
.then(charge => addPurchaseToCustomer(userId, charge, quantity))
.then(response => response.json())
.then(resp => createTicketForCustomer(eventId, resp.data.createPurchase.id, ticketOptionId, userId))
.then(response => response.json())
.then(resp => { resolve({ data: {createPurchase: resp }}) })
.catch(err => {
console.log(err)
reject({ data: {createPurchase: err }})
})
})pcooney10
01/26/2018, 8:47 PMpcooney10
01/26/2018, 8:48 PMconst fromEvent = require('graphcool-lib').fromEvent
const graphcool = fromEvent(event)
const api = graphcool.api('simple/v1')matic
01/26/2018, 8:48 PM{ data: { createPurchase: err }} do { error }pcooney10
01/26/2018, 8:49 PMmatic
01/26/2018, 8:52 PMpcooney10
01/26/2018, 8:54 PMmatic
01/26/2018, 8:55 PM