| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Hasura.GraphQL.Analyse
Description
Tools to analyze the structure of a GraphQL request.
Synopsis
- data Structure = Structure {}
- data FieldInfo
- data ScalarInfo = ScalarInfo {}
- data EnumInfo = EnumInfo {}
- data ObjectInfo = ObjectInfo {}
- data VariableInfo = VariableInfo {}
- data InputFieldInfo
- data InputObjectInfo = InputObjectInfo {}
- diagnoseGraphQLQuery :: SchemaIntrospection -> TypedOperationDefinition NoFragments Name -> Maybe [Text]
- analyzeGraphQLQuery :: SchemaIntrospection -> TypedOperationDefinition NoFragments Name -> (Maybe Structure, [Text])
Documentation
Overall structure of a given query. We extract the tree of fields in the output, and the graph of input variables.
Constructors
| Structure | |
Fields | |
Information about the type of an output field; whether the base type is an
object or a scalar, we store the correspoding GType to keep track of the
modifiers applied to it (list or non-nullability).
data ScalarInfo Source #
Constructors
| ScalarInfo | |
Fields | |
Constructors
| EnumInfo | |
Fields | |
data ObjectInfo Source #
Constructors
| ObjectInfo | |
data VariableInfo Source #
Information about a single variable of the query.
Constructors
| VariableInfo | |
Fields
| |
data InputFieldInfo Source #
Information about the type of an input field; whether the base type is an
object or a scalar, we store the correspoding GType to keep track of the
modifiers applied to it (list or non-nullability).
data InputObjectInfo Source #
Constructors
| InputObjectInfo | |
Fields
| |
diagnoseGraphQLQuery :: SchemaIntrospection -> TypedOperationDefinition NoFragments Name -> Maybe [Text] Source #
Given the schema's definition, and a query, validate that the query is consistent. We do this by running the analysis, but discarding the result: we do not care about the structure, only about the validity of the query.
Returns Nothing if the query is valid, or a list of messages otherwise.
analyzeGraphQLQuery :: SchemaIntrospection -> TypedOperationDefinition NoFragments Name -> (Maybe Structure, [Text]) Source #
Given the schema's definition, and a query, run the analysis.
We process all possible fields, and return a partially filled structure if necessary. Given the following query:
query {
foo {
bar
}
does_not_exist {
ghsdflgh
}
}We would return a structure containing:
foo: {
bar: {
}
}AND an error about "does_not_exist" not existing.
In some cases, however, we might not be able to produce a structure at all,
in which case we return Nothing. This either indicates that something was
fundamentally wrong with the structure of the query (such as not finding an
object at the top level), or that a recoverable error was not caught properly
(see withCatchAndRecord).