Inclusion Criteria:  Must be ≥18 years of age at the time of signing the informed consent Must have histologically confirmed metastatic or unresectable GIST that has recurred or progressed after at least 4 lines of prior systemic SOC therapy or the Investigator has determined that treatment with SOC therapy is not appropriate for patients who failed at least 2 lines of prior SOC Patient's tumor must have known KIT mutation Must be able to swallow an oral medication Must have Eastern Cooperative Oncology Group (ECOG) performance status of 0 to 2 Patient agrees to use contraception consistent with local regulations Must provide signed informed consent to participate in the study  Exclusion Criteria:  Patient's tumor has known PDGFRA mutation Known hypersensitivity to avapritinib, midazolam, or any of their excipients Have received previous therapy with avapritinib  Have any of the following laboratory abnormalities before the first dose of study drug:  Alanine aminotransferase (ALT) and aspartate aminotransferase (AST) >3 × upper limit of normal (ULN) if no hepatic metastases are present; >5 × ULN if hepatic metastases are present Total bilirubin >1.5 × ULN; >3 × ULN in the presence of Gilbert's Disease Estimated (Cockcroft-Gault formula) or measured creatinine clearance <60 mL/min Platelet count <90 × 109/L Absolute neutrophil count (ANC) <1.0 × 109/L Hemoglobin <9 g/dL. Transfusion and erythropoietin may be used to reach at least 9 g/dL but must have been administered at least 2 weeks before the first dose of the study drug. Require therapy with a concomitant medication that is a strong and moderate CYP3A4 inhibitors or inducers Consumption of any nutrients known to modulate CYP3A4 enzymes activity (eg, grapefruit or grapefruit juice, pomelo juice, star fruit, or Seville [blood] orange and derivative products, cruciferous vegetables [eg, broccoli, cauliflower, cabbage, brussel sprouts]) within 14 days before screening and during the study until the end of the Main Treatment Period Have received a prior anticancer drug less than 5 half-lives or 14 days (whichever is shorter) before screening Have had a major surgical procedure within 14 days of the first dose of study drug or have significant traumatic injury within 28 days before screening Have history of a seizure disorder (eg, epilepsy) or requirement for anticonvulsant medications Have history of a cerebrovascular accident or transient ischemic attacks within 1 year before screening Have known risk of intracranial bleeding, such as a brain aneurysm or history of subdural or subarachnoid bleeding Have primary brain malignancy or metastases to the brain Have corrected QT interval using Fridericia's formula (QTcF) >450 msec Have clinically significant, uncontrolled, cardiovascular disease, including congestive heart failure Grades 2, 3, or 4 according to the New York Heart Association classification, myocardial infarction, or unstable angina within the previous 6 months, or uncontrolled hypertension Have experienced any hemorrhage or bleeding event National Cancer Institute Common Terminology Criteria for Adverse Events (NCI CTCAE) Version 5.0 Grade ≥3 within 4 weeks before screening Patients who have a symptomatic nonhealing wound, ulcer, GI perforation, or bone fracture Have received organ or allogenic bone marrow or peripheral blood stem cell transplant Have known diagnosis of human immunodeficiency virus infection or active viral hepatitis; viral testing is not required History of alcohol consumption exceeding 2 standard drinks per day on average (1 standard drink = 14 grams of alcohol). Alcohol consumption will be prohibited 48 hours before screening and throughout the entire the Main Treatment Period Use of tobacco- or nicotine-containing products within 3 months of enrollment Is a female patient who is unwilling, if not postmenopausal or surgically sterile, to abstain from sexual intercourse or employ highly effective contraception from the time of informed consent and for until at least 6 months after the last dose of study drug. Males who are unwilling, if not surgically sterile, to abstain from sexual intercourse or employ highly effective contraception from the time of informed consent and for at least 90 days after the last dose of study drug. Is a female patient who is pregnant, as documented by a serum beta human chorionic gonadotropin (β-hCG) pregnancy test consistent with pregnancy obtained within 7 days before the first dose of study drug. Patients with β-hCG values that are within the range for pregnancy but are not pregnant (false positives) may be enrolled with written consent of the Sponsor after pregnancy has been ruled out. Females of nonchildbearing potential (postmenopausal for more than 12 months, bilateral tubal ligation, bilateral oophorectomy, or hysterectomy) do not require a serum β-hCG test. Female who is breastfeeding Have a prior or ongoing clinically significant illness, medical condition, surgical history, physical finding, or laboratory abnormality that, in the Investigator's opinion, could affect the safety of the patient, alter the absorption, distribution, metabolism or excretion of the study drugs, or impair the assessment of study results.