ये तीन operation types हैं, जिनमें से हर एक schema में किसी root type से मैप होता है:
ये तीन operation types हैं, जिनमें से हर एक schema में किसी root type से मैप होता है:
query GetPost { # read
post(id: "1") { title }
}
mutation AddComment { # write; returns the created object so the client updates its cache
addComment(postId: "1", text: "Nice!") {
id
text
}
}
subscription OnComment { # live: fires every time a comment is added
commentAdded(postId: "1") {
id
text
}
}
Mutations arguments लेते हैं (अक्सर एक input object) और उन्हें प्रभावित data लौटाना चाहिए ताकि client दूसरी request के बिना refresh कर सके। क्रमिक नियम मायने रखता है: एक ही document में दो mutations — पहले deposit फिर withdraw — हमेशा उसी क्रम में चलते हैं, जबकि दो query fields समवर्ती (concurrently) रूप से resolve हो सकते हैं।
Interviewer जाँचते हैं कि आप जानते हैं कि queries समानांतर और side-effect-free होती हैं जबकि mutations क्रमिक होती हैं, और यह कि एक subscription को stateful transport (WebSocket/SSE) की ज़रूरत होती है। किसी mutation से updated data लौटाना वह व्यावहारिक विवरण है जो GraphQL को असल में शिप कर चुके लोगों को उनसे अलग करता है जिन्होंने केवल इसके बारे में पढ़ा है।
विस्तृत उत्तरों के साथ IT इंटरव्यू प्रश्नों की एक लाइब्रेरी — जूनियर से सीनियर तक।
दान करें