Skip to main content

GraphQL Notes

Introduction to GraphQL

tip

The GraphQL docs are actually excellent and provide good code samples, so i'm not going to duplicate my own code samples here. Instead I will link to relevant documentation pages when possible.

What is GraphQL?

  • A query language for APIs and a runtime for executing those queries.
  • Developed internally by Facebook in 2012 and released publicly in 2015.

Why Use GraphQL Over REST?

  • Flexibility: Clients can specify exactly what data they need.
  • Efficiency: Reduces over-fetching and under-fetching of data.
  • Strong Typing: Schema defines types and relationships in your data.

Core Concepts

Schema

  • The heart of any GraphQL server; defines types and their relationships.
  • Written using GraphQL Schema Definition Language (SDL).

GraphQL > Learn > Schemas and Types

Apollo GraphQL > Tutorials > Schema Definition Language (SDL)

Types

  • Scalar Types: Int, Float, String, Boolean, ID.
  • Object Types: Custom types defined by the schema.
  • Enumeration Types: A special kind of scalar that is restricted to a particular set of allowed values.

GraphQL > Learn > Schemas and Types

Queries

  • Read-only fetches to retrieve data.
  • Clients specify exactly what they need.

GraphQL > Learn > Queries

Mutations

  • Operations that modify data on the server.
  • Similar to queries but used for Create, Update, Delete actions.

GraphQL > Learn > Mutations

Subscriptions

  • Allows clients to subscribe to real-time updates.
  • Uses WebSockets to maintain a persistent connection.

GraphQL > Learn > Subscriptions

Resolvers

  • Functions that resolve a value for a type or field in the schema.
  • Connects schema fields to underlying data sources.

GraphQL > Learn > Execution

Apollo > Docs > Resolvers

Comments

Recent Work

Free desktop AI Chat client, designed for developers and businesses. Unlocks advanced model settings only available in the API. Includes quality of life features like custom syntax highlighting.

Learn More

BidBear

bidbear.io

Bidbear is a report automation tool. It downloads Amazon Seller and Advertising reports, daily, to a private database. It then merges and formats the data into beautiful, on demand, exportable performance reports.

Learn More