{"id":34712906,"url":"https://github.com/andycmaj/graphql-codegen-typescript-graphql-request-with-retries","last_synced_at":"2026-04-19T23:31:27.009Z","repository":{"id":43984381,"uuid":"244237653","full_name":"andycmaj/graphql-codegen-typescript-graphql-request-with-retries","owner":"andycmaj","description":"forked from @graphql-codegen/typescript-graphql-request with additional retry handling for requests","archived":false,"fork":false,"pushed_at":"2023-01-05T08:46:22.000Z","size":1127,"stargazers_count":1,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-21T06:23:10.809Z","etag":null,"topics":["error-handling","graphql","graphql-code-generator","polly-js","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andycmaj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-01T23:02:26.000Z","updated_at":"2024-05-21T06:23:10.810Z","dependencies_parsed_at":"2023-02-03T21:16:27.938Z","dependency_job_id":null,"html_url":"https://github.com/andycmaj/graphql-codegen-typescript-graphql-request-with-retries","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andycmaj/graphql-codegen-typescript-graphql-request-with-retries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andycmaj","download_url":"https://codeload.github.com/andycmaj/graphql-codegen-typescript-graphql-request-with-retries/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32026601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error-handling","graphql","graphql-code-generator","polly-js","typescript"],"created_at":"2025-12-25T00:49:16.678Z","updated_at":"2026-04-19T23:31:27.002Z","avatar_url":"https://github.com/andycmaj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# -graphql-codegen-typescript-graphql-request-with-retries\nforked from @graphql-codegen/typescript-graphql-request with additional retry handling for requests\n\n# example of using the generated SDK with a retry policy from [`polly-js`](https://github.com/mauricedb/polly-js).\n\n```typescript\nimport { GraphQLClient } from 'graphql-request';\nimport { getSdk } from './generated/types';\nimport { ASTNode, print } from 'graphql';\nimport { Variables } from 'graphql-request/dist/src/types';\nimport { RetryWrapper } from 'typescript-graphql-request-with-retries';\nimport polly from 'polly-js';\n\nconst client = new GraphQLClient(process.env.GRAPHQL_URL, {\n  headers: {\n    'x-hasura-admin-secret': process.env.HASURA_GRAPHQL_ADMIN_SECRET,\n  },\n});\n\nexport const request = \u003cT\u003e(query: ASTNode, variables?: Variables) =\u003e\n  client.request\u003cT\u003e(print(query), variables);\n\nconst withRetries: RetryWrapper = \u003cT\u003e(action: () =\u003e Promise\u003cT\u003e) =\u003e\n  polly()\n    .handle((err: Error) =\u003e {\n      console.log('HANDLE', err.message);\n      return err.message.includes('connect ETIMEDOUT');\n    })\n    .waitAndRetry(3)\n    .executeForPromise(info =\u003e {\n      console.log('RETRY', info);\n      return action();\n    });\n\nconst sdk = getSdk(client, withRetries);\n\nexport default sdk;\n```\n\n# Unit test\n\n```typescript\nimport nock from 'nock';\nimport graphqlClient from 'shared/graphqlClient';\n\ndescribe('graphqlClient', () =\u003e {\n  beforeAll(() =\u003e nock.disableNetConnect());\n  afterAll(() =\u003e nock.enableNetConnect());\n  afterEach(() =\u003e nock.cleanAll());\n\n  it('retries twice when ETIMEDOUT', async () =\u003e {\n    nock(/localhost|botany-db/)\n      .post('/v1/graphql')\n      .replyWithError({ code: 'ETIMEDOUT', message: 'connect ETIMEDOUT' });\n\n    nock(/localhost|botany-db/)\n      .post('/v1/graphql')\n      .replyWithError({ code: 'ETIMEDOUT', message: 'connect ETIMEDOUT' });\n\n    nock(/localhost|botany-db/)\n      .post('/v1/graphql')\n      .replyWithError({ code: 'ETIMEDOUT', message: 'connect ETIMEDOUT' });\n\n    try {\n      await graphqlClient.GetDataSource({\n        dataSourceId: 'github',\n      });\n    } catch (e) {\n      console.log('LAST ERROR', e, e.stack);\n    }\n  });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandycmaj%2Fgraphql-codegen-typescript-graphql-request-with-retries/lists"}