နားလည်ထားရမယ့် အချက်
GraphQL schema က self-describing ဖြစ်လို့ special introspection queries (`__schema`, `__type`) ဖြင့် schema structure ကို runtime မှာတောင်း/ဖတ်နိုင်ပါတယ်။ GraphiQL နဲ့ Apollo Sandbox လို in-browser IDE tools တွေက ဒီ introspection data ကို သုံးပြီး autocomplete, inline docs, query validation ကို live ပေးပါတယ်—developer က schema file ကို tab ခြားဖတ်စရာမလိုတော့ပါ။ Production မှာတော့ introspection ကို attacker အတွက် schema map ဖြစ်နိုင်လို့ disable လုပ်လေ့ရှိပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Development environment မှာ Apollo Server ရဲ့ default Sandbox ကနေ Tutorial Platform schema ရဲ့ types အားလုံးကို browse ပြီး `Tutorial` type ရဲ့ fields များကို `__type(name: "Tutorial")` query ဖြင့် တိုက်ရိုက်ကြည့်နိုင်ပါတယ်။ Production deploy မှာတော့ `introspection: false` သတ်မှတ်ထားလေ့ရှိပါတယ်။
အတူတူ စမ်းရေးကြည့်မယ်
query IntrospectTutorialType {
__type(name: "Tutorial") {
name
fields {
name
type {
name
kind
}
}
}
}Introspection query ဖြင့် type တစ်ခုရဲ့ fields များကို runtime မှာ ရှာဖွေနိုင်မည်။၅ မိနစ် စမ်းကြည့်
Apollo Sandbox (သို့) GraphiQL ကိုဖွင့်ပြီး schema တစ်ခုရဲ့ root `Query` type အောက်ရှိ field အားလုံးကို docs panel ဖြင့် ရှာဖွေကြည့်ပါ။
သတိလေးတစ်ချက်
Production API မှာ introspection ကို ဖွင့်ထားခဲ့ရင် schema တစ်ခုလုံး (field names, types, deprecated fields) ကို public exposure ဖြစ်သွားနိုင်ပါတယ်—sensitive internal naming ပါလာရင် သတိထားပါ။
GraphQL — Introspection — GraphQL