> This page is for Developer.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bigcommerce.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bigcommerce.com/_mcp/server.

# What is GraphQL?

Plan: Developer Foundations

Lesson 2 of 28 · 15 min

### GraphQL

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.

Developed by Facebook in 2012 and open-sourced in 2015, GraphQL allows clients to define the structure of the data presented in a query and returned from the server, thus preventing excessively large amounts of data from being returned.

GraphQL provides a complete description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time and enables powerful developer tools.

## Benefits of GraphQL

* **Get Predictable Results** - Send a GraphQL query to your API and get exactly what you need, nothing more and nothing less. GraphQL queries always return predictable results. Apps using GraphQL are fast and stable because they control the data they get, not the server.
* **Get Many Resources in a Single Request**- GraphQL queries access not just the properties of one resource but also smoothly follow references between them. While completing a task with typical REST APIs often requires making calls to multiple endpoints, GraphQL APIs get all the data your app needs in a single request. Apps using GraphQL can be quick even on slow mobile network connections.
* **Type System** - GraphQL APIs are organized in terms of types and fields, not endpoints. Access the full capabilities of your data from a single endpoint. GraphQL uses types to ensure Apps only ask for what's possible and provide clear and helpful errors. Apps can use types to avoid writing manual parsing code.

### GraphQL vs REST API

It's important to understand the differences between GraphQL and REST API and how they work together. **Click the tabs** below to explore some of the major differences between the two.

#### Endpoints

REST APIs put different information on different endpoints or paths/URLs. There is an endpoint for products and there is an endpoint for cart. They are different URLs. For this reason, if you are interested in both cart and product information at the same time, you have to run more than one HTTP request because that is how the API is structured.

With GraphQL there is only one single endpoint: `/graphql`

With GraphQL, you can ask more complex questions with a single API request.

"*I want to know about product 1234 and I also want to know about the category tree*"

#### Return ONLY what you need

REST APIs tend to return most properties associated with an object.

If you send a request for a product, the response always returns the product description and the product description can be quite large. If you are only interested in the name and the image, the response has given you too much information.

With GraphQL, you can query for the name and image of a product and you will receive exactly that - the name and the image of the specific product you asked for.

Something to keep an eye on - GraphQL will always return a 200 ok message, even when there is an error.

#### Overfetching

GraphQL requires that each field be requested explicitly. You have to be very specific about every single field that you want to request. For example, in our REST API you would say, "*I'm interested in product ID 123*" and the response would send you most of the fields related to that product.

With GraphQL you have to say, *"I'm interested in product 123 and I want to know the name, the brand, the price, and the sale price, and I want the default image."*

You have to ask for that very explicitly. As a result, the problem of overfetching is erased because you have to be extremely explicit about what you want. One thing to note is that GraphQL queries can get complex very quickly. To avoid over-complex queries, it is important to determine if GraphQL is the right tool to use.

#### Request verbs

While RESTful APIs use the HTTP request verbs (GET, POST, PULL, DELETE), GraphQL only accepts one verb - POST.

## Resources

* [GraphQL Cheatsheet](https://devhints.io/graphql)
* [graphql.org](https://graphql.org/)