-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell GraphQL implementation -- -- This package provides a rudimentary parser for the GraphQL -- language. @package graphql @version 0.8.0.0 -- | Various parts of a GraphQL document can be annotated with directives. -- This module describes locations in a document where directives can -- appear. module Language.GraphQL.AST.DirectiveLocation -- | All directives can be splitted in two groups: directives used to -- annotate various parts of executable definitions and the ones used in -- the schema definition. data DirectiveLocation ExecutableDirectiveLocation :: ExecutableDirectiveLocation -> DirectiveLocation TypeSystemDirectiveLocation :: TypeSystemDirectiveLocation -> DirectiveLocation -- | Where directives can appear in an executable definition, like a query. data ExecutableDirectiveLocation Query :: ExecutableDirectiveLocation Mutation :: ExecutableDirectiveLocation Subscription :: ExecutableDirectiveLocation Field :: ExecutableDirectiveLocation FragmentDefinition :: ExecutableDirectiveLocation FragmentSpread :: ExecutableDirectiveLocation InlineFragment :: ExecutableDirectiveLocation -- | Where directives can appear in a type system definition. data TypeSystemDirectiveLocation Schema :: TypeSystemDirectiveLocation Scalar :: TypeSystemDirectiveLocation Object :: TypeSystemDirectiveLocation FieldDefinition :: TypeSystemDirectiveLocation ArgumentDefinition :: TypeSystemDirectiveLocation Interface :: TypeSystemDirectiveLocation Union :: TypeSystemDirectiveLocation Enum :: TypeSystemDirectiveLocation EnumValue :: TypeSystemDirectiveLocation InputObject :: TypeSystemDirectiveLocation InputFieldDefinition :: TypeSystemDirectiveLocation instance GHC.Show.Show Language.GraphQL.AST.DirectiveLocation.DirectiveLocation instance GHC.Classes.Eq Language.GraphQL.AST.DirectiveLocation.DirectiveLocation instance GHC.Show.Show Language.GraphQL.AST.DirectiveLocation.TypeSystemDirectiveLocation instance GHC.Classes.Eq Language.GraphQL.AST.DirectiveLocation.TypeSystemDirectiveLocation instance GHC.Show.Show Language.GraphQL.AST.DirectiveLocation.ExecutableDirectiveLocation instance GHC.Classes.Eq Language.GraphQL.AST.DirectiveLocation.ExecutableDirectiveLocation -- | This module defines an abstract syntax tree for the GraphQL -- language. It follows closely the structure given in the specification. -- Please refer to Facebook's GraphQL Specification. for more -- information. module Language.GraphQL.AST.Document -- | Alternative field name. -- --
-- {
-- smallPic: profilePic(size: 64)
-- bigPic: profilePic(size: 1024)
-- }
--
--
-- Here "smallPic" and "bigPic" are aliases for the same field,
-- "profilePic", used to distinquish between profile pictures with
-- different arguments (sizes).
type Alias = Name
-- | Single argument.
--
--
-- {
-- user(id: 4) {
-- name
-- }
-- }
--
--
-- Here "id" is an argument for the field "user" and its value is 4.
data Argument
Argument :: Name -> Value -> Argument
-- | A list of values passed to a field.
--
--
-- type Person {
-- name: String
-- picture(width: Int, height: Int): Url
-- }
--
--
-- Person has two fields, "name" and "picture". "name" doesn't
-- have any arguments, so ArgumentsDefinition contains an empty
-- list. "picture" contains definitions for 2 arguments: "width" and
-- "height".
newtype ArgumentsDefinition
ArgumentsDefinition :: [InputValueDefinition] -> ArgumentsDefinition
-- | Constant input value.
data ConstValue
ConstInt :: Int32 -> ConstValue
ConstFloat :: Double -> ConstValue
ConstString :: Text -> ConstValue
ConstBoolean :: Bool -> ConstValue
ConstNull :: ConstValue
ConstEnum :: Name -> ConstValue
ConstList :: [ConstValue] -> ConstValue
ConstObject :: [ObjectField ConstValue] -> ConstValue
-- | All kinds of definitions that can occur in a GraphQL document.
data Definition
ExecutableDefinition :: ExecutableDefinition -> Definition
TypeSystemDefinition :: TypeSystemDefinition -> Definition
TypeSystemExtension :: TypeSystemExtension -> Definition
-- | GraphQL has built-in capability to document service APIs.
-- Documentation is a GraphQL string that precedes a particular
-- definition and contains Markdown. Any GraphQL definition can be
-- documented this way.
--
--
-- """
-- Supported languages.
-- """
-- enum Language {
-- English
-- EN
--
-- Russian
-- RU
-- }
--
newtype Description
Description :: Maybe Text -> Description
-- | Directive.
--
-- Directives begin with "@", can accept arguments, and can be applied to
-- the most GraphQL elements, providing additional information.
data Directive
Directive :: Name -> [Argument] -> Directive
-- | GraphQL document.
type Document = NonEmpty Definition
-- | Single value in an enum definition.
--
--
-- enum Direction {
-- NORTH
-- EAST
-- SOUTH
-- WEST
-- }
--
--
-- "NORTH, EAST, SOUTH, and WEST are value
-- definitions of an enum type definition Direction.
data EnumValueDefinition
EnumValueDefinition :: Description -> Name -> [Directive] -> EnumValueDefinition
-- | Top-level definition of a document, either an operation or a fragment.
data ExecutableDefinition
DefinitionOperation :: OperationDefinition -> ExecutableDefinition
DefinitionFragment :: FragmentDefinition -> ExecutableDefinition
-- | Definition of a single field in a type.
--
--
-- type Person {
-- name: String
-- picture(width: Int, height: Int): Url
-- }
--
--
-- "name" and "picture", including their arguments and types, are field
-- definitions.
data FieldDefinition
FieldDefinition :: Description -> Name -> ArgumentsDefinition -> Type -> [Directive] -> FieldDefinition
-- | Fragment definition.
data FragmentDefinition
FragmentDefinition :: Name -> TypeCondition -> [Directive] -> SelectionSet -> FragmentDefinition
-- | Defines a list of interfaces implemented by the given object type.
--
--
-- type Business implements NamedEntity & ValuedEntity {
-- name: String
-- }
--
--
-- Here the object type Business implements two interfaces:
-- NamedEntity and ValuedEntity.
newtype ImplementsInterfaces t
ImplementsInterfaces :: t NamedType -> ImplementsInterfaces t
-- | Defines an input value.
--
--
-- input Point2D {
-- x: Float
-- y: Float
-- }
--
--
-- The input type Point2D contains two value definitions: "x" and
-- "y".
data InputValueDefinition
InputValueDefinition :: Description -> Name -> Type -> Maybe ConstValue -> [Directive] -> InputValueDefinition
-- | Name.
type Name = Text
-- | Represents type names.
type NamedType = Name
-- | Helper type to represent Non-Null types and lists of such types.
data NonNullType
NonNullTypeNamed :: Name -> NonNullType
NonNullTypeList :: Type -> NonNullType
-- | Key-value pair.
--
-- A list of ObjectFields represents a GraphQL object type.
data ObjectField a
ObjectField :: Name -> a -> ObjectField a
-- | Operation definition.
data OperationDefinition
SelectionSet :: SelectionSet -> OperationDefinition
OperationDefinition :: OperationType -> Maybe Name -> [VariableDefinition] -> [Directive] -> SelectionSet -> OperationDefinition
-- | GraphQL has 3 operation types:
--
--
-- schema {
-- query: MyQueryRootType
-- mutation: MyMutationRootType
-- }
--
data OperationTypeDefinition
OperationTypeDefinition :: OperationType -> NamedType -> OperationTypeDefinition
-- | Extension of the schema definition by further operations or
-- directives.
data SchemaExtension
SchemaOperationExtension :: [Directive] -> NonEmpty OperationTypeDefinition -> SchemaExtension
SchemaDirectivesExtension :: NonEmpty Directive -> SchemaExtension
-- | Selection is a single entry in a selection set. It can be a single
-- field, fragment spread or inline fragment.
--
-- The only required property of a field is its name. Optionally it can
-- also have an alias, arguments, directives and a list of subfields.
--
-- In the following query "user" is a field with two subfields, "id" and
-- "name":
--
--
-- {
-- user {
-- id
-- name
-- }
-- }
--
--
-- A fragment spread refers to a fragment defined outside the operation
-- and is expanded at the execution time.
--
--
-- {
-- user {
-- ...userFragment
-- }
-- }
--
-- fragment userFragment on UserType {
-- id
-- name
-- }
--
--
-- Inline fragments are similar but they don't have any name and the type
-- condition ("on UserType") is optional.
--
--
-- {
-- user {
-- ... on UserType {
-- id
-- name
-- }
-- }
--
data Selection
Field :: Maybe Alias -> Name -> [Argument] -> [Directive] -> SelectionSetOpt -> Selection
FragmentSpread :: Name -> [Directive] -> Selection
InlineFragment :: Maybe TypeCondition -> [Directive] -> SelectionSet -> Selection
-- | "Top-level" selection, selection on an operation or fragment.
type SelectionSet = NonEmpty Selection
-- | Field selection.
type SelectionSetOpt = [Selection]
-- | Type representation.
data Type
TypeNamed :: Name -> Type
TypeList :: Type -> Type
TypeNonNull :: NonNullType -> Type
-- | Type condition.
type TypeCondition = Name
-- | Type definitions describe various user-defined types.
data TypeDefinition
ScalarTypeDefinition :: Description -> Name -> [Directive] -> TypeDefinition
ObjectTypeDefinition :: Description -> Name -> ImplementsInterfaces [] -> [Directive] -> [FieldDefinition] -> TypeDefinition
InterfaceTypeDefinition :: Description -> Name -> [Directive] -> [FieldDefinition] -> TypeDefinition
UnionTypeDefinition :: Description -> Name -> [Directive] -> UnionMemberTypes [] -> TypeDefinition
EnumTypeDefinition :: Description -> Name -> [Directive] -> [EnumValueDefinition] -> TypeDefinition
InputObjectTypeDefinition :: Description -> Name -> [Directive] -> [InputValueDefinition] -> TypeDefinition
-- | Extensions for custom, already defined types.
data TypeExtension
ScalarTypeExtension :: Name -> NonEmpty Directive -> TypeExtension
ObjectTypeFieldsDefinitionExtension :: Name -> ImplementsInterfaces [] -> [Directive] -> NonEmpty FieldDefinition -> TypeExtension
ObjectTypeDirectivesExtension :: Name -> ImplementsInterfaces [] -> NonEmpty Directive -> TypeExtension
ObjectTypeImplementsInterfacesExtension :: Name -> ImplementsInterfaces NonEmpty -> TypeExtension
InterfaceTypeFieldsDefinitionExtension :: Name -> [Directive] -> NonEmpty FieldDefinition -> TypeExtension
InterfaceTypeDirectivesExtension :: Name -> NonEmpty Directive -> TypeExtension
UnionTypeUnionMemberTypesExtension :: Name -> [Directive] -> UnionMemberTypes NonEmpty -> TypeExtension
UnionTypeDirectivesExtension :: Name -> NonEmpty Directive -> TypeExtension
EnumTypeEnumValuesDefinitionExtension :: Name -> [Directive] -> NonEmpty EnumValueDefinition -> TypeExtension
EnumTypeDirectivesExtension :: Name -> NonEmpty Directive -> TypeExtension
InputObjectTypeInputFieldsDefinitionExtension :: Name -> [Directive] -> NonEmpty InputValueDefinition -> TypeExtension
InputObjectTypeDirectivesExtension :: Name -> NonEmpty Directive -> TypeExtension
-- | Type system can define a schema, a type or a directive.
--
--
-- schema {
-- query: Query
-- }
--
-- directive example on FIELD_DEFINITION
--
-- type Query {
-- field: String example
-- }
--
--
-- This example defines a custom directive "@example", which is applied
-- to a field definition of the type definition Query. On the top
-- the schema is defined by taking advantage of the type Query.
data TypeSystemDefinition
SchemaDefinition :: [Directive] -> NonEmpty OperationTypeDefinition -> TypeSystemDefinition
TypeDefinition :: TypeDefinition -> TypeSystemDefinition
DirectiveDefinition :: Description -> Name -> ArgumentsDefinition -> NonEmpty DirectiveLocation -> TypeSystemDefinition
-- | Extension for a type system definition. Only schema and type
-- definitions can be extended.
data TypeSystemExtension
SchemaExtension :: SchemaExtension -> TypeSystemExtension
TypeExtension :: TypeExtension -> TypeSystemExtension
-- | List of types forming a union.
--
-- -- union SearchResult = Person | Photo ---- -- Person and Photo are member types of the union -- SearchResult. newtype UnionMemberTypes t UnionMemberTypes :: t NamedType -> UnionMemberTypes t -- | Input value (literal or variable). data Value Variable :: Name -> Value Int :: Int32 -> Value Float :: Double -> Value String :: Text -> Value Boolean :: Bool -> Value Null :: Value Enum :: Name -> Value List :: [Value] -> Value Object :: [ObjectField Value] -> Value -- | Variable definition. -- -- Each operation can include a list of variables: -- --
-- query (protagonist: String = Zarathustra) {
-- getAuthor(protagonist: $protagonist)
-- }
--
--
-- This query defines an optional variable protagonist of type
-- String, its default value is Zarathustra. If no
-- default value is defined and no value is provided, a variable can
-- still be null if its type is nullable.
--
-- Variables are usually passed along with the query, but not in the
-- query itself. They make queries reusable.
data VariableDefinition
VariableDefinition :: Name -> Type -> Maybe ConstValue -> VariableDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.Definition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.Definition
instance GHC.Show.Show Language.GraphQL.AST.Document.TypeSystemDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.TypeSystemDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.TypeDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.TypeDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.TypeSystemExtension
instance GHC.Classes.Eq Language.GraphQL.AST.Document.TypeSystemExtension
instance GHC.Show.Show Language.GraphQL.AST.Document.TypeExtension
instance GHC.Classes.Eq Language.GraphQL.AST.Document.TypeExtension
instance GHC.Show.Show Language.GraphQL.AST.Document.EnumValueDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.EnumValueDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.FieldDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.FieldDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.ArgumentsDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.ArgumentsDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.InputValueDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.InputValueDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.Description
instance GHC.Classes.Eq Language.GraphQL.AST.Document.Description
instance GHC.Show.Show Language.GraphQL.AST.Document.SchemaExtension
instance GHC.Classes.Eq Language.GraphQL.AST.Document.SchemaExtension
instance GHC.Show.Show Language.GraphQL.AST.Document.OperationTypeDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.OperationTypeDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.ExecutableDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.ExecutableDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.OperationDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.OperationDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.FragmentDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.FragmentDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.Selection
instance GHC.Classes.Eq Language.GraphQL.AST.Document.Selection
instance GHC.Show.Show Language.GraphQL.AST.Document.Directive
instance GHC.Classes.Eq Language.GraphQL.AST.Document.Directive
instance GHC.Show.Show Language.GraphQL.AST.Document.VariableDefinition
instance GHC.Classes.Eq Language.GraphQL.AST.Document.VariableDefinition
instance GHC.Show.Show Language.GraphQL.AST.Document.Type
instance GHC.Classes.Eq Language.GraphQL.AST.Document.Type
instance GHC.Show.Show Language.GraphQL.AST.Document.NonNullType
instance GHC.Classes.Eq Language.GraphQL.AST.Document.NonNullType
instance GHC.Show.Show Language.GraphQL.AST.Document.Argument
instance GHC.Classes.Eq Language.GraphQL.AST.Document.Argument
instance GHC.Show.Show Language.GraphQL.AST.Document.Value
instance GHC.Classes.Eq Language.GraphQL.AST.Document.Value
instance GHC.Show.Show Language.GraphQL.AST.Document.ConstValue
instance GHC.Classes.Eq Language.GraphQL.AST.Document.ConstValue
instance GHC.Show.Show a => GHC.Show.Show (Language.GraphQL.AST.Document.ObjectField a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.GraphQL.AST.Document.ObjectField a)
instance GHC.Show.Show Language.GraphQL.AST.Document.OperationType
instance GHC.Classes.Eq Language.GraphQL.AST.Document.OperationType
instance Data.Foldable.Foldable t => GHC.Classes.Eq (Language.GraphQL.AST.Document.UnionMemberTypes t)
instance Data.Foldable.Foldable t => GHC.Show.Show (Language.GraphQL.AST.Document.UnionMemberTypes t)
instance GHC.Base.Semigroup Language.GraphQL.AST.Document.ArgumentsDefinition
instance GHC.Base.Monoid Language.GraphQL.AST.Document.ArgumentsDefinition
instance Data.Foldable.Foldable t => GHC.Classes.Eq (Language.GraphQL.AST.Document.ImplementsInterfaces t)
instance Data.Foldable.Foldable t => GHC.Show.Show (Language.GraphQL.AST.Document.ImplementsInterfaces t)
-- | Target AST for Parser.
module Language.GraphQL.AST
-- | This module defines a minifier and a printer for the GraphQL
-- language.
module Language.GraphQL.AST.Encoder
-- | Instructs the encoder whether the GraphQL document should be minified
-- or pretty printed.
--
-- Use pretty or minified to construct the formatter.
data Formatter
-- | Converts a tDefinition into a string.
definition :: Formatter -> ExecutableDefinition -> Text
-- | Converts a Directive into a string.
directive :: Formatter -> Directive -> Text
-- | Converts a Document' into a string.
document :: Formatter -> Document -> Text
-- | Constructs a formatter for minifying.
minified :: Formatter
-- | Constructs a formatter for pretty printing.
pretty :: Formatter
-- | Converts a Type a type into a string.
type' :: Type -> Text
-- | Converts a Value into a string.
value :: Formatter -> Value -> Text
-- | This module defines a bunch of small parsers used to parse individual
-- lexemes.
module Language.GraphQL.AST.Lexer
-- | Standard parser. Accepts the type of the parsed token.
type Parser = Parsec Void Text
-- | Parser for "&".
amp :: Parser Text
-- | Parser for "@".
at :: Parser Text
-- | Parser for "!".
bang :: Parser Text
-- | Parser for block strings.
blockString :: Parser Text
-- | Parser for an expression between "{" and "}".
braces :: forall a. Parser a -> Parser a
-- | Parser for an expression between "[" and "]".
brackets :: forall a. Parser a -> Parser a
-- | Parser for ":".
colon :: Parser Text
-- | Parser for "$".
dollar :: Parser Text
-- | Parser for comments.
comment :: Parser ()
-- | Parser for "=".
equals :: Parser Text
-- | Parses "extend" followed by a symbol. It is used by schema
-- extensions.
extend :: forall a. Text -> String -> NonEmpty (Parser a) -> Parser a
-- | Parser for integers.
integer :: Integral a => Parser a
-- | Parser for floating-point numbers.
float :: Parser Double
-- | Lexeme definition which ignores whitespaces and commas.
lexeme :: forall a. Parser a -> Parser a
-- | Parser for names ([_A-Za-z][_0-9A-Za-z]*).
name :: Parser Text
-- | Parser for an expression between "(" and ")".
parens :: forall a. Parser a -> Parser a
-- | Parser for "|".
pipe :: Parser Text
-- | Parser that skips comments and meaningless characters, whitespaces and
-- commas.
spaceConsumer :: Parser ()
-- | Parser for the spread operator (...).
spread :: Parser Text
-- | Parser for strings.
string :: Parser Text
-- | Symbol definition which ignores whitespaces and commas.
symbol :: Text -> Parser Text
-- | Parser for the "Byte Order Mark".
unicodeBOM :: Parser ()
-- | GraphQL document parser.
module Language.GraphQL.AST.Parser
-- | Parser for the GraphQL documents.
document :: Parser Document
-- | This is the AST meant to be executed.
module Language.GraphQL.AST.Core
-- | Argument list.
newtype Arguments
Arguments :: HashMap Name Value -> Arguments
instance GHC.Show.Show Language.GraphQL.AST.Core.Arguments
instance GHC.Classes.Eq Language.GraphQL.AST.Core.Arguments
instance GHC.Base.Semigroup Language.GraphQL.AST.Core.Arguments
instance GHC.Base.Monoid Language.GraphQL.AST.Core.Arguments
-- | Monad transformer stack used by the GraphQL resolvers.
module Language.GraphQL.Trans
-- | Retrieves an argument by its name. If the argument with this name
-- couldn't be found, returns Null (i.e. the argument is assumed
-- to be optional then).
argument :: Monad m => Name -> ActionT m Value
-- | Monad transformer stack used by the resolvers to provide error
-- handling and resolution context (resolver arguments).
newtype ActionT m a
ActionT :: ExceptT Text (ReaderT Context m) a -> ActionT m a
[runActionT] :: ActionT m a -> ExceptT Text (ReaderT Context m) a
-- | Resolution context holds resolver arguments.
data Context
Context :: Arguments -> Value -> Context
[arguments] :: Context -> Arguments
[values] :: Context -> Value
instance GHC.Base.Functor m => GHC.Base.Functor (Language.GraphQL.Trans.ActionT m)
instance GHC.Base.Monad m => GHC.Base.Applicative (Language.GraphQL.Trans.ActionT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Language.GraphQL.Trans.ActionT m)
instance Control.Monad.Trans.Class.MonadTrans Language.GraphQL.Trans.ActionT
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Language.GraphQL.Trans.ActionT m)
instance GHC.Base.Monad m => GHC.Base.Alternative (Language.GraphQL.Trans.ActionT m)
instance GHC.Base.Monad m => GHC.Base.MonadPlus (Language.GraphQL.Trans.ActionT m)
-- | Input types and values.
--
-- This module is intended to be imported qualified, to avoid name
-- clashes with Out.
module Language.GraphQL.Type.In
-- | Field argument definition.
data Argument
Argument :: Maybe Text -> Type -> Maybe Value -> Argument
-- | Single field of an InputObjectType.
data InputField
InputField :: Maybe Text -> Type -> Maybe Value -> InputField
-- | Input object type definition.
--
-- An input object defines a structured collection of fields which may be
-- supplied to a field argument.
data InputObjectType
InputObjectType :: Name -> Maybe Text -> HashMap Name InputField -> InputObjectType
-- | These types may be used as input types for arguments and directives.
--
-- GraphQL distinguishes between "wrapping" and "named" types. Each
-- wrapping type can wrap other wrapping or named types. Wrapping types
-- are lists and Non-Null types (named types are nullable by default).
data Type
NamedScalarType :: ScalarType -> Type
NamedEnumType :: EnumType -> Type
NamedInputObjectType :: InputObjectType -> Type
ListType :: Type -> Type
NonNullScalarType :: ScalarType -> Type
NonNullEnumType :: EnumType -> Type
NonNullInputObjectType :: InputObjectType -> Type
NonNullListType :: Type -> Type
-- | Checks whether the given input type is a non-null type.
isNonNullType :: Type -> Bool
-- | Matches either NamedEnumType or NonNullEnumType.
pattern EnumBaseType :: EnumType -> Type
-- | Matches either ListType or NonNullListType.
pattern ListBaseType :: Type -> Type
-- | Matches either NamedInputObjectType or
-- NonNullInputObjectType.
pattern InputObjectBaseType :: InputObjectType -> Type
-- | Matches either NamedScalarType or NonNullScalarType.
pattern ScalarBaseType :: ScalarType -> Type
instance GHC.Classes.Eq Language.GraphQL.Type.In.Type
instance GHC.Classes.Eq Language.GraphQL.Type.In.InputObjectType
-- | Output types and values.
--
-- This module is intended to be imported qualified, to avoid name
-- clashes with In.
module Language.GraphQL.Type.Out
-- | Output object field definition.
data Field m
Field :: Maybe Text -> Type m -> HashMap Name Argument -> Field m
-- | Interface Type Definition.
--
-- When a field can return one of a heterogeneous set of types, a
-- Interface type is used to describe what types are possible, and what
-- fields are in common across all types.
data InterfaceType m
InterfaceType :: Name -> Maybe Text -> [InterfaceType m] -> HashMap Name (Field m) -> InterfaceType m
-- | Object type definition.
--
-- Almost all of the GraphQL types you define will be object types.
-- Object types have a name, but most importantly describe their fields.
data ObjectType m
ObjectType :: Name -> Maybe Text -> [InterfaceType m] -> HashMap Name (Resolver m) -> ObjectType m
-- | Resolves a Field into an Aeson.Object with
-- error information (if an error has occurred). m is an
-- arbitrary monad, usually IO.
--
-- Resolving a field can result in a leaf value or an object, which is
-- represented as a list of nested resolvers, used to resolve the fields
-- of that object.
data Resolver m
Resolver :: Field m -> ActionT m Value -> Resolver m
-- | These types may be used as output types as the result of fields.
--
-- GraphQL distinguishes between "wrapping" and "named" types. Each
-- wrapping type can wrap other wrapping or named types. Wrapping types
-- are lists and Non-Null types (named types are nullable by default).
data Type m
NamedScalarType :: ScalarType -> Type m
NamedEnumType :: EnumType -> Type m
NamedObjectType :: ObjectType m -> Type m
NamedInterfaceType :: InterfaceType m -> Type m
NamedUnionType :: UnionType m -> Type m
ListType :: Type m -> Type m
NonNullScalarType :: ScalarType -> Type m
NonNullEnumType :: EnumType -> Type m
NonNullObjectType :: ObjectType m -> Type m
NonNullInterfaceType :: InterfaceType m -> Type m
NonNullUnionType :: UnionType m -> Type m
NonNullListType :: Type m -> Type m
-- | Union Type Definition.
--
-- When a field can return one of a heterogeneous set of types, a Union
-- type is used to describe what types are possible.
data UnionType m
UnionType :: Name -> Maybe Text -> [ObjectType m] -> UnionType m
-- | Checks whether the given output type is a non-null type.
isNonNullType :: forall m. Type m -> Bool
-- | Matches either NamedEnumType or NonNullEnumType.
pattern EnumBaseType :: forall m. EnumType -> Type m
-- | Matches either NamedInterfaceType or
-- NonNullInterfaceType.
pattern InterfaceBaseType :: forall m. InterfaceType m -> Type m
-- | Matches either ListType or NonNullListType.
pattern ListBaseType :: forall m. Type m -> Type m
-- | Matches either NamedObjectType or NonNullObjectType.
pattern ObjectBaseType :: forall m. ObjectType m -> Type m
-- | Matches either NamedScalarType or NonNullScalarType.
pattern ScalarBaseType :: forall m. ScalarType -> Type m
-- | Matches either NamedUnionType or NonNullUnionType.
pattern UnionBaseType :: forall m. UnionType m -> Type m
instance GHC.Classes.Eq (Language.GraphQL.Type.Out.Type m)
instance GHC.Classes.Eq (Language.GraphQL.Type.Out.ObjectType a)
instance GHC.Classes.Eq (Language.GraphQL.Type.Out.InterfaceType a)
instance GHC.Classes.Eq (Language.GraphQL.Type.Out.UnionType a)
-- | Reexports non-conflicting type system and schema definitions.
module Language.GraphQL.Type
-- | Single field of an InputObjectType.
data InputField
InputField :: Maybe Text -> Type -> Maybe Value -> InputField
-- | Input object type definition.
--
-- An input object defines a structured collection of fields which may be
-- supplied to a field argument.
data InputObjectType
InputObjectType :: Name -> Maybe Text -> HashMap Name InputField -> InputObjectType
-- | Output object field definition.
data Field m
Field :: Maybe Text -> Type m -> HashMap Name Argument -> Field m
-- | Interface Type Definition.
--
-- When a field can return one of a heterogeneous set of types, a
-- Interface type is used to describe what types are possible, and what
-- fields are in common across all types.
data InterfaceType m
InterfaceType :: Name -> Maybe Text -> [InterfaceType m] -> HashMap Name (Field m) -> InterfaceType m
-- | Object type definition.
--
-- Almost all of the GraphQL types you define will be object types.
-- Object types have a name, but most importantly describe their fields.
data ObjectType m
ObjectType :: Name -> Maybe Text -> [InterfaceType m] -> HashMap Name (Resolver m) -> ObjectType m
-- | Union Type Definition.
--
-- When a field can return one of a heterogeneous set of types, a Union
-- type is used to describe what types are possible.
data UnionType m
UnionType :: Name -> Maybe Text -> [ObjectType m] -> UnionType m
-- | Enum type definition.
--
-- Some leaf values of requests and input values are Enums. GraphQL
-- serializes Enum values as strings, however internally Enums can be
-- represented by any kind of type, often integers.
data EnumType
EnumType :: Name -> Maybe Text -> HashMap Name EnumValue -> EnumType
-- | Enum value is a single member of an EnumType.
newtype EnumValue
EnumValue :: Maybe Text -> EnumValue
-- | Scalar type definition.
--
-- The leaf values of any request and input values to arguments are
-- Scalars (or Enums) .
data ScalarType
ScalarType :: Name -> Maybe Text -> ScalarType
-- | Contains variables for the query. The key of the map is a variable
-- name, and the value is the variable value.
type Subs = HashMap Name Value
-- | Represents accordingly typed GraphQL values.
data Value
Int :: Int32 -> Value
-- | GraphQL Float is double precision.
Float :: Double -> Value
String :: Text -> Value
Boolean :: Bool -> Value
Null :: Value
Enum :: Name -> Value
-- | Arbitrary nested list.
List :: [Value] -> Value
Object :: HashMap Name Value -> Value
-- | The Boolean scalar type represents true or
-- false.
boolean :: ScalarType
-- | The Float scalar type represents signed double-precision
-- fractional values as specified by IEEE 754.
float :: ScalarType
-- | The ID scalar type represents a unique identifier, often used
-- to refetch an object or as key for a cache. The ID type appears in a
-- JSON response as a String; however, it is not intended to be
-- human-readable. When expected as an input type, any string (such as
-- "4") or integer (such as 4) input value will be
-- accepted as an ID.
id :: ScalarType
-- | The Int scalar type represents non-fractional signed whole
-- numeric values. Int can represent values between <math> and
-- <math>.
int :: ScalarType
-- | The String scalar type represents textual data, represented
-- as UTF-8 character sequences. The String type is most often used by
-- GraphQL to represent free-form human-readable text.
string :: ScalarType
-- | A Schema is created by supplying the root types of each type of
-- operation, query and mutation (optional). A schema definition is then
-- supplied to the validator and executor.
--
-- Note: When the schema is constructed, by default only the types
-- that are reachable by traversing the root types are included, other
-- types must be explicitly referenced.
data Schema m
Schema :: ObjectType m -> Maybe (ObjectType m) -> Schema m
[query] :: Schema m -> ObjectType m
[mutation] :: Schema m -> Maybe (ObjectType m)
-- | Types and functions used for input and result coercion.
module Language.GraphQL.Execute.Coerce
-- | Intermediate type used to serialize a GraphQL value.
--
-- The serialization is done during the execution, and Output
-- contains already serialized data (in List and Object) as
-- well as the new layer that has to be serialized in the current step.
-- So Output is parameterized by the serialization format.
data Output a
Int :: Int32 -> Output a
Float :: Double -> Output a
String :: Text -> Output a
Boolean :: Bool -> Output a
Enum :: Name -> Output a
List :: [a] -> Output a
Object :: Map Name a -> Output a
-- | Serialize describes how a GraphQL value should be
-- serialized.
class Serialize a
-- | Serializes a GraphQL value according to the given
-- serialization format.
--
-- Type infomration is given as a hint, e.g. if you need to know what
-- type is being serialized to serialize it properly. Don't do any
-- validation for GraphQL built-in types here.
--
-- If the value cannot be serialized without losing information, return
-- Nothing — it will cause a field error.
serialize :: forall m. Serialize a => Type m -> Output a -> Maybe a
null :: Serialize a => a
-- | Since variables are passed separately from the query, in an
-- independent format, they should be first coerced to the internal
-- representation used by this implementation.
class VariableValue a
-- | Only a basic, format-specific, coercion must be done here. Type
-- correctness or nullability shouldn't be validated here, they will be
-- validated later. The type information is provided only as a hint.
--
-- For example GraphQL prohibits the coercion from a 't:Float'
-- to an 't:Int', but JSON doesn't have integers, so whole
-- numbers should be coerced to 't:Int` when receiving variables as a
-- JSON object. The same holds for 't:Enum'. There are formats that
-- support enumerations, JSON doesn't, so the type information
-- is given and coerceVariableValue can check that an 't:Enum' is
-- expected and treat the given value appropriately. Even checking
-- whether this value is a proper member of the corresponding 't:Enum'
-- type isn't required here, since this can be checked independently.
--
-- Another example is an ID. GraphQL explicitly allows
-- to coerce integers and strings to IDs, so if an ID
-- is received as an integer, it can be left as is and will be coerced
-- later.
--
-- If a value cannot be coerced without losing information,
-- Nothing should be returned, the coercion will fail then and the
-- query won't be executed.
coerceVariableValue :: VariableValue a => Type -> a -> Maybe Value
-- | Coerces operation arguments according to the input coercion rules for
-- the corresponding types.
coerceInputLiteral :: Type -> Value -> Maybe Value
-- | Looks up a value by name in the given map, coerces it and inserts into
-- the result map. If the coercion fails, returns Nothing. If the
-- value isn't given, but a default value is known, inserts the default
-- value into the result map. Otherwise it fails with Nothing if
-- the Input Type is a Non-Nullable type, or returns the unchanged,
-- original map.
matchFieldValues :: forall a. (Type -> a -> Maybe Value) -> HashMap Name a -> Name -> Type -> Maybe Value -> Maybe (HashMap Name Value) -> Maybe (HashMap Name Value)
instance GHC.Show.Show a => GHC.Show.Show (Language.GraphQL.Execute.Coerce.Output a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.GraphQL.Execute.Coerce.Output a)
instance Language.GraphQL.Execute.Coerce.Serialize Data.Aeson.Types.Internal.Value
instance Data.String.IsString (Language.GraphQL.Execute.Coerce.Output a)
instance Language.GraphQL.Execute.Coerce.VariableValue Data.Aeson.Types.Internal.Value
-- | Error handling.
module Language.GraphQL.Error
-- | Wraps a parse error into a list of errors.
parseError :: Applicative f => ParseErrorBundle Text Void -> f Value
-- | A wrapper to pass error messages around.
type CollectErrsT m = StateT (Resolution m) m
-- | Executor context.
data Resolution m
Resolution :: [Value] -> HashMap Name (Type m) -> Resolution m
[errors] :: Resolution m -> [Value]
[types] :: Resolution m -> HashMap Name (Type m)
-- | Adds an error to the list of errors.
addErr :: Monad m => Value -> CollectErrsT m ()
-- | Convenience function for just wrapping an error message.
addErrMsg :: Monad m => Text -> CollectErrsT m ()
-- | Runs the given query computation, but collects the errors into an
-- error list, which is then sent back with the data.
runCollectErrs :: Monad m => HashMap Name (Type m) -> CollectErrsT m Value -> m Value
-- | Constructs a response object containing only the error with the given
-- message.
singleError :: Text -> Value
-- | This module provides functions to execute a GraphQL request.
module Language.GraphQL.Execute
-- | The substitution is applied to the document, and the resolvers are
-- applied to the resulting fields.
--
-- Returns the result of the query against the schema wrapped in a
-- data field, or errors wrapped in an errors field.
execute :: (Monad m, VariableValue a) => Schema m -> HashMap Name a -> Document -> m Value
-- | The substitution is applied to the document, and the resolvers are
-- applied to the resulting fields. The operation name can be used if the
-- document defines multiple root operations.
--
-- Returns the result of the query against the schema wrapped in a
-- data field, or errors wrapped in an errors field.
executeWithName :: (Monad m, VariableValue a) => Schema m -> Text -> HashMap Name a -> Document -> m Value
-- | This module provides the functions to parse and execute
-- GraphQL queries.
module Language.GraphQL
-- | If the text parses correctly as a GraphQL query the query is
-- executed using the given Schema.
graphql :: Monad m => Schema m -> Text -> m Value
-- | If the text parses correctly as a GraphQL query the
-- substitution is applied to the query and the query is then executed
-- using to the given Schema.
graphqlSubs :: (Monad m, VariableValue a) => Schema m -> HashMap Name a -> Text -> m Value