Due to the lack of documentation and hints around how GraphQL is working, it still seems to be more of a well guarded secret than anything that could be used by vendors to implement integration.
GraphQL has multiple advantages over the more traditional REST, but is more developer focused as well.
Here, the first tentative advancements with GraphQL for integration (and I’m very happy about feedback / corrections / optimizations / further options and opinions):
1. Send a first request to retrieve a token:
You’ll receive a token in the response:
XSRF-TOKEN=d753.Y6W_6c1LSWKHit24KhzqdSH7psWgZ4C0-_GhYZKvBL0.GdSIk7sbMC_v6Jj0fU64ORmInrbPMfXgtqHGG9HIXvMynYi7hgc4K_X4rg; path=/; samesite=lax
Copy that part and use it in the following requests:
d753.Y6W_6c1LSWKHit24KhzqdSH7psWgZ4C0-_GhYZKvBL0.GdSIk7sbMC_v6Jj0fU64ORmInrbPMfXgtqHGG9HIXvMynYi7hgc4K_X4rg
2. Login - create a second request for logging into the system with a header + token and your login details in the body:
3. Check the schema for endless possibilities on integration, automation and extending the CRM:
Still with the token in the header, create the next Request to:
crm.domain/api/graphql
and the body as GraphQL:
Query:
query { __schema { types { name } } }
Here, you’ll retrieve a “geek” documentation of what’s possible.
I’d really appreciate tons of information / documentation on the details from here on.
4. Now, we’re coming to the point, where the “magic happens”: Retrieve CRM data via GraphQL:
Again, headers with our token:
The complex thing to grasp now is GraphQL itself. Here we’ve got this query language, as opposed to the v8 REST API with its defined endpoints, filters etc.
But how do you know where to get those odd body details from?
Basically, just check your browser, when you use your CRM:
Example Query:
query recordList($module: String!, $limit: Int, $offset: Int, $criteria: Iterable, $sort: Iterable) {
recordList(module:$module, limit:$limit, offset: $offset, criteria: $criteria, sort: $sort) {
id
_id
meta
records
__typename
}
}
Example Variables:
{
"criteria": {
"name": "",
"orderBy": "",
"searchModule": "Leads",
"sortOrder": "",
"filters": {
"terminal": {
"field": "terminal",
"fieldType": "bool",
"operator": "=",
"values": [1]
}
}
},
"module": "Leads",
"limit": 100,
"offset": 0,
"sort": {
"orderBy": "",
"sortOrder": "DESC"
}
}
5. And continuing - now to retrieve one lead only:
(don’t forget the header with our token as above)
Example Query:
query record($module: String!, $record: String!) {
record(module: $module, record: $record) {
_id
id
attributes
module
type
acls
favorite
__typename
}
}
Example Variables:
{
"module": "Leads",
"record": "10018f91-03fe-fe30-1fa4-679e0c7c2226"
}
And again, what to add here comes from the browser. The key is to find the correct GraphQL request details - based on the response you’ll get in the browser.
What’s your feedback / approach? I appreciate all feedback here, since I’m still heavily using the V8 REST API.