Table of Contents
Introduction
With a strong type-system to define an API, GraphQL gives the specific of what exactly needed through only one endpoint. It becomes front-end friendly and a good fit for complex systems or microservices.
Working with GraphQL API, you can use this URL https://api.nimvio.com to access the API. You may also require Project ID and Content ID to do so. By default, this API provides you with a default response structure. However, you are allowed to customize it as well. The following guides then will help you to work with each type of endpoint.
Retrieve Default Response
You can retrieve the default response by setting the request body as the below.
query {
content(){
}
}
The response will be as in the following example.
{
"status": 200,
"data": {
"Status": "Published",
"CreatedBy": "Erian Suwandi",
"CreatedAt": "2021-04-23T03:24:17.851Z",
"Data": {
"title": "New Blog"
},
"PublishedBy": "Erian Suwandi",
"UpdatedAt": "2021-05-10T06:21:28.079Z",
"Name": "Blog",
"PublishedAt": "2021-05-10T06:21:28.079Z",
"UpdatedBy": "Erian Suwandi",
"TemplateName": "Blog",
"TemplateID": "Template_64a5416f-3255-4b2f-b2fd-f86100418eb8",
"ContentID": "Content_eaea0b46-f440-438c-9c26-92f4006ae03a"
}
}
Retrieve Custom Response
You can retrieve custom responses by using a specific query. Below is an example of the query.
query {
content(){
Name,
ContentID
}
}
The response will be as in the following example.
{
"status": 200,
"data": {
"Name": "Blog",
"ContentID": "Content_eaea0b46-f440-438c-9c26-92f4006ae03a"
}
}
Retrieve Content with Specific Field
GraphQL API also provides filtering features that can be done from the query to search certain content with specific fields.
- Search with Query Parameters
Below is an example of the query.
query {
content(pageSize: 3, page: 1, sortAsc: true ){
Name
}
}
The response will be as in the following example.
{
"status": 200,
"data": [
{
"Name": "1"
},
{
"Name": "a"
},
{
"Name": "3"
}
],
"totalItems": 3
}
- Search with Specific Fields
Below is an example of the query.
query {
content(pageSize: 3, page: 1, sortAsc: true, PublishedBy: "Erian Suwandi" ){
Name,
ContentID,
PublishedBy
}
}
The response will be as in the following example.
{
"status": 200,
"data": [
{
"PublishedBy": "Erian Suwandi",
"Name": "1",
"ContentID": "Content_ef3959e2-188d-408d-8e2b-b6b5150e0caf"
}
],
"totalItems": 1
}
- Search with Specific Fields within data.Data Field
Below is an example of the query.
query {
content(pageSize: 3, page: 1, sortAsc: true, PublishedBy: "Erian", data: {desc: "lorem"} ){
Name,
ContentID,
Data,
PublishedBy
}
}
The response will be as in the following example.
{
"status": 200,
"data": [
{
"Data": {
"desc": "<p>lorem ipsum</p>",
"recommendation": {
"Type": "Reference",
"ReferenceType": "Content"
},
"asset": {
"Type": "Reference",
"ReferenceType": "Media"
}
},
"PublishedBy": "Erian Suwandi",
"Name": "3",
"ContentID": "Content_a056e3b6-cb5a-483a-8b09-6222d5fb2eb6"
}
],
"totalItems": 1
}
- Search with Specific Range on UpdatedAt, CreatedAt, PublishedAt Fields
You can do a search based on the range for datetime field by referring to the table below.
Arguments |
Description |
Example |
get |
Greater or Equals |
query { content( pageSize: 10, page: 1, PublishedAt_gte: "2021-02-03T03:06:00"){ } } |
gt |
Greater Than |
query { content( pageSize: 10, page: 1, UpdatedAt_gt: "2021-02-03T03:06:00"){ } } |
lte |
Lower or Equals |
query { content( pageSize: 10, page: 1, CreatedAt_lte: "2021-02-03T03:06:00"){ } } |
lt |
Lower Than |
query { content( pageSize: 10, page: 1, UpdatedAt_lt: "2021-02-03T03:06:00"){ } } |
Retrieve Content List
With this endpoint, you can get a list of content items with specific query parameters. The details are shown in the table below. Be noted that Path Parameters are mandatory, while Query Parameters are dynamic as the query type above.
POST /cda/graphql/v1/{project_id} |
||
Full URL https://api.nimvio.com/cda/graphql/v1/{project_id} |
||
Path parameters |
Values |
Description |
project_id |
Project ID |
String Identifies the project |
Query parameters |
Values |
Description |
name |
Content name |
String Use to request by specific content name |
templateName |
Content template name |
String Use to request by specific content template name |
status |
Content status |
String Use to request by specific content status |
createdBy |
Content creator name |
String Use to request by specific content creator |
createdAt |
Content created date |
String Use to request by specific content created date |
data |
Element or field of content |
String Use to request by specific content element or field |
publishedBy |
Content published date |
String Use to request by specific content publisher |
updatedBy |
Content editor name |
String Use to request by specific content editor |
contentID |
Content ID |
String Use to request by specific content ID |
templateID |
Template ID |
String Use to request by specific content template ID |
page |
Page number |
String Use to request specific page |
pageSize |
Page size |
Int Use to request specific page Size |
sort |
Field Name |
String Use to sort records based on field name |
sortAsc |
true or false |
Boolean Sort ascending when true and by default will sort descending |
Responses |
Fields |
Description |
|
status |
The HTTP response status |
|
data |
The content items’s system properties |
|
totalItems |
The total of content items |
|
data.Status |
The content items’s status |
|
data.CreatedBy |
The content items’s creator name |
|
data.CreatedAt |
The content items’s created date |
|
data.Data |
The content’s element or field with its value |
|
data.PublishedBy |
The content items’s publisher name |
|
data.UpdatedAt |
The content items’s updated date |
|
data.Name |
The content items’s name |
|
data.PublishedAt |
The content items’s published date |
|
data.UpdatedBy |
The content items’s editor name |
|
data.TemplateName |
The content items’s template name |
|
data.TemplateID |
The content items’s template ID |
|
data.ContentID |
The content items’s ID |
The below is a response example when using application/json as the content-type.
{
"status": 200,
"data": [
{
"Status": "Published",
"CreatedBy": "Erian Suwandi",
"CreatedAt": "2021-04-23T03:24:17.851Z",
"Data": {
"title": "New Blog"
},
"PublishedBy": "Erian Suwandi",
"UpdatedAt": "2021-05-10T06:21:28.079Z",
"Name": "Blog",
"PublishedAt": "2021-05-10T06:21:28.079Z",
"UpdatedBy": "Erian Suwandi",
"TemplateName": "Blog",
"TemplateID": "Template_64a5416f-3255-4b2f-b2fd-f86100418eb8",
"ContentID": "Content_eaea0b46-f440-438c-9c26-92f4006ae03a"
}
],
"totalItems": 1
}
What is Next?
Congratulations! You have finished the guide. Keep exploring below:
- Project ID and Content ID
- Working with REST API
- Working with Elasticsearch Query API
- Working with API via Postman
Comments
0 comments
Please sign in to leave a comment.