Size: 2438
Comment:
|
← Revision 7 as of 2020-10-05 14:47:47 ⇥
Size: 2905
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 7: | Line 7: |
Since GraphQL is a ''specification'', the user can decide between various implementations in different programming languages, almost all of which use JSON to access data. You can find a list containing some of the most popular libraries and services [[https://graphql.org/code/|here]]. | Since GraphQL is only a ''syntax'' that describes how to ask for data, the user can decide between various implementations in different programming languages, almost all of which use JSON to access data. You can find a list containing some of the most popular libraries and services [[https://graphql.org/code/|here]]. |
Line 9: | Line 9: |
Contrary to what the name implies, GraphQL has nothing to do with graph databases like [[https://ad-wiki.informatik.uni-freiburg.de/research/HowTos/WikidataCheatSheet|Wikidata]] or [[https://ad-wiki.informatik.uni-freiburg.de/research/Projects/Neo4j|Neo4j]]. The word "graph" in the name comes from the idea of crawling across the API graph. |
|
Line 20: | Line 22: |
= Example = Queries in GraphQL are like JSON data without the values. For example: |
= Example Query = A query in GraphQL is essentially a JSON without the values. The values are then added in the result. For example: |
Line 27: | Line 29: |
name | title |
Line 40: | Line 42: |
"name": "Programmieren in C++" | "title": "Programmieren in C++" |
Line 44: | Line 46: |
"name": "Information Retrieval" | "title": "Information Retrieval" |
Line 48: | Line 50: |
"name": "Algorithmen und Datenstrukturen" | "title": "Algorithmen und Datenstrukturen" |
Line 59: | Line 61: |
The GraphQL foundation also provides "GraphiQL", a graphical interactive in-browser GraphQL IDE for editing and testing queries. GraphiQL offers syntax highlighting, autocompletion, a documentation explorer, query history and other features. Again, there are libraries in various languages to choose from. | The GraphQL foundation also provides [[https://github.com/graphql/graphiql|GraphiQL]], a graphical interactive in-browser GraphQL IDE for editing and testing queries. GraphiQL offers syntax highlighting, autocompletion, a documentation explorer, query history and other features. Again, there are libraries in various languages to choose from. |
Line 61: | Line 63: |
TODO: Set up a docker container that build a GraphiQL example to play around with. | TODO: Set up a docker container to build a GraphiQL example to play around with. |
Contents
What is GraphQL?
GraphQL ("Graph Query Language") is a specification for a query language that was created by Facebook in 2012 for internal use and publicly open sourced in 2015. It is specifically focused on API development ("A query language for your API") and serves as an alternative to REST-based architectures.
Since GraphQL is only a syntax that describes how to ask for data, the user can decide between various implementations in different programming languages, almost all of which use JSON to access data. You can find a list containing some of the most popular libraries and services here.
Contrary to what the name implies, GraphQL has nothing to do with graph databases like Wikidata or Neo4j. The word "graph" in the name comes from the idea of crawling across the API graph. GraphQL is not tied to a specific schema or structure of the database. It is much less powerful than other query languages and not designed for exploiting the rich semantics of expressive ontologies.
Clients specify the data they need, receiving only what they ask for and nothing more. Thus, it minimizes the amount of data transferred and is particularly useful for mobile apps and websites.
GraphQL serves as a framework for defining your own query language on JSON-like data. GraphQL allows users to define the shape (the "schema") of data that they want to be accessible. This schema defines the semantics and the structure of the queries that are allowed.
Example Query
A query in GraphQL is essentially a JSON without the values. The values are then added in the result. For example:
{ chair { name lectures { title language } } }
This query might return something like
{ "chair": { "name": "Chair of algorithms and data structures" "lectures": [ { "title": "Programmieren in C++" "language": "German" } { "title": "Information Retrieval" "language": "English" } { "title": "Algorithmen und Datenstrukturen" "language": "German" } ] } }
TODO: Explain more how queries work and how the schema is defined.
GraphiQL
The GraphQL foundation also provides GraphiQL, a graphical interactive in-browser GraphQL IDE for editing and testing queries. GraphiQL offers syntax highlighting, autocompletion, a documentation explorer, query history and other features. Again, there are libraries in various languages to choose from.
TODO: Set up a docker container to build a GraphiQL example to play around with.