GraphQL explained in 2 minutes

GraphQL was created internally by Facebook in 2012 and has become increasingly popular over the last years. This article will cover the basics of what GraphQL is. You will also learn how GraphQL compares with other query languages such as GROQ, and learn how to start testing GraphQL on a project.

API Query Illustration

What is GraphQL?

GraphQL is a pattern and an open-source query language for API’s connected to data, consisting of a type system, query language, execution semantics, static validation, and type introspection.

GraphQL enables developers to get the exact information they need in a flexible way, by letting the client define the structure of the data required. By using GraphQL, developers also benefit from the growing GraphQL ecosystem, where new flexible tooling and libraries are added regularly.

Some popular caching and fetch clients for GraphQL include; Apollo , Relay Modern, FetchQL, GraphQL Request, Lokka, Micro GraphQL React and URQL.

Why GraphQL?

GraphQL Benefits

  • Query exactly what you need
  • Improved stability
  • Increased query efficiency
  • Retrieve data in one single request
  • Lower overhead costs related to implementation
  • Use data from any source

GraphQL Alternatives

While GraphQL is becoming increasingly popular, Sanity.io was built with GROQ as the core query language. The idea behind GROQ, is to be able to describe exactly what information your application needs, while enabling ad hoc joining information from several sets of documents, then stitching together a very specific response with only the exact fields you need.

With Sanity.io’s GROQ and GraphQL endpoints, you'll be hard to find a more versatile API offering for structured content.

Read the documentation on how to work with the GraphQL endpoints, or learn more about how to deploy the GraphQL API from the sanity schema.

    I love @sanity_io. You should check them out as well. I've used it with React in a few projects, and it's really smooth. Their GraphQL-like query language is also a big plus.

    Start querying content with GraphQL