HOME

TheInfoList



OR:

GraphQL is an open-source data query and
manipulation Manipulation may refer to: * Manipulation (psychology) - the action of manipulating someone in a clever or unscrupulous way * Crowd manipulation - use of crowd psychology to direct the behavior of a crowd toward a specific action ::*Internet mani ...
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, Dustin ...
(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 Rest or REST may refer to: Relief from activity * Sleep ** Bed rest * Kneeling * Lying (position) * Sitting * Squatting position Structural support * Structural support ** Rest (cue sports) ** Armrest ** Headrest ** Footrest Arts and ente ...
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 Graph may refer to: Mathematics *Graph (discrete mathematics), a structure made of vertices and edges **Graph theory, the study of such graphs and their properties *Graph (topology), a topological space resembling a graph in the sense of discre ...
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 infinit ...
. 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 In computing, type introspection is the ability of a program to ''examine'' the type or properties of an object at runtime. Some programming languages possess this capability. Introspection should not be confused with reflection, which goes a st ...
. It supports reading, writing (mutating), and subscribing to changes to data (realtime updates – most commonly implemented using Websockets). 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 s ...
format. On 9 February 2018, the GraphQL Schema Definition Language (SDL) became part of the specification.


Example

GET 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 Query by Example (QBE) is a database query language for relational databases. It was devised by Moshé M. Zloof at IBM Research during the mid-1970s, in parallel to the development of SQL. It is the first graphical query language, using visual t ...
* OpenAPI Specification *
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 ligh ...


References


External links

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