Crate litho_diagnostics

Source
Expand description

This crate implements all diagnostics that Litho (a GraphQL framework) can emit.

Within Litho, these diagnostics are emitted by the lexer, parser, type checker and compiler. Typically, each of those can emit multiple diagnostics without bailing out after the first diagnostic, but the compiler will only advance to the next phase if there are no errors in the previous phase.

All diagnostics are generated by a DSL Macro (see source code), implement DiagnosticInfo<S> and are generic with respect to the span that triggered the diagnostic. Diagnostics consist of an error code, name, message and zero or more labels. Labels are additional hints that refer to a separate span in the source code.

§Example

Below is an example of a diagnostic that Litho generates: MissingArgumentsClosingParentheses. It starts with the code in square brackets, followed by a message. It shows a snippet of the lines that caused the diagnostic along with the primary span that starts at graphql:6:20. And finally, it also shows two more spans (first and second) with additional hints.

[E0006] Error: Arguments are missing closing parenthesis.

   ╭─[graphql:6:20]
   │
 6 │     field(arg: true
   ·          ┬         ┬  
   ·          ╰──────────── This `(` here ...
   ·                    │  
   ·                    ╰── ... should have a matching `)` here.
───╯

Structs§

CyclicFragmentDefinition
(E0317) Fragment definition must not be cyclic.
DifferentExtensionType
(E0127) Type extension must extend type of same kind.
DifferentFieldArguments
(E0306) Selection set contains fields with the same name but different arguments.
DifferentFieldNames
(E0305) Selection set contains different fields with the same name.
DirectiveInInvalidLocation
(E0320) Directive must be used in valid location.
DuplicateArgument
(E0311) Argument may be provided only once.
DuplicateArgumentName
(E0106) Argument name must be unique.
DuplicateDirectiveName
(E0126) Directive name must be unique.
DuplicateEnumValue
(E0122) Enum values must be unique.
DuplicateExtendedField
(E0103) Field name must be unique across extended types.
DuplicateField
(E0102) Field name must be unique.
DuplicateFragmentName
(E0313) Fragment definitions must be unique.
DuplicateImplementsInterface
(E0109) Type must not implement same interface twice.
DuplicateNonRepeatableDirective
(E0321) Non-repeatable directive must be unique per location.
DuplicateOperationName
(E0300) Operation definitions must be unique.
DuplicateTypeName
(E0126) Type name must be unique.
DuplicateUnionMember
(E0119) Union members must be unique.
DuplicateVariable
(E0322) Variables must be unique per operation definition.
EmptyType
(E0101) Type must define one or more fields.
ExpectedBooleanValue
(E0205) Expected a boolean value.
ExpectedEnumValue
(E0210) Expected an enum value.
ExpectedFloatValue
(E0203) Expected a float value.
ExpectedInputObjectValue
(E0206) Expected an input object value.
ExpectedIntValue
(E0202) Expected an int value.
ExpectedListValue
(E0201) Expected a list value.
ExpectedNonNullValue
(E0200) Expected a non-null value.
ExpectedStringValue
(E0204) Expected a string value.
FieldNotOutputType
(E0105) Field must be output type.
FragmentOnNonCompositeType
(E0314) Fragment definitions must target composite type.
ImplementsNonInterfaceType
(E0110) Implemented type must be interface.
ImpossibleFragmentSpread
(E0318) Fragment spread must be possible.
IncompatibleResponseFields
(E0307) Selection set contains multiple fields with the same name with incompatible selection sets.
IncompatibleResponseShape
(E0304) Selection set contains multiple fields of incompatible types with the same name.
IncompatibleVariable
(E0327) Variable must be compatible with usage.
IncompatibleVariableInFragment
(E0328) Variable must be compatible with usage.
InputValueNotInputType
(E0108) Input value must be input type.
InvalidInterfaceFieldArgumentType
(E0114) Type must implement field with argument of same type as interface.
LoneAnonymousOperation
(E0301) Anonymous operation definitions must be alone.
MissingArgumentColon
(E0007) Argument is missing colon.
MissingArgumentValue
(E0008) Argument is missing value.
MissingArgumentsClosingParentheses
(E0006) Arguments are missing closing parenthesis.
MissingArgumentsDefinitionClosingParenthesis
(E0038) Arguments definition must have a closing parenthesis.
MissingDefaultValue
(E0021) Default value must have a value.
MissingDirectiveDefinitionAt
(E0054) Directive’s name must start with an @.
MissingDirectiveDefinitionLocations
(E0056) Directive definition must have one or more locations.
MissingDirectiveDefinitionName
(E0055) Directive definition must have a name.
MissingDirectiveName
(E0024) Directive must have a name.
MissingEnumTypeDefinitionName
(E0048) Enum type definition must have a name.
MissingEnumTypeExtensionName
(E0050) Enum type extension must have a name.
MissingEnumValues
(E0121) Enum must have at least one value.
MissingEnumValuesClosingBrace
(E0049) Enum values must have a closing brace.
MissingFieldDefinitionColon
(E0036) Field definition must have a colon.
MissingFieldDefinitionType
(E0037) Field definition must have a type.
MissingFieldName
(E0005) Field must have a name.
MissingFieldsDefinitionClosingBrace
(E0035) Fields definition must have a closing brace.
MissingFirstDirectiveLocation
(E0057) Directive definition must have one or more locations.
MissingFirstImplementsInterface
(E0033) Implemented interfaces must not be empty.
MissingFirstUnionMemberType
(E0045) Union type definition must have one or more member types.
MissingFragmentName
(E0010) Fragment definition must have a name.
MissingFragmentSelectionSet
(E0012) Fragment definition must have a selection set.
MissingFragmentTypeCondition
(E0011) Fragment definition must have a type condition.
MissingInheritedInterface
(E0111) Type must also implement inherited interfaces.
MissingInlineFragmentSelectionSet
(E0009) Inline fragment is missing selection set.
MissingInputField
(E0207) Expected a value for required input field.
MissingInputFieldsDefinitionClosingBrace
(E0052) Input fields definition must have a closing brace.
MissingInputObjectTypeDefinitionName
(E0051) Input object type definition must have a name.
MissingInputObjectTypeExtensionName
(E0053) Input object type extension must have a name.
MissingInputValueDefinitionColon
(E0039) Input value definition must have a colon.
MissingInputValueDefinitionType
(E0040) Input value definition must have a type.
MissingInterfaceField
(E0112) Type must implement field from interface.
MissingInterfaceFieldArgument
(E0113) Type must implement field with argument from interface.
MissingInterfaceTypeDefinitionName
(E0042) Interface type definition must have a name.
MissingInterfaceTypeExtensionName
(E0043) Interface type extension must have a name.
MissingListTypeClosingBracket
(E0022) List type must have a closing bracket.
MissingListTypeWrappedType
(E0023) List type must wrap another type.
MissingListValueClosingBracket
(E0014) List value must have closing bracket.
MissingObjectFieldColon
(E0016) Object field must have a colon.
MissingObjectFieldValue
(E0017) Object field must have a value.
MissingObjectTypeDefinitionName
(E0032) Object type definition must have a name.
MissingObjectTypeExtensionName
(E0041) Object type extension must have a name.
MissingObjectValueClosingBrace
(E0015) Object value must have closing brace.
MissingOperationDefinitionName
(E0002) Operation definition must have a name.
MissingOperationDefinitionSelectionSet
(E0003) Operation definition must have a selection set.
MissingRequiredArgument
(E0312) Missing required argument.
MissingRootOperationTypeDefinitionColon
(E0027) Root operation type definition must have a colon.
MissingRootOperationTypeDefinitionNamedType
(E0028) Root operation type definition must have a named type.
MissingRootOperationTypeDefinitions
(E0025) Schema definition must define one or more root operation types.
MissingRootOperationTypeDefinitionsClosingBrace
(E0026) Root operation type definitions must have a closing brace.
MissingScalarTypeDefinitionName
(E0029) Scalar type definition must have a name.
MissingScalarTypeExtensionDirectives
(E0031) Scalar type extension must have one or more directives.
MissingScalarTypeExtensionName
(E0030) Scalar type extension must have a name.
MissingSecondDirectiveLocation
(E0058) Directive location must be defined.
MissingSecondImplementsInterface
(E0034) Implemented interface name is missing.
MissingSecondUnionMemberType
(E0046) Union member type must have a name.
MissingSelectionSet
(E0308) Field of composite type must have selection set.
MissingSelectionSetClosingBrace
(E0004) Selection set is missing closing curly brace.
MissingTypeConditionNamedType
(E0013) Type condition must have a named type.
MissingUnionMembers
(E0118) Union must have at least one member type.
MissingUnionTypeDefinitionName
(E0044) Union type definition must have a name.
MissingUnionTypeExtensionName
(E0047) Union type extension must have a name.
MissingVariableDefinitionColon
(E0019) Variable definition must have a colon.
MissingVariableDefinitionType
(E0020) Variable definition must have a type.
MissingVariableDefinitionsClosingParenthesis
(E0018) Variable definitions must have a closing parenthesis.
NonCovariantInterfaceField
(E0116) Implemented type and type from interface must be covariant.
NonObjectUnionMember
(E0120) Union members must be object types.
ReservedDirectiveName
(E0124) Directive name must not start with __.
ReservedFieldName
(E0104) Field name must not start with __.
ReservedInputValueName
(E0107) Input value name must not start with __.
SelfReferentialDirective
(E0125) Directive must not be self-referential.
SelfReferentialInputType
(E0123) Input type must not be self-referential.
SelfReferentialInterface
(E0117) Interface must not implement itself.
UndefinedArgument
(E0310) Argument must exist in schema.
UndefinedDirective
(E0319) Directive must be defined.
UndefinedField
(E0303) Queried field does not exist.
UndefinedFragment
(E0316) Fragment definition must be defined.
UndefinedVariable
(E0324) Variables must be defined before they can be used.
UndefinedVariableInFragment
(E0325) Operations must define variables for all transitively included fragments.
UnexpectedNonNullExtraInterfaceFieldArgument
(E0115) Type must not require extra arguments for fields implementing interface.
UnexpectedSelectionSet
(E0309) Field of scalar-like type must not have a selection set.
UnknownNamedType
(E0100) Named type must exist.
UnrecognizedEnumValue
(E0209) Enum values must exist in schema definition.
UnrecognizedInputField
(E0208) All fields in input object must exist in schema definition.
UnrecognizedTokens
(E0001) Syntax error.
UnsupportedOperation
(E0329) Operation must be defined in schema before it can be used.
UnusedFragmentDefinition
(E0315) Fragment definitions must be used.
UnusedVariable
(E0326) Variables must be used.
VariableMustBeInputType
(E0323) Variables must be input types.

Enums§

Diagnostic
Enum that contains all possible diagnostics that Litho can return.

Traits§

DiagnosticInfo
Trait implemented by all different diagnostic types that Litho uses.