//native
/**
* Update Project
* Update a project. Only the fields you set are changed. status_id comes from List Project Statuses; label_ids (from List Project Labels) replaces all labels. Dates are YYYY-MM-DD. Priority: 0 none, 1 urgent, 2 high, 3 medium, 4 low.
*/
export async function main(
auth: RT.Linear,
project_id: string,
name: string | undefined,
description: string | undefined,
status_id: string | undefined,
lead_id: string | undefined,
priority: number | undefined,
start_date: string | undefined,
target_date: string | undefined,
label_ids: string[] | undefined
) {
const response = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
Authorization: auth.apiKey,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query: `mutation ($id: String!, $input: ProjectUpdateInput!) { projectUpdate(id: $id, input: $input) { success project { id name description url priority progress startDate targetDate updatedAt status { id name type } lead { id name } labels { nodes { id name } } teams { nodes { id key } } } } }`,
variables: {
id: project_id,
input: {
name: name || undefined,
description: description || undefined,
statusId: status_id || undefined,
leadId: lead_id || undefined,
priority: priority ?? undefined,
startDate: start_date || undefined,
targetDate: target_date || undefined,
labelIds: label_ids?.length ? label_ids : undefined,
},
},
}),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
const { data, errors } = await response.json()
if (errors) {
throw new Error(JSON.stringify(errors))
}
return data.projectUpdate
}
Submitted by hugo989 2 hours ago