MCPcopy Index your code
hub / github.com/simstudioai/sim / linearGraphQL

Function linearGraphQL

apps/sim/connectors/linear/linear.ts:37–69  ·  view source on GitHub ↗

* Executes a GraphQL query against the Linear API.

(
  accessToken: string,
  query: string,
  variables?: Record<string, unknown>,
  retryOptions?: RetryOptions
)

Source from the content-addressed store, hash-verified

35 * Executes a GraphQL query against the Linear API.
36 */
37async function linearGraphQL(
38 accessToken: string,
39 query: string,
40 variables?: Record<string, unknown>,
41 retryOptions?: RetryOptions
42): Promise<Record<string, unknown>> {
43 const response = await fetchWithRetry(
44 LINEAR_API,
45 {
46 method: 'POST',
47 headers: {
48 'Content-Type': 'application/json',
49 Authorization: `Bearer ${accessToken}`,
50 },
51 body: JSON.stringify({ query, variables }),
52 },
53 retryOptions
54 )
55
56 if (!response.ok) {
57 const errorText = await response.text()
58 logger.error('Linear GraphQL request failed', { status: response.status, error: errorText })
59 throw new Error(`Linear API error: ${response.status}`)
60 }
61
62 const json = (await response.json()) as { data?: Record<string, unknown>; errors?: unknown[] }
63 if (json.errors) {
64 logger.error('Linear GraphQL errors', { errors: json.errors })
65 throw new Error(`Linear GraphQL error: ${JSON.stringify(json.errors)}`)
66 }
67
68 return json.data as Record<string, unknown>
69}
70
71/**
72 * Builds a formatted text document from a Linear issue.

Callers 1

linear.tsFile · 0.85

Calls 3

fetchWithRetryFunction · 0.90
textMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected