{"record":{"id":"fea6dca058493e3e","repo":"twentyhq/twenty","slug":"url-or-fetcher-is-required","errorCode":null,"errorMessage":"url or fetcher is required","messagePattern":"url or fetcher is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-client-sdk/src/generate/genql/runtime/fetcher.ts","lineNumber":30,"sourceCode":"    batchInterval?: number // ms\n    maxBatchSize?: number\n}\n\nconst DEFAULT_BATCH_OPTIONS = {\n    maxBatchSize: 10,\n    batchInterval: 40,\n}\n\nexport const createFetcher = ({\n    url,\n    headers = {},\n    fetcher,\n    fetch: _fetch,\n    batch = false,\n    ...rest\n}: ClientOptions): Fetcher => {\n    if (!url && !fetcher) {\n        throw new Error('url or fetcher is required')\n    }\n    if (!fetcher) {\n        fetcher = async (body) => {\n            let headersObject =\n                typeof headers == 'function' ? await headers() : headers\n            headersObject = headersObject || {}\n            if (typeof fetch === 'undefined' && !_fetch) {\n                throw new Error(\n                    'Global `fetch` function is not available, pass a fetch polyfill to Genql `createClient`',\n                )\n            }\n            let fetchImpl = _fetch || fetch\n            const res = await fetchImpl(url!, {\n                headers: {\n                    'Content-Type': 'application/json',\n                    ...headersObject,\n                },\n                method: 'POST',","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-client-sdk/src/generate/genql/runtime/fetcher.ts#L12-L48","documentation":"Generated genql code in the Twenty client SDK: `createFetcher` requires at least one transport — either a GraphQL endpoint `url` or a custom `fetcher` function. If neither is supplied in the `ClientOptions`, it throws immediately at client construction. This is a programmer error in how the SDK consumer built the client, not a runtime/network issue.","triggerScenarios":"Calling `createClient({})` or `createClient({ headers })` without a `url` or `fetcher`; destructuring a config object that omitted both; passing `url: undefined`/`url: ''` (falsy) and no fetcher.","commonSituations":"Building a client from an env var that was undefined at construction time (`url: process.env.GRAPHQL_URL` when the var is unset), a refactor that dropped the url argument, or using a custom fetcher pattern but forgetting to pass the fetcher option.","solutions":["Pass a non-empty `url` to `createClient`, e.g. `createClient({ url: 'https://api.twenty.com/graphql', headers })`.","If you intend to supply your own transport, pass the `fetcher` option instead of `url`.","When reading the URL from an env var, validate it is non-empty before constructing the client (fail fast with a clear config error).","Check the type of the config object — `url` must be a string, not an object or undefined."],"exampleFix":"// before\nconst client = createClient({\n  headers: { Authorization: `Bearer ${token}` },\n  // url accidentally omitted\n});\n\n// after\nconst endpoint = process.env.TWENTY_GRAPHQL_URL;\nif (!endpoint) throw new Error('TWENTY_GRAPHQL_URL must be set');\nconst client = createClient({\n  url: endpoint,\n  headers: { Authorization: `Bearer ${token}` },\n});","handlingStrategy":"validation","validationCode":"const endpoint = process.env.TWENTY_GRAPHQL_URL;\nif (!endpoint) {\n  throw new Error('TWENTY_GRAPHQL_URL must be set to construct the SDK client');\n}\nconst client = createClient({ url: endpoint, headers });","typeGuard":"const hasClientTransport = (\n  opts: Partial<ClientOptions>,\n): opts is { url: string } | { fetcher: Fetcher } =>\n  (typeof opts.url === 'string' && opts.url.length > 0) || typeof opts.fetcher === 'function';","tryCatchPattern":null,"preventionTips":["Validate the URL (or fetcher) is present before calling createClient.","Read endpoint config from a validated env loader, not raw `process.env` inline.","Add a unit test that constructs the client with the production config to catch missing-URL at test time.","Treat createClient({}) as a programmer error worth a compile-time assertion."],"tags":["client-sdk","genql","configuration","typescript","constructor"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}