Need advice about which tool to choose?Ask the StackShare community!

Apache Thrift

173
242
+ 1
0
GraphQL

33K
27.1K
+ 1
310
Add tool

Apache Thrift vs GraphQL: What are the differences?

Introduction

This article provides a comparison between Apache Thrift and GraphQL, highlighting their key differences.

  1. Declarative vs. Imperative: One of the fundamental differences between Thrift and GraphQL is their approach in defining APIs. Thrift follows an imperative approach where the API is defined using an IDL (Interface Definition Language) and strict contracts are enforced. On the other hand, GraphQL takes a declarative approach where the API is defined using a schema and clients can request the specific data they need.

  2. Type System: Thrift and GraphQL have different type systems. Thrift supports a fixed set of primitive types and allows the definition of complex data structures using structs and unions. GraphQL, on the other hand, has a flexible and extensible type system which allows defining custom scalar types, enums, interfaces, and unions.

  3. Transport Protocol: Thrift uses a binary protocol for data serialization and transportation, resulting in more efficient data transfer with smaller payload size. On the contrary, GraphQL uses HTTP as a transport protocol and the data is typically serialized and transmitted using JSON. This makes GraphQL more accessible and easier to integrate with existing web technologies.

  4. Data Fetching: In Thrift, the server-side defines the available data endpoints, and the client must adhere to those endpoints to fetch the data. In GraphQL, the client has the flexibility to specify the fields and nested data it needs, reducing the over-fetching or under-fetching issues commonly seen in traditional REST APIs.

  5. Efficiency: Thrift is known for its efficiency when it comes to serialization, deserialization, and network transfer, as it leverages a binary protocol. On the other hand, GraphQL introduces a higher level of abstraction, making it less efficient in terms of network transfer and serialization compared to Thrift.

  6. Ecosystem and Adoption: Apache Thrift has been around longer and has a larger ecosystem with support from various programming languages. Thrift is widely used and has been adopted by large companies for building scalable and high-performance APIs, often in distributed systems. GraphQL, although relatively newer, has gained significant popularity with its focus on front-end development and has an active community, making it a promising choice for modern web applications.

In summary, Thrift and GraphQL differ in their approach to API definition, type system, transport protocol, data fetching flexibility, efficiency, and ecosystem/adoption status.

Get Advice from developers at your company using StackShare Enterprise. Sign up for StackShare Enterprise.
Learn More
Pros of Apache Thrift
Pros of GraphQL
    Be the first to leave a pro
    • 75
      Schemas defined by the requests made by the user
    • 63
      Will replace RESTful interfaces
    • 62
      The future of API's
    • 49
      The future of databases
    • 13
      Self-documenting
    • 12
      Get many resources in a single request
    • 6
      Query Language
    • 6
      Ask for what you need, get exactly that
    • 3
      Fetch different resources in one request
    • 3
      Type system
    • 3
      Evolve your API without versions
    • 2
      Ease of client creation
    • 2
      GraphiQL
    • 2
      Easy setup
    • 1
      "Open" document
    • 1
      Fast prototyping
    • 1
      Supports subscription
    • 1
      Standard
    • 1
      Good for apps that query at build time. (SSR/Gatsby)
    • 1
      1. Describe your data
    • 1
      Better versioning
    • 1
      Backed by Facebook
    • 1
      Easy to learn

    Sign up to add or upvote prosMake informed product decisions

    Cons of Apache Thrift
    Cons of GraphQL
      Be the first to leave a con
      • 4
        Hard to migrate from GraphQL to another technology
      • 4
        More code to type.
      • 2
        Takes longer to build compared to schemaless.
      • 1
        No support for caching
      • 1
        All the pros sound like NFT pitches
      • 1
        No support for streaming
      • 1
        Works just like any other API at runtime
      • 1
        N+1 fetch problem
      • 1
        No built in security

      Sign up to add or upvote consMake informed product decisions

      No Stats
      - No public GitHub repository available -

      What is Apache Thrift?

      The Apache Thrift software framework, for scalable cross-language services development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi and other languages.

      What is GraphQL?

      GraphQL is a data query language and runtime designed and used at Facebook to request and deliver data to mobile and web apps since 2012.

      Need advice about which tool to choose?Ask the StackShare community!

      Jobs that mention Apache Thrift and GraphQL as a desired skillset
      What companies use Apache Thrift?
      What companies use GraphQL?
      See which teams inside your own company are using Apache Thrift or GraphQL.
      Sign up for StackShare EnterpriseLearn More

      Sign up to get full access to all the companiesMake informed product decisions

      What tools integrate with Apache Thrift?
      What tools integrate with GraphQL?

      Sign up to get full access to all the tool integrationsMake informed product decisions

      Blog Posts

      GitHubDockerReact+17
      40
      36174
      GitHubPythonNode.js+47
      54
      72284
      What are some alternatives to Apache Thrift and GraphQL?
      gRPC
      gRPC is a modern open source high performance RPC framework that can run in any environment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking...
      Protobuf
      Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
      REST
      An architectural style for developing web services. A distributed system framework that uses Web protocols and technologies.
      Avro
      It is a row-oriented remote procedure call and data serialization framework developed within Apache's Hadoop project. It uses JSON for defining data types and protocols, and serializes data in a compact binary format.
      JSON
      JavaScript Object Notation is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language.
      See all alternatives