kendraio-app
kendraio-app copied to clipboard
GraphQL
We can connect to and use GraphQL endpoints using the HTTP block, but the configuration is clunky and hard to use. This is because you currently have to use JMES Path to construct the payload. Here is an example from the Value Flows adapter:
{
"type": "http",
"method": "post",
"notify": false,
"endpoint": {
"protocol": "https:",
"host": "valnet.lurker.dev",
"pathname": "/api/graphql"
},
"payload": "{ query: 'query ($token: String) { viewer(token: $token) { allCommitments { id action plannedStart committedOn due committedQuantity { numericValue unit { name } } note resourceClassifiedAs { name category } involves { id resourceClassifiedAs { name category } trackingIdentifier } provider { id name } receiver { id name } inputOf { id name } outputOf { id name } scope { id name } plan { id name } isPlanDeliverable forPlanDeliverable { id action outputOf { name } } isDeletable } }}', variables: { token: context.vfAuth } }"
}
It would be nicer to have a GraphQL block that natively supported constructing GraphQL queries directly.
Maybe provide a block as a wrapper around an existing JS library, such as one of the options listed on this page: https://graphql.org/code/#javascript-1
Need to review the benefits of these to find a library that will enable expressive but simple configuration via JSON.
https://github.com/kadirahq/lokka https://github.com/yoshuawuyts/nanographql https://github.com/prisma-labs/graphql-request
https://principledgraphql.com/integrity#1-one-graph
https://www.apollographql.com/docs/angular/basics/queries/
A more flexible configuration format (like JSON5) would make this a bit easier, as queries would not need to be reformatted into a single-line JSON string.
I propose that a GraphQL query or mutation task/block would include a mapping to take the variables from the input data. This would be part of the block configuration, rather than a separate mapping block. A fallback (default behaviour) for when this configuration is not provided would be a one to one mapping between properties of the input data and the variables in the query.
Done, but needs documenting