Contents
What is Sitecore GraphQL?
The Sitecore GraphQL API is a generic GraphQL service platform on top of Sitecore. It hosts your data and presents it through GraphQL queries. The API supports real-time data using GraphQL subscriptions. GraphQL has these features: This eliminates data over-fetching, saves bandwidth, and improves performance.
When to use GraphQL?
GraphQL works best for the following scenarios:
- Apps for devices such as mobile phones, smartwatches, and IoT devices, where bandwidth usage matters.
- Applications where nested data needs to be fetched in a single call.
- Composite pattern, where application retrieves data from multiple, different storage APIs.
What language does GraphQL use?
Implementations in Java, JavaScript, Ruby, Scala, others. GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.
What does GraphQL do?
GraphQL is designed to make APIs fast, flexible, and developer-friendly. It can even be deployed within an integrated development environment (IDE) known as GraphiQL. As an alternative to REST, GraphQL lets developers construct requests that pull data from multiple data sources in a single API call.
Is GraphQL better than REST?
GraphQL queries themselves are not faster than REST queries, but because you can pick the fields you want to query, GraphQL requests will always be smaller and more efficient. GraphQL also enables developers to retrieve multiple entities in one request, further adding to each query’s efficiency.
When should you not use GraphQL?
Below are some reasons why GraphQL could be a bad fit for your project when compared to a REST architecture:
- GraphQL queries could cause performance issues.
- REST can do much of what GraphQL does.
- GraphQL makes some tasks more complex.
- It’s easier to use a web cache with REST than with GraphQL.
Do you need a GraphQL endpoint in Sitecore?
Sitecore GraphQL does not ship with any GraphQL endpoints defined. To use the GraphQL API you must define at least one endpoint. The following is an example of defining an authentication-required content API endpoint for the master database (belongs as a Sitecore config patch in App_Config/Include)
Do you need SSC key to use Sitecore?
Sitecore does not support subscriptions for use in scaled public environments. If using CORS or wanting to use impersonation, you’ll want to set up a SSC API key in the /sitecore/system/Settings/Services/API Keys folder. API keys work with GraphQL just like with SSC.
How are GraphQL APIs different from REST APIs?
Unlike REST APIs, there is a formal request format and response format. Due to this commonality, GraphQL endpoints are all serviced by a single Controller and no code is required to define a new endpoint. It also enables things like request batching (multiple queries in a single HTTP request) to reduce network traffic. Extensibility is paramount.