-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathAddTodoSubscription.js
More file actions
48 lines (43 loc) · 917 Bytes
/
AddTodoSubscription.js
File metadata and controls
48 lines (43 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Relay from 'react-relay/classic';
import { Subscription } from 'relay-subscriptions';
import Todo from '../components/Todo';
export default class AddTodoSubscription extends Subscription {
static fragments = {
viewer: () => Relay.QL`
fragment on User {
id
}
`,
};
getSubscription() {
return Relay.QL`
subscription {
addTodoSubscription(input: $input) {
todoEdge {
__typename
node {
${Todo.getFragment('todo')}
}
}
viewer {
id
totalCount
}
}
}
`;
}
getConfigs() {
return [{
type: 'RANGE_ADD',
parentName: 'viewer',
parentID: this.props.viewer.id,
connectionName: 'todos',
edgeName: 'todoEdge',
rangeBehaviors: () => 'append',
}];
}
getVariables() {
return {};
}
}