GraphQL introspection: schema की जाँच करें और तय करें कि क्या दिखाना है
GraphQL introspection से client API की schema जानकारी—जैसे types, fields, arguments और descriptions—पूछ सकता है। schema और type schema की संरचना खोजते हैं; typename response में object का वास्तविक type बताता है। Schema की खोज development tools और documentation में सहायक है। Production में इसे चालू रखना API के उपयोगकर्ताओं और tools की ज़रूरत पर निर्भर करता है। इसे बंद करने से खोजने की सुविधा घटती है, पर data authorization का स्थान नहीं लेता।
GraphQL introspection से client API की schema जानकारी—जैसे types, fields, arguments और descriptions—पूछ सकता है। __schema और __type schema की संरचना खोजते हैं; __typename response में object का वास्तविक type बताता है। Schema की खोज development tools और documentation में सहायक है। Production में इसे चालू रखना API के उपयोगकर्ताओं और tools की ज़रूरत पर निर्भर करता है। इसे बंद करने से खोजने की सुविधा घटती है, पर data authorization का स्थान नहीं लेता।
Introspection के दो प्रकार अलग समझें
Schema introspection GraphQL meta-fields __schema और __type के ज़रिए उपलब्ध types, fields, descriptions और deprecated स्थिति पूछता है। GraphiQL या IDE इस जानकारी से autocomplete और documentation दे सकते हैं। पूरा introspection query गहराई से nested हो सकता है और बड़ा response बना सकता है।
__typename का काम अलग है: यह Object, Interface या Union परिणाम का वास्तविक object type लौटाता है। Client इससे type के अनुसार अलग व्यवहार कर सकता है या normalized cache रख सकता है। इसे __schema से पूरे schema की सूची बनाने के बराबर न समझें।
query Search($text: String!) {
search(text: $text) {
__typename
... on Product { id name }
... on Review { id rating }
}
}यहाँ __typename बताता है कि हर search परिणाम Product है या Review। GraphQL implementation यह meta-field देता है; developer इसे सामान्य API field की तरह नहीं जोड़ता।
Schema देखने के लिए client __schema पूछ सकता है:
query SchemaTypes {
__schema { types { name } queryType { name } }
}__schema और __type(name: ...) query root से उपलब्ध हैं। Tools __Type.kind और ofType का अनुसरण करके List और Non-Null wrappers समझ सकते हैं तथा field descriptions और deprecated जानकारी पढ़ सकते हैं।
Development और production को अलग तरीके से संभालें
Development के दौरान introspection schema explorer, IDE autocomplete, documentation browser और client-code tools में मदद करता है। Apollo Server का मौजूदा API reference बताता है कि NODE_ENV=production न होने पर यह default रूप से चालू होता है; production में default रूप से बंद रहता है। Apollo GraphOS Router भी default रूप से introspection queries को resolve नहीं करता। दूसरे servers, router versions और configurations के defaults जाँचें।
Production का निर्णय API के प्रकार पर निर्भर है:
**आंतरिक first-party API:** यदि deployed clients build के समय से operations जानते हैं और खुली खोज आवश्यक नहीं है, तो production endpoint पर introspection सीमित करें और tools को registry या build artifact के ज़रिए schema दें।
**सार्वजनिक developer API:** यदि schema खोजना developer experience या contract का हिस्सा है, तो इसे दिखाना उचित हो सकता है। Request/cost limits और authorization लागू करें; संवेदनशील descriptions और आंतरिक types की समीक्षा करें।
**Staging या सीमित environment:** आवश्यकता होने पर authentication या network policy से पहुँच सीमित करें और पुष्टि करें कि configuration production से अपेक्षा के अनुसार अलग है।
Schema की दृश्यता और data access अलग बातें हैं। Introspection API की संरचना दिखाता है, लेकिन resolver के ज़रिए data पढ़ने की अनुमति नहीं देता। इसे बंद करने से API paths, client bundles, errors, documentation या व्यवहार से सभी विवरणों का अनुमान लगाना भी नहीं रुकता। इसे discoverability घटाने वाली परत मानें, authorization का विकल्प नहीं।
बंद करने से पहले
Explorer, GraphQL Playground या IDE plugins जैसे सीधे server से schema पढ़ने वाले tools काम करना बंद कर सकते हैं या autocomplete खो सकते हैं। Apollo schema registry से टीम production endpoint पूछे बिना registered schema देख और प्रबंधित कर सकती है। Version-controlled SDL file या आंतरिक documentation भी विकल्प हैं।
हर environment जाँचें: development में tools schema पढ़ सकें; production में introspection query नीति के अनुसार अस्वीकार हो और सामान्य queries में field/object authorization लागू रहे। Setting के नाम और व्यवहार implementation पर निर्भर हैं; Apollo configuration को दूसरे server पर सीधे न कॉपी करें।
जाँच सूची
कौन से clients और tools runtime introspection पर निर्भर हैं?
API सार्वजनिक developers के लिए है या केवल आंतरिक apps के लिए?
क्या schema descriptions और fields को दिखाने की उपयुक्तता जाँची है?
Production में बंद करने पर registry या SDL विकल्प है?
Data fields के authentication और authorization स्वतंत्र रूप से लागू हैं?
Development, staging और production की पहुँच और settings जाँची हैं?
गहरे introspection और सामान्य operations के लिए resource limits हैं?
स्रोत
[GraphQL की आधिकारिक introspection मार्गदर्शिका](https://graphql.org/learn/introspection/)
[GraphQL सितंबर 2026 विनिर्देश: introspection system](https://spec.graphql.org/September2026/#sec-Introspection)
[Apollo Graph Security: production discoverability का प्रबंधन](https://www.apollographql.com/docs/graphos/platform/security/overview)
[Apollo Server API: introspection का default](https://www.apollographql.com/docs/apollo-server/api/apollo-server)
[Apollo Router YAML configuration: introspection और depth limits](https://www.apollographql.com/docs/graphos/routing/v3/configuration/yaml)
[Apollo production readiness checklist](https://www.apollographql.com/docs/graphos/platform/production-readiness/checklist)