-- 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.5.0.0 -- | This is the AST meant to be executed. module Language.GraphQL.AST.Core type Alias = Name data Argument Argument :: Name -> Value -> Argument type Document = NonEmpty Operation data Field Field :: Maybe Alias -> Name -> [Argument] -> [Field] -> Field -- | Name type Name = Text data ObjectField ObjectField :: Name -> Value -> ObjectField data Operation Query :: Maybe Text -> NonEmpty Field -> Operation Mutation :: Maybe Text -> NonEmpty Field -> Operation data Value ValueInt :: Int32 -> Value ValueFloat :: Double -> Value ValueString :: Text -> Value ValueBoolean :: Bool -> Value ValueNull :: Value ValueEnum :: Name -> Value ValueList :: [Value] -> Value ValueObject :: [ObjectField] -> Value instance GHC.Show.Show Language.GraphQL.AST.Core.Operation instance GHC.Classes.Eq Language.GraphQL.AST.Core.Operation instance GHC.Show.Show Language.GraphQL.AST.Core.Field instance GHC.Classes.Eq Language.GraphQL.AST.Core.Field instance GHC.Show.Show Language.GraphQL.AST.Core.Argument instance GHC.Classes.Eq Language.GraphQL.AST.Core.Argument instance GHC.Show.Show Language.GraphQL.AST.Core.Value instance GHC.Classes.Eq Language.GraphQL.AST.Core.Value instance GHC.Show.Show Language.GraphQL.AST.Core.ObjectField instance GHC.Classes.Eq Language.GraphQL.AST.Core.ObjectField instance Data.String.IsString Language.GraphQL.AST.Core.Value -- | This module defines an abstract syntax tree for the GraphQL -- language based on Facebook's GraphQL Specification. -- -- Target AST for Parser. module Language.GraphQL.AST type Alias = Name data Argument Argument :: Name -> Value -> Argument type Arguments = [Argument] data Definition DefinitionOperation :: OperationDefinition -> Definition DefinitionFragment :: FragmentDefinition -> Definition data Directive Directive :: Name -> [Argument] -> Directive type Directives = [Directive] type Document = NonEmpty Definition data Field Field :: Maybe Alias -> Name -> Arguments -> Directives -> SelectionSetOpt -> Field data FragmentDefinition FragmentDefinition :: FragmentName -> TypeCondition -> Directives -> SelectionSet -> FragmentDefinition type FragmentName = Name data FragmentSpread FragmentSpread :: Name -> Directives -> FragmentSpread data InlineFragment InlineFragment :: Maybe TypeCondition -> Directives -> SelectionSet -> InlineFragment -- | Name type Name = Text data NonNullType NonNullTypeNamed :: Name -> NonNullType NonNullTypeList :: Type -> NonNullType data ObjectField ObjectField :: Name -> Value -> ObjectField data OperationDefinition OperationSelectionSet :: SelectionSet -> OperationDefinition OperationDefinition :: OperationType -> Maybe Name -> VariableDefinitions -> Directives -> SelectionSet -> OperationDefinition data OperationType Query :: OperationType Mutation :: OperationType data Selection SelectionField :: Field -> Selection SelectionFragmentSpread :: FragmentSpread -> Selection SelectionInlineFragment :: InlineFragment -> Selection type SelectionSet = NonEmpty Selection type SelectionSetOpt = [Selection] data Type TypeNamed :: Name -> Type TypeList :: Type -> Type TypeNonNull :: NonNullType -> Type type TypeCondition = Name data Value ValueVariable :: Name -> Value ValueInt :: Int32 -> Value ValueFloat :: Double -> Value ValueString :: Text -> Value ValueBoolean :: Bool -> Value ValueNull :: Value ValueEnum :: Name -> Value ValueList :: [Value] -> Value ValueObject :: [ObjectField] -> Value data VariableDefinition VariableDefinition :: Name -> Type -> Maybe Value -> VariableDefinition type VariableDefinitions = [VariableDefinition] instance GHC.Show.Show Language.GraphQL.AST.Definition instance GHC.Classes.Eq Language.GraphQL.AST.Definition instance GHC.Show.Show Language.GraphQL.AST.OperationDefinition instance GHC.Classes.Eq Language.GraphQL.AST.OperationDefinition instance GHC.Show.Show Language.GraphQL.AST.FragmentDefinition instance GHC.Classes.Eq Language.GraphQL.AST.FragmentDefinition instance GHC.Show.Show Language.GraphQL.AST.InlineFragment instance GHC.Classes.Eq Language.GraphQL.AST.InlineFragment instance GHC.Show.Show Language.GraphQL.AST.Selection instance GHC.Classes.Eq Language.GraphQL.AST.Selection instance GHC.Show.Show Language.GraphQL.AST.Field instance GHC.Classes.Eq Language.GraphQL.AST.Field instance GHC.Show.Show Language.GraphQL.AST.FragmentSpread instance GHC.Classes.Eq Language.GraphQL.AST.FragmentSpread instance GHC.Show.Show Language.GraphQL.AST.Directive instance GHC.Classes.Eq Language.GraphQL.AST.Directive instance GHC.Show.Show Language.GraphQL.AST.VariableDefinition instance GHC.Classes.Eq Language.GraphQL.AST.VariableDefinition instance GHC.Show.Show Language.GraphQL.AST.Type instance GHC.Classes.Eq Language.GraphQL.AST.Type instance GHC.Show.Show Language.GraphQL.AST.NonNullType instance GHC.Classes.Eq Language.GraphQL.AST.NonNullType instance GHC.Show.Show Language.GraphQL.AST.Argument instance GHC.Classes.Eq Language.GraphQL.AST.Argument instance GHC.Show.Show Language.GraphQL.AST.Value instance GHC.Classes.Eq Language.GraphQL.AST.Value instance GHC.Show.Show Language.GraphQL.AST.ObjectField instance GHC.Classes.Eq Language.GraphQL.AST.ObjectField instance GHC.Show.Show Language.GraphQL.AST.OperationType instance GHC.Classes.Eq Language.GraphQL.AST.OperationType -- | This module defines a minifier and a printer for the GraphQL -- language. module Language.GraphQL.Encoder -- | Instructs the encoder whether a GraphQL should be minified or pretty -- printed. -- -- Use pretty and minified to construct the formatter. data Formatter -- | Converts a Definition into a string. definition :: Formatter -> Definition -> Text -- | Converts a Directive into a string. directive :: Formatter -> Directive -> Text -- | Converts a Document into a string. document :: Formatter -> Document -> Text minified :: Formatter pretty :: Formatter -- | Converts a Type a type into a string. type' :: Type -> Text -- | Converts a Value into a string. value :: Formatter -> Value -> Text 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 [Value] 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 => CollectErrsT m Value -> m Value -- | Runs the given computation, collecting the errors and appending them -- to the previous list of errors. runAppendErrs :: Monad m => CollectErrsT m a -> CollectErrsT m a -- | Constructs a response object containing only the error with the given -- message. singleError :: Text -> Value -- | This module defines a bunch of small parsers used to parse individual -- lexemes. module Language.GraphQL.Lexer -- | Standard parser. Accepts the type of the parsed token. type Parser = Parsec Void Text -- | Parser for "&". amp :: Parser Text -- | Parser for "@". at :: Parser Char -- | Parser for "!". bang :: Parser Char -- | 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 Char -- | Parser for comments. comment :: Parser () -- | Parser for "=". equals :: Parser Text -- | 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 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 () module Language.GraphQL.Parser document :: Parser Document module Language.GraphQL.Trans newtype ActionT m a ActionT :: ExceptT Text m a -> ActionT m a [runActionT] :: ActionT m a -> ExceptT Text m a 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) -- | Definitions for GraphQL type system. module Language.GraphQL.Type -- | 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). -- -- This Wrapping type doesn't reflect this distinction exactly but -- it is used in the resolvers to take into account that the returned -- value can be nullable or an (arbitrary nested) list. data Wrapping a -- | Arbitrary nested list List :: [Wrapping a] -> Wrapping a -- | Named type without further wrapping Named :: a -> Wrapping a -- | Null Null :: Wrapping a instance GHC.Show.Show a => GHC.Show.Show (Language.GraphQL.Type.Wrapping a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.GraphQL.Type.Wrapping a) instance GHC.Base.Functor Language.GraphQL.Type.Wrapping instance Data.Foldable.Foldable Language.GraphQL.Type.Wrapping instance Data.Traversable.Traversable Language.GraphQL.Type.Wrapping instance GHC.Base.Applicative Language.GraphQL.Type.Wrapping instance GHC.Base.Monad Language.GraphQL.Type.Wrapping instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Language.GraphQL.Type.Wrapping a) -- | This module provides a representation of a GraphQL Schema in -- addition to functions for defining and manipulating Schemas. module Language.GraphQL.Schema -- | Resolves a Field into an Aeson.Value with error -- information (or empty). m is usually expected to be -- an instance of 'MonadIO. data Resolver m -- | A GraphQL schema. m is usually expected to be an instance of -- MonadIO. type Schema m = NonEmpty (Resolver m) -- | Variable substitution function. type Subs = Name -> Maybe Value -- | Create a new Resolver with the given Name from the given -- Resolvers. object :: MonadIO m => Name -> ActionT m [Resolver m] -> Resolver m -- | Like object but also taking Arguments. objectA :: MonadIO m => Name -> (Arguments -> ActionT m [Resolver m]) -> Resolver m -- | A scalar represents a primitive value, like a string or an integer. scalar :: (MonadIO m, ToJSON a) => Name -> ActionT m a -> Resolver m -- | Like scalar but also taking Arguments. scalarA :: (MonadIO m, ToJSON a) => Name -> (Arguments -> ActionT m a) -> Resolver m -- | Represents one of a finite set of possible values. Used in place of a -- scalar when the possible responses are easily enumerable. enum :: MonadIO m => Name -> ActionT m [Text] -> Resolver m -- | Like enum but also taking Arguments. enumA :: MonadIO m => Name -> (Arguments -> ActionT m [Text]) -> Resolver m -- | Takes a list of Resolvers and a list of Fields and -- applies each Resolver to each Field. Resolves into a -- value containing the resolved Field, or a null value and error -- information. resolve :: MonadIO m => [Resolver m] -> Fields -> CollectErrsT m Value -- | Like enum but can be null or a list of enums. wrappedEnum :: MonadIO m => Name -> ActionT m (Wrapping [Text]) -> Resolver m -- | Like enum but also taking Arguments and can be null or a -- list of enums. wrappedEnumA :: MonadIO m => Name -> (Arguments -> ActionT m (Wrapping [Text])) -> Resolver m -- | Like object but can be null or a list of objects. wrappedObject :: MonadIO m => Name -> ActionT m (Wrapping [Resolver m]) -> Resolver m -- | Like object but also taking Arguments and can be null or -- a list of objects. wrappedObjectA :: MonadIO m => Name -> (Arguments -> ActionT m (Wrapping [Resolver m])) -> Resolver m -- | Like scalar but can be null or a list of scalars. wrappedScalar :: (MonadIO m, ToJSON a) => Name -> ActionT m (Wrapping a) -> Resolver m -- | Lika scalar but also taking Arguments and can be null or -- a list of scalars. wrappedScalarA :: (MonadIO m, ToJSON a) => Name -> (Arguments -> ActionT m (Wrapping a)) -> Resolver m data Field data Argument Argument :: Name -> Value -> Argument data Value ValueInt :: Int32 -> Value ValueFloat :: Double -> Value ValueString :: Text -> Value ValueBoolean :: Bool -> Value ValueNull :: Value ValueEnum :: Name -> Value ValueList :: [Value] -> Value ValueObject :: [ObjectField] -> Value module Language.GraphQL.AST.Transform document :: Subs -> Document -> Maybe Document -- | This module provides the function to execute a GraphQL -- request -- according to a Schema. module Language.GraphQL.Execute -- | Takes a Schema, a variable substitution function (Subs), -- and a GraphQL document. The substitution is applied to -- the document using rootFields, and the Schema's -- 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 :: MonadIO m => Schema m -> Subs -> Document -> m Value -- | Takes a Schema, operation name, a variable substitution -- function (Subs), and a GraphQL document. The -- substitution is applied to the document using rootFields, and -- the Schema's 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. executeWithName :: MonadIO m => Schema m -> Text -> Subs -> Document -> m Value -- | This module provides the functions to parse and execute -- GraphQL queries. module Language.GraphQL -- | Takes a Schema and text representing a GraphQL request -- document. If the text parses correctly as a GraphQL query the -- query is executed according to the given Schema. -- -- Returns the response as an Aeson.Value. graphql :: MonadIO m => Schema m -> Text -> m Value -- | Takes a Schema, a variable substitution function and text -- representing a GraphQL request document. If the text parses -- correctly as a GraphQL query the substitution is applied to -- the query and the query is then executed according to the given -- Schema. -- -- Returns the response as an Aeson.Value. graphqlSubs :: MonadIO m => Schema m -> Subs -> Text -> m Value