The APIS Docs
HookDiscordContact Us
  • ☺️Hello, Web3!
  • ↔️About The APIS
    • Introduction
    • Core Team
    • Our Partners
  • 🤖Roadmap
  • 🍦Products
    • 🔍Hook
      • Get Started
        • Explore
        • Calendar
        • Collections Trending
        • Watch List
      • Twitter RSS
      • Chatting /w Community
    • ❄️Data Lake
  • 🤓Academy
    • On-Chain Glossary
      • NFT
      • DeFi
  • ℹ️$API Token Info
    • 🅰️$API Smart Contract Address
    • 🪙Token Economics
      • $API Token Utility
      • $API Token Distribution
      • Dune Analysis
      • Investors
      • FAQs
        • What is API?
        • How do APIs work?
        • What is the API token?
        • Why does API stand out?
        • What does API mean for the crypto industry?
    • 📈Get $API Token
    • ⬆️Listed Exchanges
  • 🤝Get In Touch
    • 🥰Contact Us
    • 🥰Join Us
    • ❓FAQ
  • 📖Docs
    • 🔐Security
      • 📄Security Report by Certik
    • 📄Terms & Conditions
    • 📑Privacy Policy
    • ℹ️Disclaimer
  • 📃Whitepaper
    • Whitepaper
      • 1️⃣1⃣ Background
        • 1.1 Background
        • 1.2 Introduction
      • 2️⃣2⃣ Architecture
        • 2.1 Message Propagation Protocol
        • 2.2 Message Formatting Overview
        • 2.3 APIS Core Contracts
        • 2.4 Governance Contract (GC)
        • 2.5 Dispute Resolution Contract (DRC) Factory
        • 2.6 Optimistic Rollup Contract
      • 3️⃣3⃣ Applications
        • 3.1IDs
        • 3.2 API Token
        • 3.3 Token Distribution, Community Ownership
      • 4️⃣4⃣ Discussion
      • 5️⃣5⃣ Appendix
        • 5.1 REST History and Analysis
        • 5.2 REST APIs in Practice
        • 5.3 Strengths and Weaknesses of REST
        • 5.4 GraphQL History and Analysis
        • 5.5 GraphQL as a ‘Fetching Tree’
        • 5.6 Anatomy of a GraphQL Request
        • 5.7Note on GraphQL Resolvers:
        • 5.8 Direct Comparison
        • 5.9 Weaknesses of GraphQL
      • 6️⃣6⃣ Bibliography
Powered by GitBook
On this page
Edit on GitHub
  1. Whitepaper
  2. Whitepaper
  3. 5⃣ Appendix

5.5 GraphQL as a ‘Fetching Tree’

While the name GraphQL may imply that this API structure optimized for graph databases, this is not actually the case. GraphQL allows server-side developers to model the resources and processes provided by their servers as a Domain Specific Language. Thus, server-side developers can create a querying language that maps specifically to the structure of their database, and force client-side developers to conform to their naming conventions and structure in order to formulate their queries, yet simultaneously allowing client-side developers to execute more efficient queries.

The best way to understand how a GraphQL query is processed is by abstracting away what queries generally look like. Typically, client-side applications are designed in the form of discrete pages, which are seeded with some tiny bit of data, and then perform a cascade of fetches to get the data needed to provide a unique user experience to the end-user. As an example, let’s assume that, on a client-sid web application, a profile page is ‘seeded’ with a user-id, and from that information the web application can reach out to multiple endpoints across the backend server architecture to grab the information necessary to populate the rest of the page. The fundamental insight in the development of GraphQL is that, in most cases, this contingent data fetching forms a tree that is more or less fixed for a given page. Data from early responses contain the keys for subsequent requests (such the address of my profile image in the REST example provided earlier), and the linkages between these requests are usually straightforward. As such, if the client can factor all of these disparate fetches into one spot, encode them as one large fetching tree, and send that fetching tree to the server, the client can receive all of the user’s data in request, eliminating the multiple roundtrips that are often needed with REST APIs, and consequently saving significant bandwidth and latency. Now that we have established this abstraction of a query as a fetching tree, let us examine how the fetching tree defined within GraphQL.

Previous5.4 GraphQL History and AnalysisNext5.6 Anatomy of a GraphQL Request

Last updated 3 years ago

📃
5️⃣