Skip to the workspace
Pebellslearn by building
Designing APIs  ›  Lesson

GraphQL, gRPC and SOAP

GraphQL 14 minGraphQL lets clients choose the fields they need from one endpoint, gRPC gives fast typed calls between services, and SOAP is an older XML-based style still found in enterprise systems.

backend / GraphQL, gRPC and SOAP

Explore each scene at your own pace.

01 · The rule

The rule

GraphQL, gRPC and SOAP

REST with JSON is a sensible default, but it is not the only style. The bookshop's mobile app wants exactly three fields per screen, its internal services call each other thousands of times a second, and the old warehouse system speaks only XML. Each of those problems has a style built for it.

The rule

Let the caller decide: flexible clients, fast services, or old contracts.

GraphQL gives clients one endpoint and a query language. The server publishes a schema of types and fields; the client asks for exactly the fields it wants, even across related data, in one request:

query {
  book(id: 42) {
    title
    author { name }
    reviews(first: 3) { rating }
  }
}

The response mirrors the query's shape. That avoids two REST pains: fetching too much (whole objects when you need two fields) and making many round trips (book, then author, then reviews). The costs: HTTP caching is harder because most queries are POSTs to one URL, and the server must guard against very expensive queries.

gRPC is for service-to-service calls. You define the contract in a .proto file; tools generate typed client and server code in many languages. Messages travel as compact binary Protocol Buffers over HTTP/2, and gRPC also supports streaming.

service Pricing {
  rpc GetPrice (PriceRequest) returns (PriceReply);
}
message PriceRequest { int64 book_id = 1; }
message PriceReply   { int64 price = 1; }

It is fast and strictly typed, but browsers cannot call it directly without a proxy, and binary messages are harder to read by eye.

SOAP is an older standard that wraps every call in an XML envelope, described by a WSDL contract. It is verbose, but it is still common in banking, government and enterprise systems. You rarely choose SOAP for something new; you meet it when integrating with a system that already uses it.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.