API Stability Preview

The validateQuery() GraphQL query is used to check that a query compiles. This field is deprecated. Use analyzeQuery() , instead.

For more information on saved queries, see the User Functions (Saved Searches) reference page where saved queries are discussed. Also, look at the Searching Data documentation page as it relates to recent queries and saving queries.

Syntax

Below is the syntax for the validateQuery() query field:

graphql
validateQuery(
     queryString: string!
     version: LanguageVersionEnum!
     isLive: boolean
     arguments: [QueryArgument!]
   ): QueryValidationResult!

Again, since this field is deprecated, use instead analyzeQuery() . Below is an example, though, of how this query field might be used:

Show:
graphql
query {
  validateQuery(queryString:"host=localhost",
                version: legacy, isLive: false)
  {isValid, diagnostics{severity, message, code}}
}

Given Datatypes

For version, see LanguageVersionEnum. For arguments, the datatype QueryArgument, there are a couple parameters. Below is a list of them along with their datatypes and a description of each:

Table: QueryArgument

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 19, 2024
namestringyes PreviewThe name of the query argument.
valuestringyes PreviewThe value fo the query argument.

Returned Datatypes

The returned datatype QueryValidationResult has its own parameters. They're listed in the table here:

Table: QueryValidationResult

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Oct 2, 2024
diagnostics[QueryDiagnostic]yes PreviewA diagnostic message from query validation. See QueryDiagnostic. This is a preview for internal testing and subject to change.
isValidbooleanyes PreviewWhether query is valid. For internal testing.