Query Tags


Query Tags are SQL comments which are made up of (key=value) pairs that are appended to the SQL statements generated by Hasura for GraphQL operations. This enables the ability to get some application context in the database logs and also use native database monitoring tools (e.g. pganalyze) for better performance analysis.


When the following query is sent to Hasura

query GetChild {
  child {

Hasura attaches query tags (unless disabled) to the generated SQL statement it sends to the database.

SELECT * FROM child /* request_id=487c2ed5-08a4-429a-b0e0-4666a82e3cc6, field_name=child, operation_name=GetChild */

Formats of Query Tags

The format of the Query Tags describes how the (Key,Value) pairs are constructed. Currently we support two formats of Query Tags:

  1. Standard (standard)
  2. SQLCommenter (sqlcommenter)


This format makes a collection of key=value pairs and separates each pair by a comma , . This is the default format for Query Tags

For eg:

SELECT * FROM child /* request_id=487c2ed5-08a4-429a-b0e0-4666a82e3cc6, field_name=child, parameterized_query_hash=b2a71ce23928ca7f0021f9060e5d590e9f9bb00f, operation_name=GetChild */


The specification for this format is defined at https://google.github.io/sqlcommenter/spec/

For eg:

SELECT * FROM child /* field_name='child', operation_name='GetChild', parameterized_query_hash='b2a71ce23928ca7f0021f9060e5d590e9f9bb00f' ,  request_id='487c2ed5-08a4-429a-b0e0-4666a82e3cc6' */

Information in Query Tags

The following information is present in query tags for the GraphQL operations.

Query and Mutation

  1. Request ID (request_id)
  2. Operation Name (operation_name)
  3. (Root) field name (alias if provided) (field_name)
  4. Parameterized Query Hash (parameterized_query_hash)


  1. (Root) field name (alias if provided) (field_name)
  2. Parameterized Query Hash (parameterized_query_hash)

Metadata Specification

  default_format: # Optional Field (Values can be sqlcommenter or standard)
  per_source_configuration: # Optional Field
    source_name: # Name of the database
      format: # Optional Field (Values can be sqlcommenter or standard)
      disabled: # Optional Field (Values can be true or false)


The default format for the Query Tags is Standard and they are always appended to the SQL statements. To disable or configure them you have to edit the metadata directly.

In the above metadata spec:

  1. If default_format is not specified, Standard is used as the default format
  2. The format in the source_name could be used to override the default_format
  3. If the default_format and the format for a source is not mentioned then Standard is used as format.
  4. If disabled is not set for any source, False is used i.e Query Tags are always enabled by default

Example Metadata Specification

  default_format: sqlcommenter
      format: standard
      disabled: true
      format: sqlcommenter
      disable: true