com.walmartlabs.lacinia.parser

Parse a query document using a compiled schema.

Also provides functions that operate on the parsed query.

invariant?

added in 1.1

(invariant? parsed-query)

Analyzes the parsed query and returns true if it contains no query variables or query directives; an invariant query will be identical before and after invoking prepare-with-query-variables.

operations

added in 0.17.0

(operations parsed-query)

Given a previously parsed query, this returns a map of two keys:

:type
The type of request, one of: :query, :mutation, or :subscription.
:operations
The names of the top-level operations, as a set of keywords.

parse-query

(parse-query schema query-document)(parse-query schema query-document operation-name)(parse-query schema query-document operation-name timing-start)

Given a compiled schema and a query document, parses the query to an executable form as well as performing a number of validations.

When the request containing the query document provides an operation name, that is provided and the parsed query executes just that operation.

prepare-with-query-variables

(prepare-with-query-variables parsed-query variables)

Given a parsed query data structure and a map of variables, update the query, calculating field arguments and applying @skip and @include directives.

summarize-query

added in 0.26.0

(summarize-query parsed-query)

Analyzes a parsed query, returning a summary string.

The summary superficially resembles a GraphQL query, but strips out aliases, directives, and field arguments. In addition, fragments (both inline and named) are collapsed into their containing selections.

This summary can act as a ‘fingerprint’ of a related set of queries and is typically used in query performance analysis.