GraphQL API in Sitecore v9.1





To access content and items from Sitecore we have another option called Grapth API in sitecore 9.1. To configure Graph QL first add end points in patch file placed at App_Config\..
<endpoints>
<master url="/sitecore/api/graph/items/master" type="Sitecore.Services.GraphQL.Hosting.GraphQLEndpoint, Sitecore.Services.GraphQL.NetFxHost" resolve="true">
                        <url>$(url)</url>
            </master>
</endpoints>

Now type below url in browserto access Graph API

In my case it was http://jss.9dot1.sc/sitecore/api/graph/items/master as in below screen shot.
Here default GraphQL window is open in browser with available schema and query insformation at top right corner in docs link.



I applied query on same API to get data from sitecore and getting below result.


Query:

{  item(path: "/sitecore/templates") {
    id
    path
    children {       name     }
    template {        fields {         name       }     }
  } }
 




Output:






With the help of GraphQL API we can get content in JSS app and provide it to other UI framework as well.

Happy Learning!!!

Comments

Popular posts from this blog

Error : DependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.adobe.aem:uber-jar:jar:apis -> version 6.3.0 vs 6.4.0

Operators in Asterisk with Linux

ERROR Exception while handling event Sitecore.Eventing.Remote.PublishEndRemoteEventException: System.AggregateExceptionMessage: One or more exceptions occurred while processing the subscribers to the 'publish:end:remote'