graphql-api-0.2.0: Sketch of GraphQL stuff

Safe HaskellNone
LanguageHaskell2010

GraphQL.Value

Contents

Description

Literal GraphQL values.

Synopsis

Documentation

type Value = Value' ConstScalar Source #

A GraphQL value which contains no variables.

data Value' scalar Source #

A GraphQL value. scalar represents the type of scalar that's contained within this value.

Normally, it is one of either ConstScalar (to indicate that there are no variables whatsoever) or VariableScalar (to indicate that there might be some variables).

Constructors

ValueScalar' scalar 
ValueList' (List' scalar) 
ValueObject' (Object' scalar) 

Instances

Functor Value' Source # 

Methods

fmap :: (a -> b) -> Value' a -> Value' b #

(<$) :: a -> Value' b -> Value' a #

Foldable Value' Source # 

Methods

fold :: Monoid m => Value' m -> m #

foldMap :: Monoid m => (a -> m) -> Value' a -> m #

foldr :: (a -> b -> b) -> b -> Value' a -> b #

foldr' :: (a -> b -> b) -> b -> Value' a -> b #

foldl :: (b -> a -> b) -> b -> Value' a -> b #

foldl' :: (b -> a -> b) -> b -> Value' a -> b #

foldr1 :: (a -> a -> a) -> Value' a -> a #

foldl1 :: (a -> a -> a) -> Value' a -> a #

toList :: Value' a -> [a] #

null :: Value' a -> Bool #

length :: Value' a -> Int #

elem :: Eq a => a -> Value' a -> Bool #

maximum :: Ord a => Value' a -> a #

minimum :: Ord a => Value' a -> a #

sum :: Num a => Value' a -> a #

product :: Num a => Value' a -> a #

Traversable Value' Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Value' a -> f (Value' b) #

sequenceA :: Applicative f => Value' (f a) -> f (Value' a) #

mapM :: Monad m => (a -> m b) -> Value' a -> m (Value' b) #

sequence :: Monad m => Value' (m a) -> m (Value' a) #

Eq scalar => Eq (Value' scalar) Source # 

Methods

(==) :: Value' scalar -> Value' scalar -> Bool #

(/=) :: Value' scalar -> Value' scalar -> Bool #

Ord scalar => Ord (Value' scalar) Source # 

Methods

compare :: Value' scalar -> Value' scalar -> Ordering #

(<) :: Value' scalar -> Value' scalar -> Bool #

(<=) :: Value' scalar -> Value' scalar -> Bool #

(>) :: Value' scalar -> Value' scalar -> Bool #

(>=) :: Value' scalar -> Value' scalar -> Bool #

max :: Value' scalar -> Value' scalar -> Value' scalar #

min :: Value' scalar -> Value' scalar -> Value' scalar #

Show scalar => Show (Value' scalar) Source # 

Methods

showsPrec :: Int -> Value' scalar -> ShowS #

show :: Value' scalar -> String #

showList :: [Value' scalar] -> ShowS #

Arbitrary scalar => Arbitrary (Value' scalar) Source # 

Methods

arbitrary :: Gen (Value' scalar) #

shrink :: Value' scalar -> [Value' scalar] #

ToJSON scalar => ToJSON (Value' scalar) Source # 

Methods

toJSON :: Value' scalar -> Value #

toEncoding :: Value' scalar -> Encoding #

toJSONList :: [Value' scalar] -> Value #

toEncodingList :: [Value' scalar] -> Encoding #

ToValue (Value' ConstScalar) Source # 

type UnresolvedVariableValue = Value' UnresolvedVariableScalar Source #

A GraphQL value which might contain some variables. These variables are not yet associated with <https://facebook.github.io/graphql/#VariableDefinition variable definitions> (see also VariableDefinition), which are provided in a different context.

pattern ValueInt :: Int32 -> Value Source #

pattern ValueEnum :: Name -> Value Source #

pattern ValueList :: forall t. List' t -> Value' t Source #

pattern ValueObject :: forall t. Object' t -> Value' t Source #

pattern ValueNull :: Value Source #

toObject :: Value' scalar -> Maybe (Object' scalar) Source #

If a value is an object, return just that. Otherwise Nothing.

valueToAST :: Value -> Value Source #

Convert a value to an AST value.

astToVariableValue :: HasCallStack => Value -> Maybe UnresolvedVariableValue Source #

Convert an AST value to a variable value.

Will fail if the AST value contains duplicate object fields, or is otherwise invalid.

variableValueToAST :: UnresolvedVariableValue -> Value Source #

Convert a variable value to an AST value.

type List = List' ConstScalar Source #

A list of values that are known to be constants.

Note that this list might not be valid GraphQL, because GraphQL only allows homogeneous lists (i.e. all elements of the same type), and we do no type checking at this point.

newtype List' scalar Source #

Constructors

List' [Value' scalar] 

Instances

Functor List' Source # 

Methods

fmap :: (a -> b) -> List' a -> List' b #

(<$) :: a -> List' b -> List' a #

Foldable List' Source # 

Methods

fold :: Monoid m => List' m -> m #

foldMap :: Monoid m => (a -> m) -> List' a -> m #

foldr :: (a -> b -> b) -> b -> List' a -> b #

foldr' :: (a -> b -> b) -> b -> List' a -> b #

foldl :: (b -> a -> b) -> b -> List' a -> b #

foldl' :: (b -> a -> b) -> b -> List' a -> b #

foldr1 :: (a -> a -> a) -> List' a -> a #

foldl1 :: (a -> a -> a) -> List' a -> a #

toList :: List' a -> [a] #

null :: List' a -> Bool #

length :: List' a -> Int #

elem :: Eq a => a -> List' a -> Bool #

maximum :: Ord a => List' a -> a #

minimum :: Ord a => List' a -> a #

sum :: Num a => List' a -> a #

product :: Num a => List' a -> a #

Traversable List' Source # 

Methods

traverse :: Applicative f => (a -> f b) -> List' a -> f (List' b) #

sequenceA :: Applicative f => List' (f a) -> f (List' a) #

mapM :: Monad m => (a -> m b) -> List' a -> m (List' b) #

sequence :: Monad m => List' (m a) -> m (List' a) #

ToValue List Source # 
Eq scalar => Eq (List' scalar) Source # 

Methods

(==) :: List' scalar -> List' scalar -> Bool #

(/=) :: List' scalar -> List' scalar -> Bool #

Ord scalar => Ord (List' scalar) Source # 

Methods

compare :: List' scalar -> List' scalar -> Ordering #

(<) :: List' scalar -> List' scalar -> Bool #

(<=) :: List' scalar -> List' scalar -> Bool #

(>) :: List' scalar -> List' scalar -> Bool #

(>=) :: List' scalar -> List' scalar -> Bool #

max :: List' scalar -> List' scalar -> List' scalar #

min :: List' scalar -> List' scalar -> List' scalar #

Show scalar => Show (List' scalar) Source # 

Methods

showsPrec :: Int -> List' scalar -> ShowS #

show :: List' scalar -> String #

showList :: [List' scalar] -> ShowS #

Arbitrary scalar => Arbitrary (List' scalar) Source # 

Methods

arbitrary :: Gen (List' scalar) #

shrink :: List' scalar -> [List' scalar] #

ToJSON scalar => ToJSON (List' scalar) Source # 

Methods

toJSON :: List' scalar -> Value #

toEncoding :: List' scalar -> Encoding #

toJSONList :: [List' scalar] -> Value #

toEncodingList :: [List' scalar] -> Encoding #

Names

makeName :: Text -> Either NameError Name Source #

Create a Name.

Names must match the regex [_A-Za-z][_0-9A-Za-z]*. If the given text does not match, return Nothing.

>>> makeName "foo"
Right (Name {unName = "foo"})
>>> makeName "9-bar"
Left (NameError "9-bar")

Objects

type Object = Object' ConstScalar Source #

A GraphQL object that contains only non-variable values.

newtype Object' scalar Source #

A GraphQL object.

Note that https://facebook.github.io/graphql/#sec-Response calls these "Maps", but everywhere else in the spec refers to them as objects.

Constructors

Object' (OrderedMap Name (Value' scalar)) 

Instances

Functor Object' Source # 

Methods

fmap :: (a -> b) -> Object' a -> Object' b #

(<$) :: a -> Object' b -> Object' a #

Foldable Object' Source # 

Methods

fold :: Monoid m => Object' m -> m #

foldMap :: Monoid m => (a -> m) -> Object' a -> m #

foldr :: (a -> b -> b) -> b -> Object' a -> b #

foldr' :: (a -> b -> b) -> b -> Object' a -> b #

foldl :: (b -> a -> b) -> b -> Object' a -> b #

foldl' :: (b -> a -> b) -> b -> Object' a -> b #

foldr1 :: (a -> a -> a) -> Object' a -> a #

foldl1 :: (a -> a -> a) -> Object' a -> a #

toList :: Object' a -> [a] #

null :: Object' a -> Bool #

length :: Object' a -> Int #

elem :: Eq a => a -> Object' a -> Bool #

maximum :: Ord a => Object' a -> a #

minimum :: Ord a => Object' a -> a #

sum :: Num a => Object' a -> a #

product :: Num a => Object' a -> a #

Traversable Object' Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Object' a -> f (Object' b) #

sequenceA :: Applicative f => Object' (f a) -> f (Object' a) #

mapM :: Monad m => (a -> m b) -> Object' a -> m (Object' b) #

sequence :: Monad m => Object' (m a) -> m (Object' a) #

Eq scalar => Eq (Object' scalar) Source # 

Methods

(==) :: Object' scalar -> Object' scalar -> Bool #

(/=) :: Object' scalar -> Object' scalar -> Bool #

Ord scalar => Ord (Object' scalar) Source # 

Methods

compare :: Object' scalar -> Object' scalar -> Ordering #

(<) :: Object' scalar -> Object' scalar -> Bool #

(<=) :: Object' scalar -> Object' scalar -> Bool #

(>) :: Object' scalar -> Object' scalar -> Bool #

(>=) :: Object' scalar -> Object' scalar -> Bool #

max :: Object' scalar -> Object' scalar -> Object' scalar #

min :: Object' scalar -> Object' scalar -> Object' scalar #

Show scalar => Show (Object' scalar) Source # 

Methods

showsPrec :: Int -> Object' scalar -> ShowS #

show :: Object' scalar -> String #

showList :: [Object' scalar] -> ShowS #

Arbitrary scalar => Arbitrary (Object' scalar) Source # 

Methods

arbitrary :: Gen (Object' scalar) #

shrink :: Object' scalar -> [Object' scalar] #

ToJSON scalar => ToJSON (Object' scalar) Source # 

Methods

toJSON :: Object' scalar -> Value #

toEncoding :: Object' scalar -> Encoding #

toJSONList :: [Object' scalar] -> Value #

toEncodingList :: [Object' scalar] -> Encoding #

ToValue (Object' ConstScalar) Source # 

type ObjectField = ObjectField' ConstScalar Source #

A field of an object that has a non-variable value.

data ObjectField' scalar Source #

Instances

Functor ObjectField' Source # 

Methods

fmap :: (a -> b) -> ObjectField' a -> ObjectField' b #

(<$) :: a -> ObjectField' b -> ObjectField' a #

Eq scalar => Eq (ObjectField' scalar) Source # 

Methods

(==) :: ObjectField' scalar -> ObjectField' scalar -> Bool #

(/=) :: ObjectField' scalar -> ObjectField' scalar -> Bool #

Ord scalar => Ord (ObjectField' scalar) Source # 

Methods

compare :: ObjectField' scalar -> ObjectField' scalar -> Ordering #

(<) :: ObjectField' scalar -> ObjectField' scalar -> Bool #

(<=) :: ObjectField' scalar -> ObjectField' scalar -> Bool #

(>) :: ObjectField' scalar -> ObjectField' scalar -> Bool #

(>=) :: ObjectField' scalar -> ObjectField' scalar -> Bool #

max :: ObjectField' scalar -> ObjectField' scalar -> ObjectField' scalar #

min :: ObjectField' scalar -> ObjectField' scalar -> ObjectField' scalar #

Show scalar => Show (ObjectField' scalar) Source # 

Methods

showsPrec :: Int -> ObjectField' scalar -> ShowS #

show :: ObjectField' scalar -> String #

showList :: [ObjectField' scalar] -> ShowS #

Arbitrary scalar => Arbitrary (ObjectField' scalar) Source # 

Methods

arbitrary :: Gen (ObjectField' scalar) #

shrink :: ObjectField' scalar -> [ObjectField' scalar] #

Constructing

makeObject :: [ObjectField' scalar] -> Maybe (Object' scalar) Source #

Make an object from a list of object fields.

objectFromList :: [(Name, Value' scalar)] -> Maybe (Object' scalar) Source #

Create an object from a list of (name, value) pairs.

objectFromOrderedMap :: OrderedMap Name (Value' scalar) -> Object' scalar Source #

Make an object from an ordered map.

Combining

unionObjects :: [Object' scalar] -> Maybe (Object' scalar) Source #

Querying

objectFields :: Object' scalar -> [ObjectField' scalar] Source #