GraphQL
   HOME

TheInfoList



OR:

GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. GraphQL was developed internally by
Facebook Facebook is an online social media and social networking service owned by American company Meta Platforms. Founded in 2004 by Mark Zuckerberg with fellow Harvard College students and roommates Eduardo Saverin, Andrew McCollum, Dust ...
(now Meta) in 2012 before being publicly released in 2015. On 7 November 2018, the GraphQL project was moved from Facebook to the newly established GraphQL Foundation, hosted by the non-profit
Linux Foundation The Linux Foundation (LF) is a non-profit technology consortium founded in 2000 as a merger between Open Source Development Labs and the Free Standards Group to standardize Linux, support its growth, and promote its commercial adoption. Addi ...
. Since 2012, GraphQL's rise has closely followed the adoption timeline as set out by Lee Byron, GraphQL's creator. Byron's goal is to make GraphQL omnipresent across web platforms. GraphQL provides an approach to developing web APIs and has been compared and contrasted with REST and other web service architectures. It allows clients to define the structure of the data required, and the same structure of the data is returned from the server. This prevents excessively large amounts of data from being returned, but can impede web caching of query results. The flexibility and richness of the query language also adds complexity that may not be worthwhile for simple APIs. Despite the name, GraphQL does not provide the richness of graph operations that one might find in a full-fledged graph query language such as
SPARQL SPARQL (pronounced " sparkle" , a recursive acronym for SPARQL Protocol and RDF Query Language) is an RDF query language—that is, a semantic query language for databases—able to retrieve and manipulate data stored in Resource Description ...
, or even in dialects of SQL that support
transitive closure In mathematics, the transitive closure of a binary relation on a set is the smallest relation on that contains and is transitive. For finite sets, "smallest" can be taken in its usual sense, of having the fewest related pairs; for infinite ...
. For example, a GraphQL interface that reports the parents of an individual cannot return, in a single query, the set of all their ancestors. GraphQL consists of a type system, query language and execution semantics, static validation, and type introspection. It supports reading, writing (mutating), and subscribing to changes to data (realtime updates – most commonly implemented using
Websockets WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as in 2011. The current API specification allowing web applications ...
). GraphQL servers are available for multiple languages. The result of a single query is returned in
JSON JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other se ...
format. On 9 February 2018, the GraphQL Schema Definition Language (SDL) became part of the specification.


Example

GET Get or GET may refer to: * Get (animal), the offspring of an animal * Get (divorce document), in Jewish religious law * GET (HTTP), a type of HTTP request * "Get" (song), by the Groggers * Georgia Time, used in the Republic of Georgia * Get AS, a ...
request: Response:


Testing

GraphQL APIs can be tested by triggering different requests at the API endpoint, and verifying the correctness of the response. This may be done manually by developers, or automated with testing tools. Tests may also be generated automatically. For example, a request triggered by an existing test case can be mutated to produce a variant, and new requests may be produced through search-based techniques. GraphQL requests arriving at the API endpoint in production may also be used to generate test cases that detect errors in the implementation of the schema.


See also

* Query by Example *
OpenAPI Specification The OpenAPI Specification, previously known as the Swagger Specification, is a specification for a machine-readable interface definition language for describing, producing, consuming and visualizing RESTful web services. Previously part of the S ...
*
Microservices A microservice architecture – a variant of the service-oriented architecture structural style – is an architectural pattern that arranges an application as a collection of loosely-coupled, fine-grained services, communicating through lightwe ...


References


External links

* * Query languages Data modeling languages {{software-stub