આ ત્રણ operation types છે, દરેક schema માં એક root type સાથે mapped છે:
આ ત્રણ operation types છે, દરેક schema માં એક root type સાથે mapped છે:
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 કરી શકે. Sequential નિયમ મહત્વનો છે: એક document માં બે mutations — deposit પછી withdraw — હંમેશા એ જ ક્રમમાં ચાલે છે, જ્યારે બે query fields એકસાથે (concurrently) resolve થઈ શકે.
Interviewers ચકાસે છે કે તમે જાણો છો કે queries parallel અને side-effect-free છે જ્યારે mutations sequential છે, અને subscription ને stateful transport (WebSocket/SSE) ની જરૂર છે. Mutation માંથી updated data પરત કરવો એ વ્યવહારુ વિગત છે જે GraphQL ship કરી ચૂકેલા લોકોને ફક્ત વાંચેલા લોકોથી અલગ પાડે છે.
વિગતવાર જવાબો સાથે IT ઇન્ટરવ્યૂ પ્રશ્નોની લાઇબ્રેરી — જુનિયરથી સિનિયર સુધી.
દાન કરો