- Gestión automatizada de sesiones
- Dirígete a cualquier ciudad de 195 países
- Sesiones simultáneas sin límite
GraphQL
TLDR: GraphQL is a query language for APIs. Clients specify exactly which fields they want — no over-fetching or under-fetching. A single endpoint handles all queries, mutations, and subscriptions.
GraphQL was developed internally at Meta (Facebook) in 2012. It was open-sourced in 2015. GraphQL defines a schema that describes all available data and operations. Clients send a query that mirrors the shape of the response they want. The server returns only the requested fields — nothing more.
Core Concepts
- Schema: A typed definition of all available data types and relationships.
- Query: A read operation. Clients specify exactly which fields to return.
- Mutation: A write operation that modifies server-side data.
- Subscription: A real-time operation that pushes updates to the client over WebSocket.
- Resolver: A server-side function that fetches the data for each field in the schema.
- Fragment: A reusable selection of fields that can be shared across multiple queries.
GraphQL vs REST
- Single Endpoint: GraphQL uses one endpoint. REST uses many resource-specific URLs.
- No Over-fetching: GraphQL returns only the requested fields. REST returns the full resource.
- No Under-fetching: GraphQL retrieves nested data in one request. REST often requires multiple round trips.
- Strongly Typed: The GraphQL schema is a contract. REST schemas are often informal or missing.
- Introspection: Clients can query the schema itself to discover available types and fields.
GraphQL and Web Data Collection
Many modern platforms — Shopify, GitHub, Twitter/X — expose GraphQL APIs. Collecting data from these APIs requires sending a POST request with a query in the body rather than a URL path. GraphQL APIs return JSON, just like REST. The response structure mirrors the query exactly, making parsing straightforward. Bright Data’s Web Scraper API can target both REST and GraphQL endpoints to extract structured data.