0

List Project Updates

by
Published today

List project status updates, optionally for one project.

Script linear Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 1 hour ago
1
//native
2

3
/**
4
 * List Project Updates
5
 * List project status updates, newest first, optionally for a single project. Paginate with after = pageInfo.endCursor.
6
 */
7
export async function main(
8
  auth: RT.Linear,
9
  project_id: string | undefined,
10
  include_archived: boolean = false,
11
  first: number = 50,
12
  after: string | undefined
13
) {
14
  const response = await fetch("https://api.linear.app/graphql", {
15
    method: "POST",
16
    headers: {
17
      Authorization: auth.apiKey,
18
      "Content-Type": "application/json",
19
      Accept: "application/json",
20
    },
21
    body: JSON.stringify({
22
      query: `query ($filter: ProjectUpdateFilter, $includeArchived: Boolean, $first: Int, $after: String) { projectUpdates(filter: $filter, includeArchived: $includeArchived, first: $first, after: $after, orderBy: createdAt) { nodes { id body health url createdAt updatedAt user { id name } project { id name } } pageInfo { hasNextPage endCursor } } }`,
23
      variables: {
24
        filter: project_id
25
          ? { project: { id: { eq: project_id } } }
26
          : undefined,
27
        includeArchived: include_archived,
28
        first,
29
        after: after || undefined,
30
      },
31
    }),
32
  })
33

34
  if (!response.ok) {
35
    throw new Error(`${response.status} ${await response.text()}`)
36
  }
37

38
  const { data, errors } = await response.json()
39
  if (errors) {
40
    throw new Error(JSON.stringify(errors))
41
  }
42

43
  return data.projectUpdates
44
}
45