james.hatfield
04/25/2017, 9:44 PMmannigan
04/25/2017, 10:55 PMmannigan
04/26/2017, 12:18 AMjeffo
04/26/2017, 4:14 AMilja
04/26/2017, 5:27 AMgameItemID
, userID
, userBalanceAfterPurchase
. Can query based on this data perform checks like:
1) Item that is being purchased exists
2) userBalanceAfterPurchase
is result of subtracting game item price from current user balance
userBalanceAfterPurchase
this bit is my idea of updating users balance without the need of server less function.
At the moment I can’t imagine how such query would look and even if it is possible to do something like this?sdubois
04/26/2017, 5:35 AMsomeUserExists
should be SomeUserExists
, and also the combination of AND
and OR
isn't recognized (maybe a misplacing of brackets?)sdubois
04/26/2017, 5:37 AMsdubois
04/26/2017, 5:38 AMartyom
04/26/2017, 8:17 AMpicosam
04/26/2017, 9:45 AMpicosam
04/26/2017, 9:45 AMsorenbs
nick.kozhukharenko
04/26/2017, 10:50 AMorder
filed which will container a sequence number of the item.
// options 1
type Course {
id: ID!
lessons: [Lesson!]! @relation(name: "CourseLessons")
}
type Lesson {
id: ID!
order: Int! // location in the list on UI
course: Course
}
But in this case if the order in UI is changed (e.g. last lesson was moved to first position) - we have to update each Lesson separatly (a lot of mutation). And I dont know how to determine the ‘order’ property when a Lesson is creating…
Second option is to store a lessonsOrder
filed (which is an array of lessons ids) in the Course and change it every time the order is change/lessons created or delete.
type Course {
id: ID!
lessonsOrder: [String!]! // store here lessons IDs in correct order
lessons: [Lesson!]! @relation(name: "CourseLessons")
}
type Lesson {
id: ID!
course: Course @relation(name: "CourseLessons")
}
Perhaps there are other options that I do not know about?sorenbs
[1, 2, 3, 4]
becomes [1, 1.5, 2, 4]
nick.kozhukharenko
04/26/2017, 12:12 PMartyom
04/26/2017, 12:35 PMpicosam
04/26/2017, 2:55 PMartyom
04/26/2017, 4:13 PMadamveld12
04/26/2017, 4:13 PMrtowarek
04/26/2017, 4:19 PMgustav
04/26/2017, 8:49 PMartyom
04/26/2017, 9:36 PMhvillain
04/26/2017, 9:57 PMuser
04/26/2017, 10:00 PMhttps://prisma.slack.com/files/U4KES2J7P/F55618C0L/image_uploaded_from_ios.jpg▾
user
04/26/2017, 10:28 PMhttps://prisma.slack.com/files/U4KES2J7P/F55618C0L/image_uploaded_from_ios.jpg▾
mannigan
04/27/2017, 12:04 AMsebastien
04/27/2017, 3:40 AMrtowarek
04/27/2017, 7:58 AMtheom
04/27/2017, 8:13 AMconst Comments = React.createClass({
componentDidMount () {
if (this.props.data.loading === false){
this.subscription = this.subscribe();
}
},
componentWillUnmount() {
if (this.subscriptionObserver) {
this.subscriptionObserver.unsubscribe();
}
},
isDuplicateComment(newComment, existingComments) {
let duplicateComment = false;
existingComments.forEach((comment) => {
if (newComment.id !== null && newComment.id === comment.id) {
duplicateComment = true;
}
});
console.log('duplicateComment = ', duplicateComment);
return duplicateComment;
},
subscribe() {
const postIndexID = this.props.postIndexID;
this.subscriptionObserver = this.props.data.subscribeToMore({
document: Subscription_Add_Delete_Comment_Query,
updateQuery: (previousState, {subscriptionData}) => {
// The mutations allways update the Root_Tree, so the new comment already exists in previousState.
// So you just need to return the previousState as is
console.log('previousState = ', previousState);
console.log('subscriptionData = ', subscriptionData);
return previousState;
},
onError: (err) => console.error(err),
});
},
....
})
and my websocket connection code is as follows:
import ApolloClient, {
createNetworkInterface,
addTypeName,
} from 'apollo-client';
import {
SubscriptionClient,
addGraphQLSubscriptions,
} from 'subscriptions-transport-ws';
// Create WebSocket client
const wsClient = new SubscriptionClient('<wss://subscriptions.graph.cool/v1/cj0ogobvm96du01021v9ajeg1>', {
reconnect: true,
connectionParams: {
// Pass any arguments you want for initialization
}
})
const networkInterface = createNetworkInterface({
uri: '<https://api.graph.cool/simple/v1/cj0ogobvm96du01021v9ajeg1>',
opts: {
// Additional fetch options like `credentials` or `headers`
credentials: 'same-origin',
}
})
// Extend the network interface with the WebSocket
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
networkInterface,
wsClient
)
const client = new ApolloClient({
networkInterface: networkInterfaceWithSubscriptions,
dataIdFromObject: (o) => o.id,
addTypeName: true
})
export default client;
What am I overlooking here?user
04/27/2017, 8:25 AMhttps://prisma.slack.com/files/U54PXSN04/F557HPF1R/graph.gif▾