MCPcopy Create free account
hub / github.com/TanStack/query / constructor

Method constructor

examples/lit/pagination/src/main.ts:104–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102 >
103
104 constructor() {
105 super()
106
107 this.projectsQueryOptions = {
108 queryKey: projectsQueryKey(this.page, this.delayMs, this.forceErrorMode),
109 queryFn: () =>
110 fetchProjectsPage(this.page, this.delayMs, this.forceErrorMode),
111 placeholderData: keepPreviousData,
112 }
113
114 this.projectsQuery = createQueryController<ProjectsPageResponse, Error>(
115 this,
116 this.projectsQueryOptions,
117 )
118
119 this.createProjectMutation = createMutationController<
120 Project,
121 Error,
122 CreateProjectInput
123 >(
124 this,
125 {
126 mutationKey: ['create-project'],
127 mutationFn: async (input) => {
128 const response = await createProjectOnServer(input)
129 return response.project
130 },
131 onMutate: () => {
132 this.mutationControlStatus = 'idle'
133 this.mutationControlError = undefined
134 },
135 onSuccess: async () => {
136 this.page = 1
137 this.lastAutoPrefetchPage = 0
138 this.prefetchStatus = 'idle'
139 this.draftName = ''
140 this.draftOwner = 'Team 6'
141 this.syncProjectsQueryOptions()
142 await queryClient.invalidateQueries({
143 queryKey: ['projects'],
144 refetchType: 'none',
145 })
146 await this.projectsQuery.refetch()
147 },
148 },
149 queryClient,
150 )
151
152 this.favoriteMutation = createMutationController<
153 Project,
154 Error,
155 ToggleProjectFavoriteInput,
156 FavoriteMutationContext
157 >(
158 this,
159 {
160 mutationKey: ['toggle-project-favorite'],
161 mutationFn: async (input) => {

Callers

nothing calls this directly

Calls 12

projectsQueryKeyFunction · 0.90
fetchProjectsPageFunction · 0.90
createQueryControllerFunction · 0.90
createMutationControllerFunction · 0.90
createProjectOnServerFunction · 0.90
refetchMethod · 0.80
invalidateQueriesMethod · 0.45
cancelQueriesMethod · 0.45
getQueriesDataMethod · 0.45
setQueryDataMethod · 0.45

Tested by

no test coverage detected