MCPcopy Create free account
hub / github.com/simstudioai/sim / mondayGraphQL

Function mondayGraphQL

apps/sim/connectors/monday/monday.ts:116–157  ·  view source on GitHub ↗

* Executes a GraphQL query against the monday.com API, surfacing GraphQL-level * errors (which return HTTP 200 with an `errors` array) as thrown errors.

(
  accessToken: string,
  query: string,
  variables: Record<string, unknown> = {},
  retryOptions?: Parameters<typeof fetchWithRetry>[2]
)

Source from the content-addressed store, hash-verified

114 * errors (which return HTTP 200 with an `errors` array) as thrown errors.
115 */
116async function mondayGraphQL<T>(
117 accessToken: string,
118 query: string,
119 variables: Record<string, unknown> = {},
120 retryOptions?: Parameters<typeof fetchWithRetry>[2]
121): Promise<T> {
122 const response = await fetchWithRetry(
123 MONDAY_API_URL,
124 {
125 method: 'POST',
126 headers: mondayHeaders(accessToken),
127 body: JSON.stringify({ query, variables }),
128 },
129 retryOptions
130 )
131
132 if (!response.ok) {
133 const errorText = await response.text().catch(() => '')
134 throw new Error(
135 `monday.com API HTTP error: ${response.status}${errorText ? ` — ${errorText.slice(0, 200)}` : ''}`
136 )
137 }
138
139 const data = (await response.json()) as {
140 data?: T
141 errors?: { message?: string }[]
142 error_message?: string
143 }
144
145 if (data.errors && data.errors.length > 0) {
146 const message = data.errors
147 .map((e) => e.message)
148 .filter(Boolean)
149 .join('; ')
150 throw new Error(`monday.com API error: ${message || 'Unknown GraphQL error'}`)
151 }
152 if (data.error_message) {
153 throw new Error(`monday.com API error: ${data.error_message}`)
154 }
155
156 return data.data as T
157}
158
159/**
160 * GraphQL selection set for an item, shared between listing and single-item

Callers 1

monday.tsFile · 0.85

Calls 4

fetchWithRetryFunction · 0.90
textMethod · 0.80
joinMethod · 0.80
mondayHeadersFunction · 0.70

Tested by

no test coverage detected