-- 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.1.0 -- | This is the AST meant to be executed. module Language.GraphQL.AST.Core -- | 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
-- | GraphQL document is a non-empty list of operations.
type Document = NonEmpty Operation
-- | A single GraphQL field.
--
-- Only required property of a field, is its name. Optionally it can also
-- have an alias, arguments or a list of subfields.
--
-- Given the following query:
--
--
-- {
-- zuck: user(id: 4) {
-- id
-- 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
-- | Argument.
data Argument
Argument :: Name -> Value -> Argument
-- | Argument list.
-- | Deprecated: Use [Argument] instead
type Arguments = [Argument]
-- | Top-level definition of a document, either an operation or a fragment.
data Definition
DefinitionOperation :: OperationDefinition -> Definition
DefinitionFragment :: FragmentDefinition -> Definition
-- | Directive.
data Directive
Directive :: Name -> [Argument] -> Directive
-- | Directive list.
-- | Deprecated: Use [Directive] instead
type Directives = [Directive]
-- | GraphQL document.
type Document = NonEmpty Definition
-- | GraphQL field.
data Field
Field :: Maybe Alias -> Name -> [Argument] -> [Directive] -> SelectionSetOpt -> Field
-- | Fragment definition.
data FragmentDefinition
FragmentDefinition :: Name -> TypeCondition -> [Directive] -> SelectionSet -> FragmentDefinition
-- | Deprecated: Use Name instead
type FragmentName = Name
-- | Fragment spread.
data FragmentSpread
FragmentSpread :: Name -> [Directive] -> FragmentSpread
-- | Inline fragment.
data InlineFragment
InlineFragment :: Maybe TypeCondition -> [Directive] -> SelectionSet -> InlineFragment
-- | Name
type Name = Text
-- | 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
ObjectField :: Name -> Value -> ObjectField
-- | Operation definition.
data OperationDefinition
OperationSelectionSet :: SelectionSet -> OperationDefinition
OperationDefinition :: OperationType -> Maybe Name -> [VariableDefinition] -> [Directive] -> SelectionSet -> OperationDefinition
-- | GraphQL has 3 operation types: queries, mutations and subscribtions.
--
-- Currently only queries and mutations are supported.
data OperationType
Query :: OperationType
Mutation :: OperationType
-- | Single selection element.
data Selection
SelectionField :: Field -> Selection
SelectionFragmentSpread :: FragmentSpread -> Selection
SelectionInlineFragment :: InlineFragment -> Selection
-- | "Top-level" selection, selection on a operation.
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
-- | Input value.
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
-- | Variable definition.
data VariableDefinition
VariableDefinition :: Name -> Type -> Maybe Value -> VariableDefinition
-- | Variable definition list.
-- | Deprecated: Use [VariableDefinition] instead
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
-- | 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
-- | 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 [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
-- | 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.Parser
-- | Parser for the GraphQL documents.
document :: Parser Document
-- | Monad transformer stack used by the GraphQL resolvers.
module Language.GraphQL.Trans
-- | Monad transformer stack used by the resolvers to provide error
-- handling.
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.Object with
-- error information (if an error has occurred). 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.
-- | Deprecated: Use NonEmpty (Resolver m) instead
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 -> ([Argument] -> 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 -> ([Argument] -> ActionT m a) -> Resolver m
-- | Deprecated: Use scalar instead
enum :: MonadIO m => Name -> ActionT m [Text] -> Resolver m
-- | Deprecated: Use scalarA instead
enumA :: MonadIO m => Name -> ([Argument] -> 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] -> [Selection] -> CollectErrsT m Value
-- | Deprecated: Use wrappedScalar instead
wrappedEnum :: MonadIO m => Name -> ActionT m (Wrapping [Text]) -> Resolver m
-- | Deprecated: Use wrappedScalarA instead
wrappedEnumA :: MonadIO m => Name -> ([Argument] -> 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 -> ([Argument] -> 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 -> ([Argument] -> ActionT m (Wrapping a)) -> Resolver m
-- | A single GraphQL field.
--
-- Only required property of a field, is its name. Optionally it can also
-- have an alias, arguments or a list of subfields.
--
-- Given the following query:
--
--
-- {
-- zuck: user(id: 4) {
-- id
-- name
-- }
-- }
--
--
--
-- {
-- user(id: 4) {
-- name
-- }
-- }
--
--
-- Here "id" is an argument for the field "user" and its value is 4.
data Argument
Argument :: Name -> Value -> Argument
-- | Represents accordingly typed GraphQL values.
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
-- | After the document is parsed, before getting executed the AST is
-- transformed into a similar, simpler AST. This module is responsible
-- for this transformation.
module Language.GraphQL.AST.Transform
-- | Rewrites the original syntax tree into an intermediate representation
-- used for query execution.
document :: Subs -> Document -> Maybe Document
-- | 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 :: MonadIO m => NonEmpty (Resolver m) -> Subs -> 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 :: MonadIO m => NonEmpty (Resolver m) -> Text -> Subs -> 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 Resolvers.
graphql :: MonadIO m => NonEmpty (Resolver 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 Resolvers.
graphqlSubs :: MonadIO m => NonEmpty (Resolver m) -> Subs -> Text -> m Value