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

GraphQL

33.1K
27.2K
+ 1
310
TypeORM

571
802
+ 1
78
Add tool

GraphQL vs TypeORM: What are the differences?

Introduction

This document outlines the key differences between GraphQL and TypeORM. GraphQL is a query language and runtime for APIs, whereas TypeORM is an Object Relational Mapping (ORM) library for TypeScript and JavaScript.

  1. 1. Query Language vs ORM Library: The first key difference between GraphQL and TypeORM is their purpose and functionality. GraphQL is primarily a query language that allows clients to efficiently and flexibly retrieve data from an API. It provides a unified interface to retrieve exactly the data that the client requests. On the other hand, TypeORM is an ORM library that facilitates the mapping of database objects to TypeScript or JavaScript classes. It allows developers to interact with databases using object-oriented programming techniques.

  2. 2. Data Retrieval and Manipulation: Another difference is the way data is retrieved and manipulated. With GraphQL, clients can specify the exact data they need by defining a query, and the server responds with only the requested data, eliminating over-fetching and under-fetching issues. In contrast, TypeORM provides APIs and methods for developers to perform various common database operations such as querying, inserting, updating, and deleting records.

  3. 3. Declarative vs Imperative: GraphQL is a declarative language, meaning that clients can specify the desired data structure and shape without needing to explicitly define the steps or commands to retrieve it. The server handles the execution of the query and returns the requested data. TypeORM, on the other hand, follows an imperative approach, where developers write explicit code to interact with the database, specifying the actions to be performed step by step.

  4. 4. Server-Centric vs Client-Centric: GraphQL is a server-centric technology, with the server responsible for processing and executing the client's queries. The server is responsible for resolving fields and relationships, aggregating data from various sources, and returning the result to the client. TypeORM, on the other hand, is a client-centric technology, where developers primarily use the library on the client-side to interact with databases. It provides a set of APIs specifically designed for querying and manipulating data on the client-side.

  5. 5. Execution Control: GraphQL provides fine-grained control over the execution of queries through its resolver functions. Developers can define resolver functions to handle specific fields and relationships, allowing for complex computations, data transformations, and business logic to be performed during the query execution. TypeORM, on the other hand, provides a more limited level of execution control, as the library primarily focuses on mapping database objects to JavaScript or TypeScript classes and executing predefined CRUD operations.

  6. 6. Language Agnostic vs TypeScript/JavaScript: GraphQL is designed to be language-agnostic, meaning it can be used with any programming language. This allows for a wide range of client implementations and backend server integrations. In contrast, TypeORM is specifically designed for TypeScript and JavaScript applications. It provides strong typing, decorators, and other language-specific features that enhance the development experience for projects using these languages.

In summary, GraphQL is a query language for APIs, providing a flexible and efficient way for clients to retrieve data from servers. TypeORM, on the other hand, is an Object Relational Mapping library that maps database objects to TypeScript or JavaScript classes, aiming to simplify database interactions for developers on the client-side.

Get Advice from developers at your company using StackShare Enterprise. Sign up for StackShare Enterprise.
Learn More
Pros of GraphQL
Pros of TypeORM
  • 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
  • 29
    Typescript
  • 11
    Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Ser
  • 9
    Easy setup
  • 8
    Cons of TypeORM
  • 7
    Promise Based
  • 7
    Works in NodeJS, Browser, Ionic, Cordova and Electron p
  • 6
    Support MySQL & MariaDB, PostgreSQL, MSSQL, Sqlite
  • 1
    Support MongoDB

Sign up to add or upvote prosMake informed product decisions

Cons of GraphQL
Cons of TypeORM
  • 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
  • 5
    Completely abandoned by its creator
  • 3
    Too complex for what it does
  • 2
    Doesn't really support native javascript
  • 1
    Not proper/real type safety
  • 1
    Cannot use query on any relation

Sign up to add or upvote consMake informed product decisions

- No public GitHub repository available -

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.

What is TypeORM?

It supports both Active Record and Data Mapper patterns, unlike all other JavaScript ORMs currently in existence, which means you can write high quality, loosely coupled, scalable, maintainable applications the most productive way.

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

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

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

What tools integrate with GraphQL?
What tools integrate with TypeORM?
    No integrations found

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

    Blog Posts

    GitHubDockerReact+17
    40
    36266
    GitHubPythonNode.js+47
    54
    72312
    What are some alternatives to GraphQL and TypeORM?
    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...
    Falcor
    Falcor lets you represent all your remote data sources as a single domain model via a virtual JSON graph. You code the same way no matter where the data is, whether in memory on the client or over the network on the server.
    React
    Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.
    graphql.js
    Lightest GraphQL client with intelligent features. You can download graphql.js directly, or you can use Bower or NPM.
    MongoDB
    MongoDB stores data in JSON-like documents that can vary in structure, offering a dynamic, flexible schema. MongoDB was also designed for high availability and scalability, with built-in replication and auto-sharding.
    See all alternatives