Posts

Showing posts with the label GraphQL

Extending Edge GraphQl Schema To Support Custom Fields In XM Cloud

Hello everyone! In this blog, we'll explore how to extend the GraphQL schema to support custom fields. In XM Cloud, when using the preview endpoint and running a search GQL query, all item versions are returned rather than just the latest ones. This can be challenging for authors who need to verify results in the page builder, as it relies on the preview endpoint for executing GQL queries. In this blog, we will add _latestversion to supported field types in GQL schema. We will extend Sitecore.Services.GraphQL.EdgeSchema.Services.SearchService . Below is the code for your references. namespace Foundation.Services { using System; using System.Collections; using System.Linq.Expressions; using System.Reflection; using Sitecore; using Sitecore.Services.GraphQL.Content.GraphTypes.ContentSearch; using Sitecore.Services.GraphQL.EdgeSchema.GraphTypes.Search.Models; using Sitecore.Services.GraphQL.EdgeSchema.Services; using Sitecore.Services.GraphQL.EdgeSchema.S...

Create and Fetch Content From Sitecore Content Hub One using GraphQL and React

Image
Hello everyone, In this blog, we will see overview of Sitecore Content Hub One product its benefits, features etc. This blog will walkthrough below listed points. Overview Features Content Hub One Dashboard Creating Taxonomy Creating Content Type Uploading New Media Creating Content Items From Content Type Getting GraphQL Token Creating Sample React Application To Read the Content from Content Hub One Overview Sitecore Content Hub One is a powerful platform. It is designed to centralize and streamline content creation, management, and distribution across various channels.Focuses on delivering content via APIs, enabling seamless integration with various front-end frameworks.Hosted in the cloud, offering scalability, automatic updates, and reduced infrastructure management.Provides flexible APIs and SDKs for developers to integrate and build custom solutions efficiently. Features Headless Content Management : Allows content to be delivered via APIs to any front-end or platfor...

Steps to Generate Access Token for Authoring API Endpoint in XM Cloud

Image
Hello everyone, In this blog we will understand, how to get access token which is must for interacting with Authoring API endpoint. As we all know, to work with preview endpoint in XM Cloud, we required sc_apikey which we can get from Sitecore. But we cannot use the same when working with Authoring API endpoint. We will require an access token for the same. So follow below steps to implement the same. Step 1 : Login to you XM Cloud Instance and click on XM Cloud Deploy APP. Step 2 : Click on Credentials in left side panel. Step 3 : Click on Create Credentials.A popup will come up. Fill the details as shown in below figure. Step 4 : Another popup will come up which will show you generated client id and client secret.Copy you client secret as will not be accessible once popup us closed. Step 5 : Now we are ready with client id and client secret. It's time to get the access token.Open Powershell in administrator mode and run below command.The placeholder {0} represent the clie...

Understanding Search Query With Pagination Using GraphQL In XM Cloud

Image
Hello Everyone, In this blog we will see how we can implement search query using GraphQL and implement pagination.GraphQL uses cursor based system to handle pagination whenever we execute a search query. We will see this in action. Let's understand this with a common use-case which every developers encounters. We are having Blog pages or Article pages. We want to get all blogs or articles based on some conditions. The blogs or articles should be sorted based on published date. At first, we just want to show n number of items from the result. Then on load more, we need to show the remaining items. Let's jump quickly into action. We will open GraphQL IDE and dive into writing the query. I am using local XM Cloud. Required thing to execute query. GraphQL IDE : "https://xmcloudcm.localhost/sitecore/api/graph/edge/ide" Api Key: We can get it from Sitecore instance under mentioned path. Path: /sitecore/system/Settings/Services/API Keys. In above image, it give...

More GraphQL Query Example In Sitecore JSS

Image
Hello everyone. In this blog we will see more example of writing GraphQL queries. This is continue part of my previous blog which you can find here So let's start without wasting any extra time. Below is the Sitecore structure which we will be using in our case. Let me give you an overview. We are having going to read children of Social Links folder. There are links item created from two different template. One is Social Link and another one is Footer Link. This is just for example purpose. Social Link template has one Image field named as logo. Below is the screenshot for your reference. Reading Children of Item passed as query parameter in GraphQL If you see above query, we are passing datasource and language as Paramter. Then we are calling children which is responsible for getting all Sitecore items under result object.We are just showing the template name and item name from the result Reading Children of of Item passed as Query in GraphQL with template id filter If y...

Playing with GraphQL Query with Sitecore Headless Next JS

Image
Hello Everyone, In this blog let's try to understand some basic GraphQL query that we can use while working in Sitecore Headless Project. I just started learning GraphQL, so thought of sharing my learning with you with some practical scenario that we can encounter.In this blog we will see to fetch normal fields and Multilist field using GraphQL. So Lets get straight to the Point. Imagine a scenario where we are reading Tiles component. We need to show list of Tile along with Tile Header. In this scenario, most of the time we will create a datasource item. That item will have two fields one will be Tile Header and another will be TilesList which will be a multilist field. Also on Top of that, if we want to get some data from Page Item(ex.Home page) like Page Title and Page Description, how we can use GraphQL to get all these datas. Below images are representing the Sitecore CMS structure for the same. TileList Datasource Item Tile Item Home Page Item Now lets see how we c...