kendraio-app icon indicating copy to clipboard operation
kendraio-app copied to clipboard

GraphQL

Open darrenmothersele opened this issue 4 years ago • 6 comments

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.

darrenmothersele avatar Apr 02 '20 09:04 darrenmothersele

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

darrenmothersele avatar Apr 02 '20 10:04 darrenmothersele

https://principledgraphql.com/integrity#1-one-graph

darrenmothersele avatar Apr 02 '20 10:04 darrenmothersele

https://www.apollographql.com/docs/angular/basics/queries/

darrenmothersele avatar Apr 02 '20 10:04 darrenmothersele

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.

darrenmothersele avatar Apr 06 '20 11:04 darrenmothersele

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.

darrenmothersele avatar Apr 06 '20 11:04 darrenmothersele

Done, but needs documenting

darrenmothersele avatar Apr 17 '20 13:04 darrenmothersele