← Back to blog

Sitecore GraphQL with Angular: From REST to GraphQL

2026-10-06

In the first two articles of this series, we looked at the architecture of Sitecore JSS with Angular and then explored how the Sitecore Layout Service delivers page layout and component data to an Angular application.

Now let's take the next step:

GraphQL.

GraphQL has become an important part of modern Sitecore headless development. Sitecore JSS provides GraphQL services and clients, and the JSS Layout API can retrieve layout information through GraphQL as well as REST.

But there is an important distinction:

Using GraphQL with Sitecore is not simply about replacing a REST URL with a GraphQL URL.

There are different ways GraphQL can participate in a JSS application, and choosing the right approach depends on what your component needs.

In this article, we'll explore:

  • What GraphQL is
  • REST vs GraphQL in Sitecore
  • How GraphQL fits into JSS
  • GraphQL Layout Service
  • Connected GraphQL
  • Integrated GraphQL
  • Angular implementation
  • Datasource queries
  • Query optimization
  • Error handling
  • When to use each approach
  • Common mistakes
  • A practical architecture

1. What Is GraphQL?

Before looking at Sitecore, let's quickly understand GraphQL.

With a traditional REST API, the server generally determines the shape of the response.

For example:

GET /api/products/123

The response might contain:

{
  "id": "123",
  "name": "Product A",
  "description": "Product description",
  "price": 100,
  "category": "Electronics",
  "createdDate": "2026-01-01",
  "updatedDate": "2026-01-10"
}

But your Angular component might only need:

name
price

You still received the other fields.

GraphQL takes a different approach.

The client describes the data it needs.

query {
  product {
    name
    price
  }
}

The response contains the requested fields.

{
  "data": {
    "product": {
      "name": "Product A",
      "price": 100
    }
  }
}

This gives frontend developers more control over the shape of the data they consume.

2. REST vs GraphQL

Let's compare the two.

RESTGraphQL
Multiple endpointsUsually a GraphQL endpoint
Server determines response structureClient specifies requested fields
Can lead to over-fetchingCan reduce unnecessary fields
Simple HTTP modelQuery-based model
Easy to understand initiallyRequires schema/query understanding
Different resources often use different endpointsRelated data can often be requested together

But GraphQL isn't automatically better for every situation.

The right question is:

Does GraphQL solve a real problem in this application?

That question becomes especially important in Sitecore.

3. Where Does GraphQL Fit in Sitecore JSS?

Let's revisit the architecture from Blog 2.

With REST:

Angular
REST Layout Service
Sitecore
Layout JSON
Angular Components

With GraphQL:

Angular
GraphQL
Sitecore GraphQL Endpoint
GraphQL Response
Angular Components

Sitecore's JSS ecosystem supports GraphQL services for scenarios including layout and dictionary data. Current Sitecore documentation also describes Experience Edge for XM and the Sitecore Edge Preview GraphQL endpoint as supported GraphQL endpoints for JSS scenarios.

The JSS Layout API abstracts the underlying data-fetching implementation, so applications can consume layout information without having to implement every low-level detail themselves.

4. Three Important GraphQL Approaches

When discussing GraphQL with Sitecore JSS, I find it useful to separate three concepts.

  • Sitecore + GraphQL
    • GraphQL Layout Service
      • Layout
    • Connected GraphQL
      • Custom Data
    • Integrated GraphQL
      • Component Data

These approaches solve different problems.

Let's look at each one.

5. GraphQL Layout Service

The first approach is using GraphQL as the delivery mechanism for layout data.

Conceptually:

Angular
GraphQL Layout Service
Sitecore
  • Route
  • Placeholders
  • Renderings
  • Component Data
GraphQL Response

Sitecore provides a GraphQLLayoutService abstraction for fetching layout data. The current JSS documentation shows configuring this service with a GraphQL client factory and then calling fetchLayoutData().

A simplified example:

import { GraphQLLayoutService } from '@sitecore-jss/sitecore-jss';

export const layoutService = new GraphQLLayoutService({
  clientFactory,
  siteName: 'my-site'
});

Then:

layoutService
  .fetchLayoutData('en')
  .then(data => {
    console.log(data);
  });

The exact configuration varies by Sitecore/JSS version and application architecture.

The important concept is:

GraphQL
Layout Service
Sitecore Page Layout

6. Angular and GraphQL Layout Data

In an Angular JSS application, the layout data eventually feeds the same rendering architecture we discussed in the previous article.

Sitecore
GraphQL Layout Service
Layout Data
JSS Angular
Placeholder
Component Mapping
Angular Component

The Angular application doesn't need to understand how Sitecore internally stores the page.

It consumes the layout contract.

7. Example: Sitecore Page

Suppose our Sitecore page looks like this:

  • Home
    • main
      • Hero
      • FeatureList
      • PromoBanner

The Angular application eventually needs information such as:

  • main
    • Hero
    • FeatureList
    • PromoBanner

GraphQL can be used to retrieve the layout information required by the JSS application.

The resulting flow is:

Sitecore Page
GraphQL Layout Service
Layout Data
Angular Placeholder
Dynamic Components

This is closely related to the Layout Service architecture from Blog 2.

The major difference is how the data is delivered.

8. Connected GraphQL

Now let's look at another approach.

Imagine your component needs additional data that isn't simply the standard layout/datasource data.

For example, you have a Product component that needs:

  • Sitecore Content
  • Product API
  • Related Products
  • Category Information

Instead of putting all of that into the initial Layout Service response, you might execute a separate GraphQL query from the application.

Conceptually:

  • Angular
    • Layout Service
    • GraphQL API
      • Additional Data

This is often referred to as connected GraphQL in JSS discussions.

Sitecore's documentation describes connected GraphQL as making direct HTTP requests to a Sitecore GraphQL endpoint using a GraphQL client library.

9. Angular Connected GraphQL Example

Suppose we have an Angular service:

import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class ProductService {

  getProducts() {
    // GraphQL request
  }

}

A GraphQL query might look like:

query GetProducts {
  products {
    items {
      id
      name
      price
    }
  }
}

The Angular service can send the query through a GraphQL client.

The exact client configuration depends on the application. Modern Sitecore JSS Angular applications can use GraphQL tooling such as Apollo Angular where appropriate; current JSS Angular upgrade documentation, for example, lists apollo-angular and graphql among the relevant dependencies in the Angular JSS stack.

10. Why Would We Use Connected GraphQL?

Consider a component that initially renders:

Product Name
Product Image
Product Description

Then, after the user selects a category:

Fetch related products

The second request is state-driven.

That makes connected GraphQL a better fit than trying to include everything in the initial layout request.

The flow becomes:

Initial Page
Layout Service
Render Component
User Interaction
GraphQL Request
Updated Data

This is particularly useful for dynamic experiences.

11. Integrated GraphQL

Now we reach one of the most interesting Sitecore JSS concepts:

Integrated GraphQL.

With integrated GraphQL, a GraphQL query can be associated with a Sitecore rendering.

The query executes as part of the layout data process, and the resulting data becomes part of the component's layout data.

Sitecore describes this as reshaping the component data returned by Layout Service into the result of a GraphQL query.

Conceptually:

Sitecore Rendering
Integrated GraphQL Query
Layout Service
Component Data
Angular

This is different from connected GraphQL.

12. Connected vs Integrated GraphQL

This distinction is extremely important.

Connected GraphQL

Angular
GraphQL Client
GraphQL Endpoint
Data

The Angular application makes the query.

Integrated GraphQL

Sitecore Rendering
GraphQL Query
Layout Service
Component Data
Angular

Sitecore executes the query as part of the layout process.

13. When Should We Use Integrated GraphQL?

Integrated GraphQL can be useful when a component needs data that goes beyond the standard datasource fields.

For example:

  • Datasource
    • Title
    • Description
    • Related Items
      • Item A
      • Item B
      • Item C

A standard datasource response may not provide exactly the shape your component needs.

An integrated GraphQL query can shape the data specifically for that component.

Sitecore recommends integrated GraphQL when a component requires more data than its normal datasource template fields provide, or when you want to avoid adding a client-side GraphQL dependency.

Imagine a Sitecore component called:

RelatedArticles

Its datasource contains:

  • Title
  • Article IDs

But the frontend needs:

  • Title
  • URL
  • Image
  • Author
  • Publication Date

Instead of returning a large datasource structure, the component can use an integrated GraphQL query to shape the data it needs.

Conceptually:

query RelatedArticles(
  $datasource: String!
) {
  item(path: $datasource) {
    children {
      results {
        name
        url {
          path
        }
        fields {
          name
          value
        }
      }
    }
  }
}

The exact schema depends on your Sitecore GraphQL endpoint.

The important architectural idea is:

Sitecore
Component GraphQL Query
Precisely Shaped Component Data
Angular

15. Why Data Shaping Matters

Imagine a component only needs:

{
  "title": "Product A",
  "image": "/images/product-a.jpg",
  "url": "/products/product-a"
}

But the API returns:

{
  "title": "...",
  "description": "...",
  "metadata": "...",
  "author": "...",
  "created": "...",
  "updated": "...",
  "permissions": "...",
  "relatedItems": "...",
  "marketingData": "..."
}

The component now receives much more information than it needs.

GraphQL gives you an opportunity to define a more focused data contract.

All Data
Large Response
Required Data
Focused Query
Angular Component

However, query efficiency matters. A poorly designed GraphQL query can be more expensive than a simple REST request.

GraphQL is a tool—not automatically a performance solution.

16. GraphQL Query Example

Let's create a simple conceptual query.

Suppose our component needs:

  • Product name
  • Product description
  • Product image

We could request:

query Product($path: String!) {
  item(path: $path) {
    name
    fields {
      name
      value
    }
  }
}

The response could look like:

{
  "data": {
    "item": {
      "name": "Product A",
      "fields": [
        {
          "name": "Title",
          "value": "Product A"
        },
        {
          "name": "Description",
          "value": "Product description"
        }
      ]
    }
  }
}

Angular can then transform the result into a component-friendly model.

17. Create a TypeScript Model

Instead of passing raw GraphQL data throughout the application, define a model.

export interface Product {
  name: string;
  description: string;
  imageUrl?: string;
}

Then map the response:

function mapProduct(data: any): Product {
  return {
    name: data.name,
    description: data.fields?.find(
      (field: any) => field.name === 'Description'
    )?.value
  };
}

Now the component works with:

Product

instead of:

GraphQLResponse

This separation is especially useful in larger Angular applications.

18. Angular Service Architecture

I recommend keeping GraphQL calls outside components.

Avoid:

  • ProductComponent
    • GraphQL Query
    • Response Mapping
    • Error Handling
    • UI

Instead:

ProductComponent
ProductService
GraphQL Client
Sitecore

Example:

@Injectable({
  providedIn: 'root'
})
export class ProductService {

  getProduct(path: string) {
    // execute GraphQL query
    // map response
    // return Product
  }

}

Then:

export class ProductComponent {

  product$ = this.productService.getProduct(
    '/sitecore/content/MySite/Home/Product'
  );

  constructor(
    private productService: ProductService
  ) {}

}

And:

<div *ngIf="product$ | async as product">

  <h2>{{ product.name }}</h2>

  <p>{{ product.description }}</p>

</div>

The component remains focused on presentation.

19. GraphQL Error Handling

GraphQL introduces another consideration.

An HTTP request can return successfully while the GraphQL response contains errors.

For example:

{
  "data": null,
  "errors": [
    {
      "message": "Field not found"
    }
  ]
}

Therefore, don't assume:

HTTP 200 = everything succeeded

Your GraphQL layer should handle:

  • Network Error
    • Authentication
    • Timeout
    • Server Error
  • GraphQL Error
    • Invalid Query
    • Missing Field
    • Authorization
    • Resolver Error

A centralized error strategy is preferable.

20. GraphQL Variables

Avoid building queries by concatenating strings.

For example, avoid:

const query = `
  query {
    item(path: "${path}") {
      name
    }
  }
`;

Instead, use variables.

query GetItem($path: String!) {
  item(path: $path) {
    name
  }
}

Then:

const variables = {
  path: '/sitecore/content/MySite/Home'
};

This makes the query easier to reuse and maintain.

21. Avoid Over-Fetching

One of the biggest advantages of GraphQL is that the client can request specific fields.

For example, don't request:

query {
  item {
    *
  }
}

when the component only needs:

query {
  item {
    name
  }
}

A good GraphQL query should answer:

What is the minimum data this component needs?

This is particularly important for components rendered repeatedly.

For example:

  • Product Listing
    • Product Card
    • Product Card
    • Product Card
    • Product Card
    • Product Card

If each card retrieves unnecessary data, the total payload can grow quickly.

22. Avoid the “One Giant Query”

Another common mistake is creating one enormous GraphQL query for the entire application.

For example:

  • Home Page
    • Header
    • Hero
    • Navigation
    • Product List
    • Recommendations
    • Footer
    • Analytics

and trying to retrieve everything with:

ONE HUGE GRAPHQL QUERY

This can make the system difficult to:

  • Maintain
  • Debug
  • Cache
  • Optimize
  • Change

Instead, think about data ownership.

HeaderHeader Data
HeroHero Data
Product ListProduct Data
FooterFooter Data

Keep queries close to the component/data responsibility where appropriate.

23. Integrated GraphQL vs Connected GraphQL

Let's compare them directly.

FeatureIntegrated GraphQLConnected GraphQL
Query executedDuring layout/data generationFrom application
Client-side GraphQL library requiredNoUsually yes
Part of initial layout dataYesNot necessarily
Good for component-specific dataYesYes
Dynamic state-driven requestsNot idealGood
MutationsNot supportedBetter suited
SubscriptionsNot supportedBetter suited
Pagination/cursorsNot recommendedBetter suited
Long-running queryCan delay renderingCan be deferred

Sitecore's current documentation specifically recommends avoiding integrated GraphQL for cases involving mutations, subscriptions, pagination/cursors, or additional queries triggered by client-side state changes; connected GraphQL is better suited to those scenarios.

24. When Should You Use What?

My practical decision tree would be:

  • Do you need Sitecore layout data?
    • YES
      • Use JSS Layout API (REST / GraphQL)
        • Only standard layout/data
          • Standard Layout Data
        • Custom component data required? (YES)
          • Static during initial load?
            • Integrated GraphQL
          • Dynamic / state-driven?
            • Connected GraphQL

This is not a strict rule, but it is a useful starting point.

25. GraphQL and Experience Edge

For modern Sitecore headless architectures, GraphQL becomes especially relevant with Experience Edge.

A simplified architecture:

Sitecore
Publish
Experience Edge
GraphQL API
Angular / JSS
Browser

Sitecore documents Experience Edge for XM as a read-only GraphQL schema designed for common headless content-delivery scenarios.

This architecture is particularly useful when the frontend is decoupled from the Sitecore content management environment.

26. Security Considerations

GraphQL does not eliminate security concerns.

You still need to consider:

  • API authentication
  • API keys
  • Permissions
  • Environment configuration
  • Query complexity
  • Rate limiting
  • Sensitive data exposure
Never put secrets into Angular code simply because you're using GraphQL.

Remember:

Angular
Browser
Anything shipped to browser
Potentially visible to users

Client-side configuration should therefore be treated as public.

Sensitive operations should remain server-side.

27. Performance Considerations

GraphQL can improve data efficiency, but performance depends on the query and backend implementation.

Consider:

Query size

Request only what is required.

Number of requests

Avoid unnecessarily splitting data into many requests.

Query complexity

A small-looking GraphQL query can still trigger expensive backend operations.

Caching

Consider caching strategies at the appropriate layer.

Initial rendering

Don't block initial rendering with expensive queries when the data can be loaded later.

Repeated components

Be especially careful with GraphQL queries executed for many instances of the same component.

For example:

100 Product Cards
100 GraphQL Requests

is usually a warning sign.

Prefer a query/data model that can retrieve the required collection efficiently.

28. Debugging GraphQL

When a GraphQL-driven component doesn't work, use this flow:

Component Not Working
Is GraphQL Request Sent?
Check Network Tab
Is Query Correct?
Check GraphQL Variables
Check Response
  • data
  • errors
Check Angular Mapping
Check Component Model
Check Template

If possible, test the query independently using the GraphQL tooling available for your Sitecore environment.

This helps separate:

Sitecore / GraphQL Problem

from:

Angular Problem

29. A Real-World Architecture

For a larger Angular + Sitecore application, I would structure the data layer like this:

AngularLayout ServiceApplication ServicesSitecoreGraphQLREST APIData ModelsAngular Components

This architecture keeps responsibilities separated.

A practical project structure could look like:

  • src
    • app
      • components
        • hero
        • product-list
        • related-articles
      • services
        • sitecore
          • layout.service.ts
        • graphql
          • graphql-client.service.ts
          • product.service.ts
          • article.service.ts
      • models
        • product.model.ts
        • article.model.ts
      • shared
    • graphql
      • queries
        • product.graphql
        • articles.graphql
      • fragments
        • product.fragment.graphql

The exact structure should be adapted to your project, but the principle is important:

Keep GraphQL infrastructure separate from presentation components.

31. GraphQL Fragments

As an application grows, fragments can make queries easier to maintain.

For example:

fragment ProductFields on Product {
  id
  name
  price
  image
}

Then:

query GetProducts {
  products {
    items {
      ...ProductFields
    }
  }
}

This helps maintain consistency when the same data structure is needed in multiple queries.

32. Don't Introduce GraphQL Just Because It Is Modern

This is perhaps the most important lesson.

GraphQL is powerful, but introducing it everywhere can also add complexity.

Before using GraphQL, ask:

Do I need flexible data selection?
Do I need related/nested data?
Do I need a custom data shape?
Do I need client-driven queries?
Would GraphQL simplify the problem?

If the answer is no, the standard Layout Service response may already be sufficient.

Sitecore's documentation similarly recommends integrated GraphQL selectively—for example, when standard datasource fields are insufficient—and advises against it for scenarios better handled by connected GraphQL.

33. Common Mistakes

Mistake 1: Thinking GraphQL Automatically Improves Performance

GraphQL can reduce unnecessary data transfer, but a complex query can still be expensive.

Think:

Better Query
+
Better Backend
+
Better Caching
=
Better Performance

Mistake 2: Putting Queries Directly in Components

Avoid turning components into API clients.

Prefer:

Component
Service
GraphQL

Mistake 3: Returning Raw GraphQL Responses Everywhere

Instead of:

component.data.graphql.data.item.fields

create application models.

Product {
  name
  price
  image
}

This keeps components cleaner.

Mistake 4: Using Integrated GraphQL for Everything

Integrated GraphQL is useful, but it is not the answer to every data problem.

For dynamic state-driven queries, mutations, subscriptions, or pagination scenarios, connected GraphQL is generally more appropriate.

Mistake 5: Ignoring Query Complexity

A GraphQL query can look small while causing significant backend work.

Always consider:

Query
Resolvers
Backend Operations
Response

Not just the number of lines in the query.

For an Angular + Sitecore project, I would generally start with:

Step 1

Use the standard JSS Layout API for page composition.

Sitecore
Layout Service
Angular

Step 2

Use standard datasource fields whenever possible.

Datasource
Layout Data
Component

Step 3

Introduce integrated GraphQL when a component needs a custom data shape that the standard layout output doesn't provide.

Datasource
Integrated GraphQL
Component-specific Data

Step 4

Use connected GraphQL when data needs to be retrieved dynamically after the page is loaded.

User Interaction
Angular Service
GraphQL
Updated UI

Step 5

For modern headless delivery, evaluate Experience Edge and its GraphQL endpoint according to the Sitecore architecture you're targeting.

35. Final Architecture

Putting everything together:

SITECOREContentLayoutJSS Layout APIRESTGraphQLLayout ServiceIntegrated GraphQLConnected GraphQLAngular ServicesAngular ComponentsBrowser

36. Key Takeaways

After working through GraphQL with Sitecore JSS, there are a few concepts worth remembering.

1. GraphQL is a data-fetching approach

It doesn't replace the overall JSS architecture.

2. JSS supports GraphQL for layout and other supported data scenarios

The JSS Layout API abstracts REST and GraphQL delivery mechanisms.

3. GraphQL Layout Service and custom GraphQL are different concepts

One focuses on retrieving layout data; the other can retrieve additional application/component data.

4. Integrated and connected GraphQL solve different problems

Integrated

Sitecore
Layout
Component

Connected

Angular
GraphQL
Component

5. Don't use GraphQL everywhere

Use it where it provides a meaningful benefit.

Conclusion

GraphQL gives Sitecore + Angular developers a powerful way to build more controlled and flexible data flows.

But the real value doesn't come from simply replacing REST with GraphQL.

It comes from understanding where GraphQL belongs in the architecture.

A well-designed Sitecore + Angular application might use:

Layout ServicePage Composition
Integrated GraphQLComponent-specific data
Connected GraphQLDynamic application data

Once these responsibilities are separated, the architecture becomes easier to reason about, test, optimize, and maintain.

The most important question isn't:

“Should we use GraphQL?”

It is:

“What data does this component actually need, when does it need it, and which part of the architecture should provide it?”

That mindset leads to better Sitecore solutions than adopting a technology simply because it is newer.

What's Next?

In the next article, we'll move from data delivery to component architecture:

We'll build a reusable component from scratch and explore:

  • Sitecore rendering definitions
  • Datasource templates
  • Angular components
  • JSS component registration
  • Sitecore fields
  • Rendering parameters
  • Reusable components
  • Component composition
  • Authoring considerations
  • Responsive design
  • A complete GitHub POC