Posts

Showing posts from September, 2024

Sitecore GraphQL Mutations: A Complete Guide

  Introduction While queries handle data retrieval in GraphQL, mutations are responsible for creating, updating, and deleting content in Sitecore. Let's explore how to effectively use Mutations in Sitecore. 1. Create Mutation: mutation CreateItem {   createItem(     name: "New Item to be Created"     template: "{4330C04F-5CAA-4E93-A2B2-634900395E51}"     parent: "{C081F940-3F38-4E10-8F43-B80AA63BC1BA}"     language: "en"     fields: [       { name: "title", value: "'New Item Created with Mutations'" }       {         name: "subtitle"         value: "'This is Sitecore New Item Created with Mutations'"       }     ]   ) {     path     id   } } In this example: createItem is a mutation function that creates a new item. name is the name of the new item. parentId is the ID of the parent item under which...

Getting Started with GraphQL Queries in Sitecore: A Practical Guide

Image
Introduction GraphQL in Sitecore provides a powerful and flexible way to interact with content programmatically. In this guide, we'll explore how to set up GraphQL in Sitecore and implement various query operations for building efficient headless applications. Sitecore GraphQL API framework: •        Queries (reading data) •        Mutations (altering data) •        Subscriptions (subscribing to real-time updates of data) Setting Up GraphQL in Sitecore •         Navigate to the `App_config` folder in your Sitecore root directory •         Locate the `Services.GraphQL` folder •        Rename the file “Sitecore.Services.GraphQL.Content.Master.config.example” to “Sitecore.Services.GraphQL.Content.Master.config”. Add Authentication Enable GraphQL using API Key •        Open AppConfig\Sitecor...