0
0
Rest APIprogramming~20 mins

REST vs SOAP vs GraphQL comparison in Rest API - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
API Mastery: REST, SOAP & GraphQL
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Key difference in data fetching between REST and GraphQL
Which statement best describes how REST and GraphQL differ in data fetching?
AREST allows clients to specify exactly what data they want, GraphQL fetches fixed data per endpoint.
BREST fetches fixed data per endpoint, GraphQL allows clients to specify exactly what data they want.
CBoth REST and GraphQL always fetch all data from the server regardless of client request.
DREST and GraphQL both require multiple requests to fetch related data.
Attempts:
2 left
💡 Hint
Think about how flexible the client is in choosing data with each approach.
Predict Output
intermediate
2:00remaining
Output of a SOAP fault response
What is the output when a SOAP service returns a fault response with this XML snippet?
Rest API
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>Invalid request</faultstring>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>
AA timeout error from the server.
BA successful response with requested data.
CA syntax error in the SOAP message.
DAn error indicating 'Invalid request' with fault code 'soap:Client'.
Attempts:
2 left
💡 Hint
Look at the element and its children.
Predict Output
advanced
2:00remaining
GraphQL query result for nested data
Given this GraphQL query, what is the expected JSON response?
Rest API
query {
  user(id: "1") {
    name
    posts {
      title
      comments {
        text
      }
    }
  }
}
A{ "data": { "user": { "name": "Alice", "posts": [ { "title": "Hello", "comments": [ { "text": "Nice post!" } ] } ] } } }
B{ "data": { "user": { "name": "Alice" } } }
C{ "error": "Field 'posts' not found" }
D{ "data": { "user": null } }
Attempts:
2 left
💡 Hint
GraphQL returns exactly the fields requested, including nested objects.
🧠 Conceptual
advanced
2:00remaining
SOAP vs REST protocol characteristics
Which of these is true about SOAP compared to REST?
ASOAP is stateless and uses JSON only, REST is stateful and uses XML only.
BSOAP is simpler and faster than REST for all use cases.
CSOAP uses XML and has built-in standards for security and transactions, REST is more flexible and uses multiple formats.
DSOAP does not support encryption, REST always requires encryption.
Attempts:
2 left
💡 Hint
Think about the protocol and message format differences.
🧠 Conceptual
expert
2:00remaining
Choosing API style for complex client-driven data needs
A mobile app needs to fetch complex, nested data but wants to minimize the number of requests and data size. Which API style is best suited?
AGraphQL, because it allows clients to request exactly the nested data they need in one request.
BSOAP, because it uses XML which is smaller and faster than JSON.
CREST, because it requires multiple endpoints and requests for nested data.
DNone, because all API styles require multiple requests for nested data.
Attempts:
2 left
💡 Hint
Consider how each API style handles nested data and request flexibility.