Skip to content

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.

Prerequisite(s)

  • Hasura server URL to submit the query against

  • Admin secret or JWT

Admin Secret or JWT

If the Hasura server requires authentication, an admin secret or JWT signed with the server's key will be required.

If using JWT, you may choose to add 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 as secrets.

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 for the event Target and add the following information:

  • Admin Token for Hasura: Reference to a TriggerMesh secret containing an admin secret or JWT to communicate with Hasura as discussed in Admin Secret or JWT.
  • 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 for 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 and GraphQL, please refer to the Hasura and GraphQL 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.