This repository was archived by the owner on Sep 27, 2023. It is now read-only.
File tree 3 files changed +54
-38
lines changed
example-hooks-gen/ts/components
3 files changed +54
-38
lines changed Original file line number Diff line number Diff line change @@ -36,16 +36,6 @@ interface Props {
36
36
}
37
37
38
38
graphql `
39
- fragment TodoData on Todo {
40
- complete
41
- id
42
- text
43
- }
44
- fragment TodoViewer on User {
45
- id
46
- totalCount
47
- completedCount
48
- }
49
39
mutation TodoRemoveMutation($input: RemoveTodoInput!) {
50
40
removeTodo(input: $input) {
51
41
deletedTodoId
@@ -55,6 +45,9 @@ graphql`
55
45
}
56
46
}
57
47
}
48
+ `
49
+
50
+ graphql `
58
51
mutation TodoRenameMutation($input: RenameTodoInput!) {
59
52
renameTodo(input: $input) {
60
53
todo {
@@ -63,6 +56,9 @@ graphql`
63
56
}
64
57
}
65
58
}
59
+ `
60
+
61
+ graphql `
66
62
mutation TodoChangeStatusMutation($input: ChangeTodoStatusInput!) {
67
63
changeTodoStatus(input: $input) {
68
64
todo {
@@ -80,8 +76,22 @@ graphql`
80
76
const Todo = ( props : Props ) => {
81
77
const [ isEditing , setIsEditing ] = React . useState ( false )
82
78
79
+ graphql `
80
+ fragment TodoData on Todo {
81
+ complete
82
+ id
83
+ text
84
+ }
85
+ `
83
86
const todo = useTodoDataFragment ( props . todo )
84
87
88
+ graphql `
89
+ fragment TodoViewer on User {
90
+ id
91
+ totalCount
92
+ completedCount
93
+ }
94
+ `
85
95
const viewer = useTodoViewerFragment ( props . viewer )
86
96
87
97
const [ commitRename ] = useTodoRenameMutation ( )
Original file line number Diff line number Diff line change @@ -29,28 +29,14 @@ interface Props {
29
29
}
30
30
31
31
graphql `
32
- fragment TodoAppData on User
33
- @refetchable(queryName: "TodoAppRefetchQuery")
34
- @argumentDefinitions(
35
- last: { type: "Int" }
36
- first: { type: "Int" }
37
- after: { type: "String" }
38
- before: { type: "String" }
39
- ) {
40
- id
41
- totalCount
42
- isAppending
43
- ...TodoListFooterData
44
- ...TodoList
45
- @arguments(last: $last, first: $first, after: $after, before: $before)
46
- }
47
-
48
32
mutation TodoAppSetAppendingMutation($isAppending: Boolean!) {
49
33
setAppending(appending: $isAppending) {
50
34
isAppending
51
35
}
52
36
}
37
+ `
53
38
39
+ graphql `
54
40
mutation TodoAppAddTodoMutation(
55
41
$input: AddTodoInput!
56
42
$connections: [ID!]!
@@ -85,6 +71,23 @@ graphql`
85
71
let tempID = 0
86
72
87
73
const TodoApp = ( props : Props ) => {
74
+ graphql `
75
+ fragment TodoAppData on User
76
+ @refetchable(queryName: "TodoAppRefetchQuery")
77
+ @argumentDefinitions(
78
+ last: { type: "Int" }
79
+ first: { type: "Int" }
80
+ after: { type: "String" }
81
+ before: { type: "String" }
82
+ ) {
83
+ id
84
+ totalCount
85
+ isAppending
86
+ ...TodoListFooterData
87
+ ...TodoList
88
+ @arguments(last: $last, first: $first, after: $after, before: $before)
89
+ }
90
+ `
88
91
const [ viewer , refetch ] = useRefetchableTodoAppDataFragment ( props . frag )
89
92
const [ addTodo ] = useTodoAppAddTodoMutation ( )
90
93
const [ setAppending ] = useTodoAppSetAppendingMutation ( )
Original file line number Diff line number Diff line change @@ -25,6 +25,21 @@ interface Props {
25
25
viewer : TodoList$key
26
26
}
27
27
28
+ graphql `
29
+ mutation TodoListMarkAllTodosMutation($input: MarkAllTodosInput!) {
30
+ markAllTodos(input: $input) {
31
+ changedTodos {
32
+ id
33
+ complete
34
+ }
35
+ viewer {
36
+ id
37
+ completedCount
38
+ }
39
+ }
40
+ }
41
+ `
42
+
28
43
graphql `
29
44
fragment TodoList on User
30
45
@argumentDefinitions(
@@ -49,18 +64,6 @@ graphql`
49
64
completedCount
50
65
...TodoViewer
51
66
}
52
- mutation TodoListMarkAllTodosMutation($input: MarkAllTodosInput!) {
53
- markAllTodos(input: $input) {
54
- changedTodos {
55
- id
56
- complete
57
- }
58
- viewer {
59
- id
60
- completedCount
61
- }
62
- }
63
- }
64
67
`
65
68
66
69
const TodoList = ( props : Props ) => {
You can’t perform that action at this time.
0 commit comments