GraphQL Use Cases

The Cleverbridge GraphQL API is a powerful resource you can use in different ways. For a list of common scenarios and code examples to help you integrate and utilize the API, check various use cases in the following topics.

🚧

Important

If you already use GraphQL, be aware of the changes related to Updates to underlying components of GraphQL as mentioned below.

Updates to underlying components of GraphQL

  1. DateTime input values will now follow the date and time notation according to ISO-8601 in order to avoid ambiguous dates such as "09-10-2015". A valid value would be "2022-05-21T10:00:00Z".
query ISO8601_example {  
   exampleSearch(  
      exampleSearchParameters: {  
         dateTimeField: {  
            value: "2022-05-21T10:00:00Z"  
            secondValue: "2022-05-21T13:42:002Z"  
            relationalOperator: BETWEEN }  
   dateField: {  
         value: "2022-05-21"  
         secondValue: "2022-05-22"  
         relationalOperator: BETWEEN }  
   })  
   {example { id } }  
}
  1. The value "null" will be treated as value "null" and not result in the default value for that field. Therefore, we advise that you do not include fields in your mutation calls if you want those fields to have their default value.
mutation MyMutation {  
   createMvtCampaign(input: {  
      clientId: 1584,  
      name: "old Migration example",  
      identifier: "old-Migration-example",  
      isActive: null  
}) {  
      createdMvtCampaign {  
         isActive  
      }  
   }  
}  
{
   "data": {
   "createMvtCampaign": {
      "createdMvtCampaign": {
         "isActive": true
         }
      }
   }
}
mutation MyMutation {
   createMvtCampaign(input: {
      clientId: 1584,
      name: "old Migration example",
      identifier: "old-Migration-example",
      isActive: null 
}) {
      createdMvtCampaign {
         isActive
      }
   }
}
{
   "data": {
   "createMvtCampaign": null
},
"errors": [
   {
         "message": "IsActive cannot be null."
      }
   ]
}
  1. The "code" property of errors will move into the "extensions" object inside of the error. To ensure a soft transition, we will not remove the old code property at first. However, we will remove it later, so we advise that you use the new field.
{
"errors": [
   {
      "message": "Unauthenticated user.",
      "code": "Access forbidden" 
        }
    ]
}
{
"errors": [
   {
      "message": "Unauthenticated user.",
      "code": "Access forbidden",
      "extensions": {
         "code": "Access forbidden"
        } 
      }
   ]
}
{
"errors": [
   {
    "message": "Unauthenticated user.",
    "extensions": {   
       "code": "Access forbidden"
        } 
     }
  ]
}
  1. Names of ENUM values must now follow the CAPITALIZED_WITH_UNDERSCORES format.

Example:

In previous versions, multiple styles of naming conventions were allowed for enumerated values. For example, in RecommendationTypeEnum { CROSS_SELLING, SUB_SELLING, UP_SELLING } the value Up_SeLLINg was interpreted as UP_SELLING.

Now, the CAPITALIZED_WITH_UNDERSCORES format has to be followed, so only the UP_SELLING name is correct. The Up_SeLLINg value would result in an error as converting to the correct syntax is no longer possible. Make sure you input your ENUM values using uppercase letters separated with underscores, if you want your ENUM-types to run smoothly.

  1. Providing a numeric value as a string when using query variables is no longer possible. Now, this will result in a type error.
{
    "query":"query example($id: Int!){ subscription(id: $id { id }}",
    "variables":{"id":"49092971"}
}
{
    "query":"query example($id: Int!){ subscription(id: $id { id }}",
    "variables":{"id":49092971}
}