{"record":{"id":"fd743954daac043f","repo":"twentyhq/twenty","slug":"genql-batch-fetcher-returned-unexpected-result","errorCode":null,"errorMessage":"Genql batch fetcher returned unexpected result  + JSON.stringify(json)","messagePattern":"Genql batch fetcher returned unexpected result  \\+ JSON\\.stringify\\(json\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-client-sdk/src/generate/genql/runtime/fetcher.ts","lineNumber":93,"sourceCode":"            }\n        }\n    }\n\n    const batcher = new QueryBatcher(\n        async (batchedQuery) => {\n            // console.log(batchedQuery) // [{ query: 'query{user{age}}', variables: {} }, ...]\n            const json = await fetcher!(batchedQuery)\n            return json as any\n        },\n        batch === true ? DEFAULT_BATCH_OPTIONS : batch,\n    )\n\n    return async ({ query, variables }) => {\n        const json = await batcher.fetch(query, variables)\n        if (json?.data) {\n            return json.data\n        }\n        throw new Error(\n            'Genql batch fetcher returned unexpected result ' + JSON.stringify(json),\n        )\n    }\n}\n","sourceCodeStart":75,"sourceCodeEnd":98,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-client-sdk/src/generate/genql/runtime/fetcher.ts#L75-L98","documentation":"Thrown by the genql batch fetcher wrapper (fetcher.ts:88-95) after the batcher returns a JSON object that has no `data` field. Unlike the single fetcher path, the batch path does not unwrap GraphQL `errors` into a GenqlError — it treats anything lacking `data` as an unexpected result and serializes the whole JSON for debugging.","triggerScenarios":"Batching is enabled (batch: true or batch options passed to createClient) and the server returns a GraphQL response containing only `errors` (no `data`), or a top-level JSON shape the client does not expect (e.g. an error envelope from a gateway).","commonSituations":"Server-side GraphQL validation errors that omit `data`; an API gateway returning `{ error: ... }`; an empty 200 response parsed to `{}`; mismatches between batched query count and server batching support.","solutions":["Disable batching (pass `batch: false` or omit it) to fall through to the single-fetcher path that properly raises GenqlError on `errors`.","Log JSON.stringify(json) from the thrown error to see the actual server response shape.","Fix the underlying GraphQL error the server is reporting in the `errors` array.","Confirm the Twenty server supports GraphQL query batching."],"exampleFix":"// before\nconst client = createClient({ url, headers, batch: true });\n// after\nconst client = createClient({ url, headers, batch: false });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const data = await client.someQuery();\n} catch (err) {\n  if (err.message.startsWith('Genql batch fetcher returned unexpected result')) {\n    // The JSON.stringify(json) suffix reveals the server payload shape.\n    console.error('Batch unexpected:', err.message);\n  }\n  throw err;\n}","preventionTips":["Disable batching unless the server explicitly supports it.","Log the serialized payload to learn the server's actual response shape.","Keep client and server versions aligned.","Use a custom fetcher that preserves response ordering when batching."],"tags":["graphql","batching","client-sdk"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}