Event Target for Hasura

This event target receives CloudEvents as either a GraphQL query or key/value pairs for a known query and sends it to Hasura.

Prerequisites

  1. Hasura server URL to submit the query against

  2. If the server requires authentication, then an admin secret or a JWT token signed with the server's key

  3. If using the JWT token, then an optional user role to invoke the queries as

Consult the Secrets guide for more information about how to add the admin or user JWT tokens.

Deploying an Instance of the Target

Open the Bridge creation screen and add a Target of type Hasura.

Adding a Hasura Target

In the Target creation form, provide a name to the event Target, and add the following information:

  • Admin token for Hasura: Reference to a TriggerMesh secret containing an admin secret or user [JWT token][hasural-jwt] to communicate with Haura as described in the prerequisites.
  • Hasura Server URL: URL endpoint to communicate with Hasura
  • Default Role: Specify the Hasura user role to use when querying Hasura
  • Pre-canned queries: A key/value pair of predefined queries available for CloudEvents to specify.

Hasura Target form

After clicking the Save button, the console will self-navigate to the Bridge editor. Proceed by adding the remaining components to the Bridge.

Bridge overview

After submitting the bridge, and allowing some configuration time, a green check mark on the main Bridges page indicates that the bridge with a Hasura event Target was successfully created.

Bridge status

For more information about using Hasura or GraphQL, please refer to the appropriate documentation.

Event Types

A Hasura event Target accepts the following CloudEvent types:

org.graphql.query.raw

Events of this type are raw GraphQL queries intended to be submitted directly to Hasura.

This type expects a JSON payload with the following properties:

Name Type Comment
query string The GraphQL to run against the Hasura server
operationName string The query name specified in the query attribute
variables map[string]string Key/value pairs of variables with the key defined in the query

The response event will have the ce-type attribute set to org.graphql.query.result and ce-source attribute set to the target's endpoint.

org.graphql.query

Events of this type leverage the pre-defined query defined when the target is created. In addition to the ce-type, the ce-subject must be set to the name of the pre-defined query, otherwise the event will not be processed by the target.

The JSON payload for this type must consist of a string dictionary where the keys correspond to the variables defined in the query, and key's value is passed as a string.

The response event will have the ce-type attribute set to org.graphql.query.result and ce-source attribute set to the target's endpoint.