Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

GraphQL

< >

GraphQL is a query language created in 2012 by Lee Byron.

#58on PLDB 12Years Old 1Repos
Homepage · Leet Sheet · Blog · Wikipedia · Subreddit · Twitter · FAQ · Release Notes · Docs

GraphQL is a data query language developed internally by Facebook in 2012 before being publicly released in 2015. It provides an alternative to REST and ad-hoc webservice architectures.. It allows clients to define the structure of the data required, and exactly the same structure of the data is returned from the server. Read more on Wikipedia...


Example from hello-world:
{ "Hello World" }
Example from Linguist:
# Copyright (c) 2015, Facebook, Inc. # All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. schema { query: QueryType mutation: MutationType } type Foo implements Bar { one: Type two(argument: InputType!): Type three(argument: InputType, other: String): Int four(argument: String = "string"): String five(argument: [String] = ["string", "string"]): String six(argument: InputType = {key: "value"}): Type } interface Bar { one: Type four(argument: String = "string"): String } union Feed = Story | Article | Advert scalar CustomScalar enum Site { DESKTOP MOBILE } input InputType { key: String! answer: Int = 42 } extend type Foo { seven(argument: [String]): Type } directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
GraphQL Keywords
null true false query mutation subscription extend schema directive scalar type interface union enum input implements fragment on

Language features

Feature Supported Example Token
Comments # A comment
Line Comments # A comment #
hasIds # The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable. query { hero { name } droid(id: "2000") { name } }
Lists
Union Types union SearchResult = Human | Droid | Starship
Strings "
Integers
Interfaces interface Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! } type Human implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! starships: [Starship] totalCredits: Int } type Droid implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! primaryFunction: String }
Floats
Enums enum Episode { NEWHOPE EMPIRE JEDI }
Booleans true false
Case Insensitive Identifiers X
Semantic Indentation X

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v154.3.0