Edits history of script submission #23002 for ' Get Issue (linear)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Issue
     * Get a single issue by its UUID or its human identifier (e.g. ENG-123).
     */
    export async function main(auth: RT.Linear, issue_id: string) {
      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: `query ($id: String!) { issue(id: $id) { id identifier title description url priority priorityLabel estimate dueDate createdAt updatedAt archivedAt state { id name type } assignee { id name email } team { id key name } project { id name } cycle { id number } parent { id identifier } labels { nodes { id name } } children { nodes { id identifier title } } } }`,
          variables: { id: issue_id },
        }),
      })
    
      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.issue
    }
    

    Submitted by hugo989 1 hour ago