GraphQL introspection: schema অনুসন্ধান ও কী প্রকাশ করবেন তা নির্ধারণ
GraphQL introspection-এর মাধ্যমে client API-এর schema-সংক্রান্ত তথ্য—যেমন type, field, argument এবং description—জিজ্ঞাসা করতে পারে। schema ও type schema অনুসন্ধান করে; typename response-এ object-এর নির্দিষ্ট type জানায়। Schema আবিষ্কার উন্নয়ন-সরঞ্জাম ও নথিপত্রে সহায়ক। Production-এ এটি চালু থাকবে কি না, তা API-এর পাঠক ও সরঞ্জামের প্রয়োজনের ওপর নির্ভর করে। এটি বন্ধ করলে আবিষ্কারযোগ্যতা কমে, কিন্তু data authorization-এর বিকল্প হয় না।
GraphQL introspection-এর মাধ্যমে client API-এর schema-সংক্রান্ত তথ্য—যেমন type, field, argument এবং description—জিজ্ঞাসা করতে পারে। __schema ও __type schema অনুসন্ধান করে; __typename response-এ object-এর নির্দিষ্ট type জানায়। Schema আবিষ্কার উন্নয়ন-সরঞ্জাম ও নথিপত্রে সহায়ক। Production-এ এটি চালু থাকবে কি না, তা API-এর পাঠক ও সরঞ্জামের প্রয়োজনের ওপর নির্ভর করে। এটি বন্ধ করলে আবিষ্কারযোগ্যতা কমে, কিন্তু data authorization-এর বিকল্প হয় না।
দুই ধরনের introspection আলাদা করুন
Schema introspection GraphQL meta-field __schema ও __type দিয়ে type, field, description এবং 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 result Product নাকি Review। GraphQL implementation এই meta-field দেয়; developer সাধারণ API field হিসেবে এটি যোগ করেন না।
Schema অনুসন্ধানে client __schema query করতে পারে:
query SchemaTypes {
__schema { types { name } queryType { name } }
}__schema ও __type(name: ...) query root থেকে ব্যবহার করা যায়। Tool __Type.kind ও ofType অনুসরণ করে List এবং Non-Null wrapper বুঝতে এবং field description ও deprecation তথ্য পড়তে পারে।
Development ও production আলাদাভাবে সামলান
Development-এ introspection schema explorer, IDE autocomplete, documentation browser এবং client-code tool-কে সহায়তা করে। Apollo Server-এর বর্তমান API reference বলে, NODE_ENV=production না হলে এটি default-এ চালু; production-এ default-এ বন্ধ। Apollo GraphOS Router-ও default-এ introspection query resolve করে না বলে জানায়। অন্য server, router version ও configuration-এর default যাচাই করুন।
Production সিদ্ধান্ত API-এর ধরন অনুযায়ী নিন:
**অভ্যন্তরীণ first-party API:** deployed client build থেকেই operation জানলে এবং খোলা অনুসন্ধান দরকার না হলে production endpoint-এ introspection সীমিত করুন; registry বা build artifact দিয়ে tool-কে schema দিন।
**সর্বসাধারণের developer API:** schema আবিষ্কার developer experience বা contract-এর অংশ হলে প্রকাশ করা উপযুক্ত হতে পারে। Request/cost limit ও authorization দিন এবং সংবেদনশীল description ও অভ্যন্তরীণ type পর্যালোচনা করুন।
**Staging বা সীমিত পরিবেশ:** প্রয়োজন হলে authentication বা network policy দিয়ে প্রবেশ সীমাবদ্ধ করুন এবং production থেকে প্রত্যাশিত পার্থক্য আছে কি না যাচাই করুন।
Schema দেখা এবং data access আলাদা বিষয়। Introspection API-এর কাঠামো দেখায়, কিন্তু resolver দিয়ে data পড়ার অনুমতি দেয় না। এটি বন্ধ করলেও API path, client bundle, error, documentation বা আচরণ থেকে সব schema তথ্য অনুমান ঠেকানো যায় না। একে authorization-এর বদলে নয়, discoverability কমানোর স্তর হিসেবে দেখুন।
বন্ধ করার আগে
Explorer, GraphQL Playground বা IDE plugin-এর মতো server-এ সরাসরি schema পড়া tool বন্ধ হতে পারে বা autocomplete হারাতে পারে। Apollo schema registry দিয়ে production endpoint query না করেও নিবন্ধিত schema দেখা ও পরিচালনা করা যায়। Version-controlled SDL file বা অভ্যন্তরীণ documentation-ও বিকল্প হতে পারে।
প্রতিটি পরিবেশ যাচাই করুন: development-এ tool schema পড়তে পারে; production-এ introspection query নীতিমতো প্রত্যাখ্যাত হয় এবং সাধারণ query-তে field/object authorization চালু থাকে। Setting-এর নাম ও আচরণ implementation-ভেদে আলাদা; Apollo configuration অন্য server-এ হুবহু ব্যবহার করবেন না।
যাচাই তালিকা
কোন client ও tool runtime introspection-এর ওপর নির্ভর করে?
API কি developer-দের জন্য উন্মুক্ত, নাকি অভ্যন্তরীণ app-এর জন্য?
Schema description ও field প্রকাশযোগ্য কি না পর্যালোচনা করেছেন?
Production-এ বন্ধ করলে registry বা SDL বিকল্প আছে?
Data field-এর authentication ও authorization কি স্বাধীনভাবে প্রয়োগ হয়?
Development, staging ও production-এর প্রবেশাধিকার ও setting যাচাই করেছেন?
গভীর introspection ও সাধারণ operation-এর resource limit আছে?
উৎস
[GraphQL-এর আনুষ্ঠানিক introspection নির্দেশিকা](https://graphql.org/learn/introspection/)
[GraphQL সেপ্টেম্বর ২০২৬ specification: 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: introspection ও depth limit](https://www.apollographql.com/docs/graphos/routing/v3/configuration/yaml)
[Apollo production readiness checklist](https://www.apollographql.com/docs/graphos/platform/production-readiness/checklist)