Lavanda Developer Docs
  • Welcome
  • Quickstart
    • Getting Started
    • Versioning
    • API Explorer
  • Concepts
    • Structure & Terms
    • Auth
    • Webhooks
    • API Paradigms
      • Connections
      • Pagination (Cursors)
      • Client Name Header
  • CRM
    • Leads
    • Contacts
    • Companies
    • Institutions
    • Offers
    • Subjects
  • Bookings
    • Bookings
  • Spaces & Inventory
    • Buildings
    • Unit Types
    • Units
  • Availability
    • Availability
  • Pricing
    • Pricing
    • Product
  • Ecommerce
    • Flow
    • Search
    • Checkout
  • Guest Messaging
    • General
  • Finance & Accounting
    • Invoices
    • Payments
  • Tickets
    • Tickets
    • Tasks
    • Charges
  • Users
    • Queries
      • whoami
    • Mutations
  • Legacy
    • README
    • Auth
    • Create Lead
    • Legacy Azure API
Powered by GitBook
On this page
  1. Concepts
  2. API Paradigms

Connections

Welcome to a quick guide that will help you grasp the core concepts of connections, nodes, and edges as they apply to our GraphQL API.

1. What Are They?

Connection: It's the link between data points. In GraphQL, a connection models a one-to-many relationship, and it is the heart of pagination.

Node: Represents an individual piece of data in your dataset. Think of nodes as the primary elements you're trying to fetch.

Edge: Serves as the bridge between connections and nodes. It contains both the node's data and additional information about the connection, like a cursor for pagination.

2. Visual Representation

Imagine a necklace. The necklace itself is the connection. Each bead on it is a node, and the thread passing through each bead is the edge.

3. Why Use This Model?

  • Scalability: This model ensures efficient data fetching, especially when dealing with large datasets.

  • Flexibility: It supports intricate pagination and data fetching patterns, such as infinite scrolling.

  • Consistency: It provides a standardized way to interact with varying datasets.

4. A Simple Query Example

{
  units(first: 5) {
    edges {
      node {
        id
        name
      }
      cursor
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

In this example:

  • We're querying a connection called units to fetch the first 5 properties.

  • Each edge contains a node (actual property data) and a cursor (used for pagination).

  • The pageInfo gives us details about the pagination status.

5. Key Concepts Recap

  • Connection: The whole dataset or its subset.

  • Node: Individual data items you're fetching.

  • Edge: Contains the node and additional info about its position in the dataset.

6. Best Practices

  • While paginating, always use the cursors provided within edges. Manual modifications can lead to unexpected results.

  • Familiarize yourself with the specific fields and data types within nodes relevant to your queries.

PreviousAPI ParadigmsNextPagination (Cursors)

Last updated 10 months ago

You can read more in the specification:

https://relay.dev/graphql/connections.htm