MCPcopy
hub / github.com/graphql/graphiql / handleResponse

Function handleResponse

packages/graphiql-react/src/execution.tsx:184–213  ·  view source on GitHub ↗
(result: ExecutionResult)

Source from the content-addressed store, hash-verified

182 try {
183 const fullResponse: ExecutionResult = {};
184 const handleResponse = (result: ExecutionResult) => {
185 // A different query was dispatched in the meantime, so don't
186 // show the results of this one.
187 if (queryId !== queryIdRef.current) {
188 return;
189 }
190
191 let maybeMultipart = Array.isArray(result) ? result : false;
192 if (
193 !maybeMultipart &&
194 typeof result === 'object' &&
195 result !== null &&
196 'hasNext' in result
197 ) {
198 maybeMultipart = [result];
199 }
200
201 if (maybeMultipart) {
202 for (const part of maybeMultipart) {
203 mergeIncrementalResult(fullResponse, part);
204 }
205
206 setIsFetching(false);
207 setResponse(formatResult(fullResponse));
208 } else {
209 const response = formatResult(result);
210 setIsFetching(false);
211 setResponse(response);
212 }
213 };
214
215 const fetch = fetcher(
216 {

Callers 2

nextFunction · 0.85
runFunction · 0.85

Calls 3

formatResultFunction · 0.90
mergeIncrementalResultFunction · 0.85
setResponseFunction · 0.85

Tested by

no test coverage detected