Skip to content

deps: replace SDK-backed GraphQL transport with native fetch #207

@iamfj

Description

@iamfj

What problem does this solve?

src/client/graphql-client.ts imports LinearClient from @linear/sdk only to call linearClient.client.rawRequest(...). This means Linearis cannot remove the SDK even though the transport can be implemented with Node 22 built-in fetch.

Proposed solution

Replace the SDK-backed GraphQL transport with a native implementation in src/client/graphql-client.ts.

The new transport should preserve existing behavior:

  • POST to https://api.linear.app/graphql
  • send JSON body { "query": print(document), "variables": variables }
  • set Content-Type: application/json
  • set Authorization consistently with current API token usage
  • preserve public-file-urls-expire-in: 3600
  • preserve request timeout behavior
  • preserve withRetry() usage
  • preserve current authentication/error mapping behavior

If print() remains in runtime code, add graphql as a direct pinned production dependency.

Alternatives considered

  • Keep using LinearClient.client.rawRequest(...): simplest short term, but leaves the SDK dependency in the critical path.
  • Add another GraphQL HTTP client dependency: unnecessary on Node 22 because fetch is available.

Primary use case

Shell scripting / automation

Additional context

Current files involved:

  • src/client/graphql-client.ts
  • tests/unit/client/graphql-client.test.ts
  • package.json
  • package-lock.json

Acceptance criteria:

  • src/client/graphql-client.ts no longer imports @linear/sdk.
  • Unit tests mock native fetch instead of the SDK.
  • Existing timeout, retry, auth error, and GraphQL error behavior is covered.
  • npm test, npm run check:ci, and typecheck pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P1Highest-priority planned work; should be implemented next

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions