Skip to content

type-architecture: centralize mutation payload extraction helpers #203

@iamfj

Description

@iamfj

What problem does this solve?

Services repeatedly check mutation payload success and entity presence manually. The pattern is correct but duplicated across many services, increasing the chance of inconsistent null handling or error messages.

Proposed solution

Create small helper functions for common Linear mutation payload patterns.

Example direction:

export function requireMutationEntity<TEntity>(
  payload: { success: boolean; entity?: TEntity | null },
  message: string,
): TEntity {
  if (!payload.success || !payload.entity) throw new Error(message);
  return payload.entity;
}

Additional helpers may be needed for payload fields like issue, project, comment, etc.

Acceptance criteria:

  • Shared helper exists for mutation payload extraction.
  • At least issue/project/initiative services use it.
  • Error behavior remains stable unless intentionally changed.

Alternatives considered

Keep local checks in every service. This is explicit but repetitive.

Primary use case

LLM agent integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P3Low-priority backlog item or nice-to-have improvementqa:smell

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions