-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | GraphQL API -- -- Implement GraphQL servers in Haskell. -- -- Provides a Servant-like type-based API for defining GraphQL schemas -- and implementing handlers for those schemas. -- -- See README.md for more details. @package graphql-api @version 0.4.0 module GraphQL.Internal.Arbitrary -- | Generate arbitrary Text. arbitraryText :: Gen Text -- | Generate an arbitrary NonEmpty list. arbitraryNonEmpty :: forall a. Arbitrary a => Gen (NonEmpty a) -- | There are many cases in GraphQL where we want to have a map from names -- to values, where values can easily be lookup up by name and name is -- unique. This would normally be modelled as a Map. However, in -- many of these cases, the order in which the entries appear matters. -- -- That is, -- --
-- {
-- foo: 1,
-- bar: 2
-- }
--
--
-- Is different to,
--
-- @ { bar: 2, foo: 1, }
--
-- Even though they have exactly the same keys, and the keys have exactly
-- the same values.
--
-- Goal for this module is to provide data structures that are "complete
-- enough" for implementing the rest of GraphQL.
module GraphQL.Internal.OrderedMap
data OrderedMap key value
-- | The empty OrderedMap. O(1)
empty :: forall key value. OrderedMap key value
-- | Create an ordered map containing a single entry. O(1)
singleton :: forall key value. key -> value -> OrderedMap key value
-- | Construct an ordered map from a list.
--
-- O(n log n).
--
-- If the list contains duplicate keys, then return Nothing.
-- Otherwise, return an OrderedMap, preserving the order.
orderedMap :: forall key value. Ord key => [(key, value)] -> Maybe (OrderedMap key value)
-- | Find a value in an ordered map.
--
-- O(log n)
lookup :: forall key value. Ord key => key -> OrderedMap key value -> Maybe value
-- | Take an ordered map with Maybe values and return the same map
-- with all the Nothing values removed.
catMaybes :: Ord key => OrderedMap key (Maybe value) -> OrderedMap key value
-- | The union of a list of ordered maps.
--
-- If any map shares a key with any other map, return Nothing.
--
-- Otherwise, return a new map containing all of the keys from all of the
-- maps. The keys from the first map will appear first, followed by the
-- second, and so forth.
--
-- O(m * n log (m * n)) where m is the number of maps, and
-- n is the size of the largest map.
unions :: forall key value. Ord key => [OrderedMap key value] -> Maybe (OrderedMap key value)
-- | Append the second ordered map to the first, combining any shared
-- elements with the given function.
unionWith :: Ord key => (value -> value -> value) -> OrderedMap key value -> OrderedMap key value -> OrderedMap key value
-- | Append together a list of ordered maps, preserving ordering of keys.
-- Combine any shared elements with the given function.
unionsWith :: Ord key => (value -> value -> value) -> [OrderedMap key value] -> OrderedMap key value
-- | Take two ordered maps, append the second one to the first. If the
-- second contains any keys that also appear in the first, combine the
-- two values with the given function.
unionWithM :: (Monad m, Ord key) => (value -> value -> m value) -> OrderedMap key value -> OrderedMap key value -> m (OrderedMap key value)
-- | Take a list of ordered maps and append them together. Any shared
-- elements are combined using the given function.
unionsWithM :: (Monad m, Ord key) => (value -> value -> m value) -> [OrderedMap key value] -> m (OrderedMap key value)
-- | Convert an ordered map to a list of keys and values. The list is
-- guaranteed to be the same order as the order of insertion into the
-- map.
--
-- O(n log n)
toList :: forall key value. Ord key => OrderedMap key value -> [(key, value)]
-- | Convert an ordered map to a regular map, losing insertion order.
toMap :: OrderedMap key value -> Map key value
-- | Get the list of keys from an ordered map, in order of appearance.
--
-- This list is guaranteed to have no duplicates.
keys :: OrderedMap key value -> [key]
-- | Get the values from an ordered map, in order of appearance. O(n log
-- n)
values :: forall key value. Ord key => OrderedMap key value -> [value]
-- | Generate an ordered map with the given key & value generators.
genOrderedMap :: forall key value. Ord key => Gen key -> Gen value -> Gen (OrderedMap key value)
instance (GHC.Show.Show key, GHC.Show.Show value) => GHC.Show.Show (GraphQL.Internal.OrderedMap.OrderedMap key value)
instance (GHC.Classes.Ord key, GHC.Classes.Ord value) => GHC.Classes.Ord (GraphQL.Internal.OrderedMap.OrderedMap key value)
instance (GHC.Classes.Eq key, GHC.Classes.Eq value) => GHC.Classes.Eq (GraphQL.Internal.OrderedMap.OrderedMap key value)
instance Data.Foldable.Foldable (GraphQL.Internal.OrderedMap.OrderedMap key)
instance Data.Traversable.Traversable (GraphQL.Internal.OrderedMap.OrderedMap key)
instance GHC.Base.Functor (GraphQL.Internal.OrderedMap.OrderedMap key)
instance (Test.QuickCheck.Arbitrary.Arbitrary key, Test.QuickCheck.Arbitrary.Arbitrary value, GHC.Classes.Ord key) => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Internal.OrderedMap.OrderedMap key value)
module GraphQL.Internal.Syntax.Tokens
tok :: Parser a -> Parser a
whiteSpace :: Parser ()
module GraphQL.Internal.Name
-- | A name in GraphQL.
--
-- https://facebook.github.io/graphql/#sec-Names
newtype Name
Name :: Text -> Name
[unName] :: Name -> Text
-- | An invalid name.
newtype NameError
NameError :: Text -> NameError
-- | Create a Name.
--
-- Names must match the regex [_A-Za-z][_0-9A-Za-z]*. If the
-- given text does not match, return NameError.
--
--
-- >>> makeName "foo"
-- Right (Name {unName = "foo"})
--
-- >>> makeName "9-bar"
-- Left (NameError "9-bar")
--
makeName :: Text -> Either NameError Name
-- | Convert a type-level Symbol into a GraphQL Name.
nameFromSymbol :: forall (n :: Symbol). KnownSymbol n => Either NameError Name
-- | Parser for Name.
nameParser :: Parser Name
-- | Types that implement this have values with a single canonical name in
-- a GraphQL schema.
--
-- e.g. a field foo(bar: Int32) would have the name
-- "foo".
--
-- If a thing *might* have a name, or has a name that might not be valid,
-- don't use this.
--
-- If a thing is aliased, then return the *original* name.
class HasName a
-- | Get the name of the object.
getName :: HasName a => a -> Name
-- | Create a Name, panicking if the given text is invalid.
--
-- Prefer makeName to this in all cases.
--
--
-- >>> unsafeMakeName "foo"
-- Name {unName = "foo"}
--
unsafeMakeName :: HasCallStack => Text -> Name
instance GHC.Show.Show GraphQL.Internal.Name.NameError
instance GHC.Classes.Eq GraphQL.Internal.Name.NameError
instance GHC.Show.Show GraphQL.Internal.Name.Name
instance GHC.Classes.Ord GraphQL.Internal.Name.Name
instance GHC.Classes.Eq GraphQL.Internal.Name.Name
instance Data.String.IsString GraphQL.Internal.Name.Name
instance Data.Aeson.Types.ToJSON.ToJSON GraphQL.Internal.Name.Name
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Name.Name
module GraphQL.Internal.Syntax.AST
-- | A QueryDocument is something a user might send us.
--
-- https://facebook.github.io/graphql/#sec-Language.Query-Document
newtype QueryDocument
QueryDocument :: [Definition] -> QueryDocument
[getDefinitions] :: QueryDocument -> [Definition]
-- | A SchemaDocument is a document that defines a GraphQL schema.
--
-- https://facebook.github.io/graphql/#sec-Type-System
newtype SchemaDocument
SchemaDocument :: [TypeDefinition] -> SchemaDocument
data Definition
DefinitionOperation :: OperationDefinition -> Definition
DefinitionFragment :: FragmentDefinition -> Definition
data OperationDefinition
Query :: Node -> OperationDefinition
Mutation :: Node -> OperationDefinition
AnonymousQuery :: SelectionSet -> OperationDefinition
data Node
Node :: Maybe Name -> [VariableDefinition] -> [Directive] -> SelectionSet -> Node
data VariableDefinition
VariableDefinition :: Variable -> GType -> Maybe DefaultValue -> VariableDefinition
newtype Variable
Variable :: Name -> Variable
type SelectionSet = [Selection]
data Selection
SelectionField :: Field -> Selection
SelectionFragmentSpread :: FragmentSpread -> Selection
SelectionInlineFragment :: InlineFragment -> Selection
data Field
Field :: Maybe Alias -> Name -> [Argument] -> [Directive] -> SelectionSet -> Field
type Alias = Name
data Argument
Argument :: Name -> Value -> Argument
data FragmentSpread
FragmentSpread :: Name -> [Directive] -> FragmentSpread
data InlineFragment
InlineFragment :: Maybe TypeCondition -> [Directive] -> SelectionSet -> InlineFragment
data FragmentDefinition
FragmentDefinition :: Name -> TypeCondition -> [Directive] -> SelectionSet -> FragmentDefinition
type TypeCondition = NamedType
data Value
ValueVariable :: Variable -> Value
ValueInt :: Int32 -> Value
ValueFloat :: Double -> Value
ValueBoolean :: Bool -> Value
ValueString :: StringValue -> Value
ValueEnum :: Name -> Value
ValueList :: ListValue -> Value
ValueObject :: ObjectValue -> Value
ValueNull :: Value
newtype StringValue
StringValue :: Text -> StringValue
newtype ListValue
ListValue :: [Value] -> ListValue
newtype ObjectValue
ObjectValue :: [ObjectField] -> ObjectValue
data ObjectField
ObjectField :: Name -> Value -> ObjectField
type DefaultValue = Value
data Directive
Directive :: Name -> [Argument] -> Directive
data GType
TypeNamed :: NamedType -> GType
TypeList :: ListType -> GType
TypeNonNull :: NonNullType -> GType
newtype NamedType
NamedType :: Name -> NamedType
newtype ListType
ListType :: GType -> ListType
data NonNullType
NonNullTypeNamed :: NamedType -> NonNullType
NonNullTypeList :: ListType -> NonNullType
data TypeDefinition
TypeDefinitionObject :: ObjectTypeDefinition -> TypeDefinition
TypeDefinitionInterface :: InterfaceTypeDefinition -> TypeDefinition
TypeDefinitionUnion :: UnionTypeDefinition -> TypeDefinition
TypeDefinitionScalar :: ScalarTypeDefinition -> TypeDefinition
TypeDefinitionEnum :: EnumTypeDefinition -> TypeDefinition
TypeDefinitionInputObject :: InputObjectTypeDefinition -> TypeDefinition
TypeDefinitionTypeExtension :: TypeExtensionDefinition -> TypeDefinition
data ObjectTypeDefinition
ObjectTypeDefinition :: Name -> Interfaces -> [FieldDefinition] -> ObjectTypeDefinition
type Interfaces = [NamedType]
data FieldDefinition
FieldDefinition :: Name -> ArgumentsDefinition -> GType -> FieldDefinition
type ArgumentsDefinition = [InputValueDefinition]
data InputValueDefinition
InputValueDefinition :: Name -> GType -> Maybe DefaultValue -> InputValueDefinition
data InterfaceTypeDefinition
InterfaceTypeDefinition :: Name -> [FieldDefinition] -> InterfaceTypeDefinition
data UnionTypeDefinition
UnionTypeDefinition :: Name -> [NamedType] -> UnionTypeDefinition
newtype ScalarTypeDefinition
ScalarTypeDefinition :: Name -> ScalarTypeDefinition
data EnumTypeDefinition
EnumTypeDefinition :: Name -> [EnumValueDefinition] -> EnumTypeDefinition
newtype EnumValueDefinition
EnumValueDefinition :: Name -> EnumValueDefinition
data InputObjectTypeDefinition
InputObjectTypeDefinition :: Name -> [InputValueDefinition] -> InputObjectTypeDefinition
newtype TypeExtensionDefinition
TypeExtensionDefinition :: ObjectTypeDefinition -> TypeExtensionDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.SchemaDocument
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.SchemaDocument
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.TypeDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.TypeDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.TypeExtensionDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.TypeExtensionDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.InputObjectTypeDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.InputObjectTypeDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.EnumTypeDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.EnumTypeDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.EnumValueDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.EnumValueDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.ScalarTypeDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.ScalarTypeDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.UnionTypeDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.UnionTypeDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.InterfaceTypeDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.InterfaceTypeDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.ObjectTypeDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.ObjectTypeDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.FieldDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.FieldDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.InputValueDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.InputValueDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.QueryDocument
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.QueryDocument
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Definition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Definition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.OperationDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.OperationDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Node
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Node
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.VariableDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.VariableDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.GType
instance GHC.Classes.Ord GraphQL.Internal.Syntax.AST.GType
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.GType
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.ListType
instance GHC.Classes.Ord GraphQL.Internal.Syntax.AST.ListType
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.ListType
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.NonNullType
instance GHC.Classes.Ord GraphQL.Internal.Syntax.AST.NonNullType
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.NonNullType
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.FragmentDefinition
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.FragmentDefinition
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Field
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Field
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Selection
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Selection
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.InlineFragment
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.InlineFragment
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.NamedType
instance GHC.Classes.Ord GraphQL.Internal.Syntax.AST.NamedType
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.NamedType
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.FragmentSpread
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.FragmentSpread
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Directive
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Directive
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Argument
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Argument
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.ListValue
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.ListValue
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.ObjectValue
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.ObjectValue
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Value
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Value
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.ObjectField
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.ObjectField
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.StringValue
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.StringValue
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Variable
instance GHC.Classes.Ord GraphQL.Internal.Syntax.AST.Variable
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Variable
instance GraphQL.Internal.Name.HasName GraphQL.Internal.Syntax.AST.GType
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.Value
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.ListValue
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.ObjectValue
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.ObjectField
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.StringValue
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.Variable
module GraphQL.Internal.Syntax.Parser
queryDocument :: Parser QueryDocument
-- | Parser for a schema document.
schemaDocument :: Parser SchemaDocument
value :: Parser Value
module GraphQL.Internal.Syntax.Encoder
queryDocument :: QueryDocument -> Text
schemaDocument :: SchemaDocument -> Text
value :: Value -> Text
module GraphQL.Internal.Value
-- | A GraphQL value which contains no variables.
type Value = Value' ConstScalar
-- | 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).
data Value' scalar
ValueScalar' :: scalar -> Value' scalar
ValueList' :: List' scalar -> Value' scalar
ValueObject' :: Object' scalar -> Value' scalar
-- | A non-variable value which contains no other values.
data ConstScalar
-- | 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.
type UnresolvedVariableValue = Value' UnresolvedVariableScalar
pattern ValueInt :: Int32 -> Value
pattern ValueFloat :: Double -> Value
pattern ValueBoolean :: Bool -> Value
pattern ValueString :: String -> Value
pattern ValueEnum :: Name -> Value
pattern ValueList :: forall t. List' t -> Value' t
pattern ValueObject :: forall t. Object' t -> Value' t
pattern ValueNull :: Value
-- | If a value is an object, return just that. Otherwise Nothing.
toObject :: Value' scalar -> Maybe (Object' scalar)
-- | Convert a value to an AST value.
valueToAST :: Value -> Value
-- | Convert an AST value to a variable value.
--
-- Will fail if the AST value contains duplicate object fields, or is
-- otherwise invalid.
astToVariableValue :: HasCallStack => Value -> Maybe UnresolvedVariableValue
-- | Convert a variable value to an AST value.
variableValueToAST :: UnresolvedVariableValue -> Value
-- | 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.
type List = List' ConstScalar
newtype List' scalar
List' :: [Value' scalar] -> List' scalar
newtype String
String :: Text -> String
-- | A name in GraphQL.
--
-- https://facebook.github.io/graphql/#sec-Names
newtype Name
Name :: Text -> Name
[unName] :: Name -> Text
-- | An invalid name.
newtype NameError
NameError :: Text -> NameError
-- | Create a Name.
--
-- Names must match the regex [_A-Za-z][_0-9A-Za-z]*. If the
-- given text does not match, return NameError.
--
--
-- >>> makeName "foo"
-- Right (Name {unName = "foo"})
--
-- >>> makeName "9-bar"
-- Left (NameError "9-bar")
--
makeName :: Text -> Either NameError Name
-- | A GraphQL object that contains only non-variable values.
type Object = Object' ConstScalar
-- | 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.
newtype Object' scalar
Object' :: OrderedMap Name (Value' scalar) -> Object' scalar
-- | A field of an object that has a non-variable value.
type ObjectField = ObjectField' ConstScalar
data ObjectField' scalar
pattern ObjectField :: forall t. Name -> Value' t -> ObjectField' t
-- | Make an object from a list of object fields.
makeObject :: [ObjectField' scalar] -> Maybe (Object' scalar)
-- | Create an object from a list of (name, value) pairs.
objectFromList :: [(Name, Value' scalar)] -> Maybe (Object' scalar)
-- | Make an object from an ordered map.
objectFromOrderedMap :: OrderedMap Name (Value' scalar) -> Object' scalar
unionObjects :: [Object' scalar] -> Maybe (Object' scalar)
objectFields :: Object' scalar -> [ObjectField' scalar]
instance GHC.Base.Functor GraphQL.Internal.Value.ObjectField'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Internal.Value.ObjectField' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Internal.Value.ObjectField' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Internal.Value.ObjectField' scalar)
instance GHC.Base.Functor GraphQL.Internal.Value.List'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Internal.Value.List' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Internal.Value.List' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Internal.Value.List' scalar)
instance GHC.Base.Functor GraphQL.Internal.Value.Value'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Internal.Value.Value' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Internal.Value.Value' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Internal.Value.Value' scalar)
instance GHC.Base.Functor GraphQL.Internal.Value.Object'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Internal.Value.Object' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Internal.Value.Object' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Internal.Value.Object' scalar)
instance GHC.Show.Show GraphQL.Internal.Value.ConstScalar
instance GHC.Classes.Ord GraphQL.Internal.Value.ConstScalar
instance GHC.Classes.Eq GraphQL.Internal.Value.ConstScalar
instance GHC.Show.Show GraphQL.Internal.Value.String
instance GHC.Classes.Ord GraphQL.Internal.Value.String
instance GHC.Classes.Eq GraphQL.Internal.Value.String
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Internal.Value.ObjectField' scalar)
instance Data.Foldable.Foldable GraphQL.Internal.Value.Value'
instance Data.Traversable.Traversable GraphQL.Internal.Value.Value'
instance Data.Aeson.Types.ToJSON.ToJSON scalar => Data.Aeson.Types.ToJSON.ToJSON (GraphQL.Internal.Value.Value' scalar)
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Internal.Value.Value' scalar)
instance Data.Foldable.Foldable GraphQL.Internal.Value.List'
instance Data.Traversable.Traversable GraphQL.Internal.Value.List'
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Internal.Value.List' scalar)
instance Data.Aeson.Types.ToJSON.ToJSON scalar => Data.Aeson.Types.ToJSON.ToJSON (GraphQL.Internal.Value.List' scalar)
instance Data.Foldable.Foldable GraphQL.Internal.Value.Object'
instance Data.Traversable.Traversable GraphQL.Internal.Value.Object'
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Internal.Value.Object' scalar)
instance Data.Aeson.Types.ToJSON.ToJSON scalar => Data.Aeson.Types.ToJSON.ToJSON (GraphQL.Internal.Value.Object' scalar)
instance Data.Aeson.Types.ToJSON.ToJSON GraphQL.Internal.Value.ConstScalar
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Value.ConstScalar
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Value.String
instance Data.Aeson.Types.ToJSON.ToJSON GraphQL.Internal.Value.String
module GraphQL.Internal.Value.ToValue
-- | Turn a Haskell value into a GraphQL value.
class ToValue a
toValue :: ToValue a => a -> Value' ConstScalar
instance GraphQL.Internal.Value.ToValue.ToValue (GraphQL.Internal.Value.Value' GraphQL.Internal.Value.ConstScalar)
instance GraphQL.Internal.Value.ToValue.ToValue a => GraphQL.Internal.Value.ToValue.ToValue [a]
instance GraphQL.Internal.Value.ToValue.ToValue a => GraphQL.Internal.Value.ToValue.ToValue (GHC.Maybe.Maybe a)
instance GraphQL.Internal.Value.ToValue.ToValue a => GraphQL.Internal.Value.ToValue.ToValue (GHC.Base.NonEmpty a)
instance GraphQL.Internal.Value.ToValue.ToValue GHC.Types.Bool
instance GraphQL.Internal.Value.ToValue.ToValue GHC.Int.Int32
instance GraphQL.Internal.Value.ToValue.ToValue GHC.Types.Double
instance GraphQL.Internal.Value.ToValue.ToValue GraphQL.Internal.Value.String
instance GraphQL.Internal.Value.ToValue.ToValue Data.Text.Internal.Text
instance GraphQL.Internal.Value.ToValue.ToValue GraphQL.Internal.Value.List
instance GraphQL.Internal.Value.ToValue.ToValue (GraphQL.Internal.Value.Object' GraphQL.Internal.Value.ConstScalar)
module GraphQL.Internal.Value.FromValue
-- | a can be converted from a GraphQL Value to a Haskell
-- value.
--
-- The FromValue instance converts Value to the type
-- expected by the handler function. It is the boundary between incoming
-- data and your custom application Haskell types.
--
-- FromValue has a generic instance for converting input objects
-- to records.
class FromValue a
-- | Convert an already-parsed value into a Haskell value, generally to be
-- passed to a handler.
fromValue :: FromValue a => Value' ConstScalar -> Either Text a
-- | Convert an already-parsed value into a Haskell value, generally to be
-- passed to a handler.
fromValue :: (FromValue a, Generic a, GenericFromValue (Rep a)) => Value' ConstScalar -> Either Text a
-- | Anything that can be converted to a value and from a value should
-- roundtrip.
prop_roundtripValue :: forall a. (Eq a, ToValue a, FromValue a) => a -> Bool
-- | Throw an error saying that value does not have the
-- expected type.
wrongType :: (MonadError Text m, Show a) => Text -> a -> m b
instance GraphQL.Internal.Value.FromValue.FromValue GHC.Int.Int32
instance GraphQL.Internal.Value.FromValue.FromValue GHC.Types.Double
instance GraphQL.Internal.Value.FromValue.FromValue GHC.Types.Bool
instance GraphQL.Internal.Value.FromValue.FromValue Data.Text.Internal.Text
instance GraphQL.Internal.Value.FromValue.FromValue v => GraphQL.Internal.Value.FromValue.FromValue [v]
instance GraphQL.Internal.Value.FromValue.FromValue v => GraphQL.Internal.Value.FromValue.FromValue (GHC.Base.NonEmpty v)
instance GraphQL.Internal.Value.FromValue.FromValue v => GraphQL.Internal.Value.FromValue.FromValue (GHC.Maybe.Maybe v)
instance (GHC.TypeLits.KnownSymbol fieldName, GraphQL.Internal.Value.FromValue.FromValue wrappedType) => GraphQL.Internal.Value.FromValue.GenericFromValue (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Maybe.Just fieldName) u s l) (GHC.Generics.Rec0 wrappedType))
instance (GHC.TypeLits.KnownSymbol dataName, GHC.TypeLits.KnownSymbol consName, GraphQL.Internal.Value.FromValue.GenericFromValue records) => GraphQL.Internal.Value.FromValue.GenericFromValue (GHC.Generics.D1 ('GHC.Generics.MetaData dataName s l 'GHC.Types.False) (GHC.Generics.C1 ('GHC.Generics.MetaCons consName p 'GHC.Types.True) records))
instance (GraphQL.Internal.Value.FromValue.GenericFromValue l, GraphQL.Internal.Value.FromValue.GenericFromValue r) => GraphQL.Internal.Value.FromValue.GenericFromValue (l GHC.Generics.:*: r)
instance (TypeError ...) => GraphQL.Internal.Value.FromValue.GenericFromValue (GHC.Generics.D1 m (l GHC.Generics.:+: r))
module GraphQL.Value
-- | A GraphQL value which contains no variables.
type Value = Value' ConstScalar
-- | 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).
data Value' scalar
ValueScalar' :: scalar -> Value' scalar
ValueList' :: List' scalar -> Value' scalar
ValueObject' :: Object' scalar -> Value' scalar
-- | A non-variable value which contains no other values.
data ConstScalar
-- | 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.
type UnresolvedVariableValue = Value' UnresolvedVariableScalar
pattern ValueInt :: Int32 -> Value
pattern ValueFloat :: Double -> Value
pattern ValueBoolean :: Bool -> Value
pattern ValueString :: String -> Value
pattern ValueEnum :: Name -> Value
pattern ValueList :: forall t. List' t -> Value' t
pattern ValueObject :: forall t. Object' t -> Value' t
pattern ValueNull :: Value
-- | If a value is an object, return just that. Otherwise Nothing.
toObject :: Value' scalar -> Maybe (Object' scalar)
-- | Convert a value to an AST value.
valueToAST :: Value -> Value
-- | Convert an AST value to a variable value.
--
-- Will fail if the AST value contains duplicate object fields, or is
-- otherwise invalid.
astToVariableValue :: HasCallStack => Value -> Maybe UnresolvedVariableValue
-- | Convert a variable value to an AST value.
variableValueToAST :: UnresolvedVariableValue -> Value
-- | 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.
type List = List' ConstScalar
newtype List' scalar
List' :: [Value' scalar] -> List' scalar
newtype String
String :: Text -> String
-- | A name in GraphQL.
--
-- https://facebook.github.io/graphql/#sec-Names
newtype Name
Name :: Text -> Name
[unName] :: Name -> Text
-- | An invalid name.
newtype NameError
NameError :: Text -> NameError
-- | Create a Name.
--
-- Names must match the regex [_A-Za-z][_0-9A-Za-z]*. If the
-- given text does not match, return NameError.
--
--
-- >>> makeName "foo"
-- Right (Name {unName = "foo"})
--
-- >>> makeName "9-bar"
-- Left (NameError "9-bar")
--
makeName :: Text -> Either NameError Name
-- | A GraphQL object that contains only non-variable values.
type Object = Object' ConstScalar
-- | 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.
newtype Object' scalar
Object' :: OrderedMap Name (Value' scalar) -> Object' scalar
-- | A field of an object that has a non-variable value.
type ObjectField = ObjectField' ConstScalar
data ObjectField' scalar
pattern ObjectField :: forall t. Name -> Value' t -> ObjectField' t
-- | Make an object from a list of object fields.
makeObject :: [ObjectField' scalar] -> Maybe (Object' scalar)
-- | Create an object from a list of (name, value) pairs.
objectFromList :: [(Name, Value' scalar)] -> Maybe (Object' scalar)
-- | Make an object from an ordered map.
objectFromOrderedMap :: OrderedMap Name (Value' scalar) -> Object' scalar
unionObjects :: [Object' scalar] -> Maybe (Object' scalar)
objectFields :: Object' scalar -> [ObjectField' scalar]
-- | Turn a Haskell value into a GraphQL value.
class ToValue a
toValue :: ToValue a => a -> Value' ConstScalar
-- | a can be converted from a GraphQL Value to a Haskell
-- value.
--
-- The FromValue instance converts Value to the type
-- expected by the handler function. It is the boundary between incoming
-- data and your custom application Haskell types.
--
-- FromValue has a generic instance for converting input objects
-- to records.
class FromValue a
-- | Convert an already-parsed value into a Haskell value, generally to be
-- passed to a handler.
fromValue :: FromValue a => Value' ConstScalar -> Either Text a
-- | Convert an already-parsed value into a Haskell value, generally to be
-- passed to a handler.
fromValue :: (FromValue a, Generic a, GenericFromValue (Rep a)) => Value' ConstScalar -> Either Text a
-- | Differs from Data.GraphQL.AST in the graphql package in
-- that there are no type references. Instead, everything is inlined.
--
-- Equivalent representation of GraphQL values is in
-- GraphQL.Value.
module GraphQL.Internal.Schema
data GType
DefinedType :: TypeDefinition -> GType
BuiltinType :: Builtin -> GType
-- | Types that are built into GraphQL.
--
-- The GraphQL spec refers to these as
-- "[scalars](https:/facebook.github.iographql/#sec-Scalars)".
data Builtin
-- | A signed 32‐bit numeric non‐fractional value
GInt :: Builtin
-- | True or false
GBool :: Builtin
-- | Textual data represented as UTF-8 character sequences
GString :: Builtin
-- | Signed double‐precision fractional values as specified by IEEE
-- 754
GFloat :: Builtin
-- | A unique identifier, often used to refetch an object or as the key for
-- a cache
GID :: Builtin
data TypeDefinition
TypeDefinitionObject :: ObjectTypeDefinition -> TypeDefinition
TypeDefinitionInterface :: InterfaceTypeDefinition -> TypeDefinition
TypeDefinitionUnion :: UnionTypeDefinition -> TypeDefinition
TypeDefinitionScalar :: ScalarTypeDefinition -> TypeDefinition
TypeDefinitionEnum :: EnumTypeDefinition -> TypeDefinition
TypeDefinitionInputObject :: InputObjectTypeDefinition -> TypeDefinition
TypeDefinitionTypeExtension :: TypeExtensionDefinition -> TypeDefinition
-- | A name in GraphQL.
--
-- https://facebook.github.io/graphql/#sec-Names
data Name
data ArgumentDefinition
ArgumentDefinition :: Name -> AnnotatedType InputType -> Maybe DefaultValue -> ArgumentDefinition
newtype EnumValueDefinition
EnumValueDefinition :: Name -> EnumValueDefinition
data EnumTypeDefinition
EnumTypeDefinition :: Name -> [EnumValueDefinition] -> EnumTypeDefinition
data FieldDefinition
FieldDefinition :: Name -> [ArgumentDefinition] -> AnnotatedType GType -> FieldDefinition
type Interfaces = [InterfaceTypeDefinition]
data InterfaceTypeDefinition
InterfaceTypeDefinition :: Name -> NonEmpty FieldDefinition -> InterfaceTypeDefinition
data ObjectTypeDefinition
ObjectTypeDefinition :: Name -> Interfaces -> NonEmpty FieldDefinition -> ObjectTypeDefinition
data UnionTypeDefinition
UnionTypeDefinition :: Name -> NonEmpty ObjectTypeDefinition -> UnionTypeDefinition
newtype ScalarTypeDefinition
ScalarTypeDefinition :: Name -> ScalarTypeDefinition
data InputType
DefinedInputType :: InputTypeDefinition -> InputType
BuiltinInputType :: Builtin -> InputType
data InputTypeDefinition
InputTypeDefinitionObject :: InputObjectTypeDefinition -> InputTypeDefinition
InputTypeDefinitionScalar :: ScalarTypeDefinition -> InputTypeDefinition
InputTypeDefinitionEnum :: EnumTypeDefinition -> InputTypeDefinition
data InputObjectTypeDefinition
InputObjectTypeDefinition :: Name -> NonEmpty InputObjectFieldDefinition -> InputObjectTypeDefinition
data InputObjectFieldDefinition
InputObjectFieldDefinition :: Name -> AnnotatedType InputType -> Maybe DefaultValue -> InputObjectFieldDefinition
data AnnotatedType t
TypeNamed :: t -> AnnotatedType t
TypeList :: ListType t -> AnnotatedType t
TypeNonNull :: NonNullType t -> AnnotatedType t
newtype ListType t
ListType :: AnnotatedType t -> ListType t
data NonNullType t
NonNullTypeNamed :: t -> NonNullType t
NonNullTypeList :: ListType t -> NonNullType t
-- | A thing that defines types. Excludes definitions of input types.
class DefinesTypes t
-- | Get the types defined by t
--
-- TODO: This ignores whether a value can define multiple types with the
-- same name, and further admits the possibility that the name embedded
-- in the type definition does not match the name in the returned
-- dictionary. jml would like to have a schema validation phase that
-- eliminates one or both of these possibilities.
--
-- Also pretty much works because we've inlined all our type definitions.
getDefinedTypes :: DefinesTypes t => t -> Map Name TypeDefinition
-- | Does the given object type match the given type condition.
--
-- See https://facebook.github.io/graphql/#sec-Field-Collection
--
-- -- DoesFragmentTypeApply(objectType, fragmentType) -- If fragmentType is an Object Type: -- if objectType and fragmentType are the same type, return true, otherwise return false. -- If fragmentType is an Interface Type: -- if objectType is an implementation of fragmentType, return true otherwise return false. -- If fragmentType is a Union: -- if objectType is a possible type of fragmentType, return true otherwise return false. --doesFragmentTypeApply :: ObjectTypeDefinition -> TypeDefinition -> Bool -- | Convert the given TypeDefinition to an -- InputTypeDefinition if it's a valid InputTypeDefinition -- (because InputTypeDefinition is a subset of -- TypeDefinition) see -- http://facebook.github.io/graphql/June2018/#sec-Input-and-Output-Types getInputTypeDefinition :: TypeDefinition -> Maybe InputTypeDefinition -- | Create a Builtin type from a Name -- -- Mostly used for the AST validation theobat: There's probably a better -- way to do it but can't find it right now builtinFromName :: Name -> Maybe Builtin -- | Simple translation between AST annotation types and -- Schema annotation types -- -- AST type annotations do not need any validation. GraphQL annotations -- are semantic decorations around type names to indicate type -- composition (list/non null). astAnnotationToSchemaAnnotation :: GType -> a -> AnnotatedType a -- | An entire GraphQL schema. -- -- This is very much a work in progress. Currently, the only thing we -- provide is a dictionary mapping type names to their definitions. data Schema -- | Create a schema from the root object. -- -- This is technically an insufficient API, since not all types in a -- schema need to be reachable from a single root object. However, it's a -- start. makeSchema :: ObjectTypeDefinition -> Schema -- | Create an empty schema for testing purpose. emptySchema :: Schema -- | Find the type with the given name in the schema. lookupType :: Schema -> Name -> Maybe TypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.Schema instance GHC.Classes.Ord GraphQL.Internal.Schema.Schema instance GHC.Classes.Eq GraphQL.Internal.Schema.Schema instance GHC.Show.Show GraphQL.Internal.Schema.UnionTypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.UnionTypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.UnionTypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.InterfaceTypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.InterfaceTypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.InterfaceTypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.ObjectTypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.ObjectTypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.ObjectTypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.TypeExtensionDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.TypeExtensionDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.TypeExtensionDefinition instance GHC.Show.Show GraphQL.Internal.Schema.TypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.TypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.TypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.GType instance GHC.Classes.Ord GraphQL.Internal.Schema.GType instance GHC.Classes.Eq GraphQL.Internal.Schema.GType instance GHC.Show.Show GraphQL.Internal.Schema.FieldDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.FieldDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.FieldDefinition instance GHC.Show.Show GraphQL.Internal.Schema.ArgumentDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.ArgumentDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.ArgumentDefinition instance GHC.Show.Show GraphQL.Internal.Schema.InputObjectTypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.InputObjectTypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.InputObjectTypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.InputTypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.InputTypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.InputTypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.InputType instance GHC.Classes.Ord GraphQL.Internal.Schema.InputType instance GHC.Classes.Eq GraphQL.Internal.Schema.InputType instance GHC.Show.Show GraphQL.Internal.Schema.InputObjectFieldDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.InputObjectFieldDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.InputObjectFieldDefinition instance GHC.Show.Show GraphQL.Internal.Schema.EnumTypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.EnumTypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.EnumTypeDefinition instance GHC.Show.Show GraphQL.Internal.Schema.EnumValueDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.EnumValueDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.EnumValueDefinition instance GHC.Show.Show GraphQL.Internal.Schema.Builtin instance GHC.Classes.Ord GraphQL.Internal.Schema.Builtin instance GHC.Classes.Eq GraphQL.Internal.Schema.Builtin instance GHC.Show.Show GraphQL.Internal.Schema.ScalarTypeDefinition instance GHC.Classes.Ord GraphQL.Internal.Schema.ScalarTypeDefinition instance GHC.Classes.Eq GraphQL.Internal.Schema.ScalarTypeDefinition instance GHC.Show.Show t => GHC.Show.Show (GraphQL.Internal.Schema.AnnotatedType t) instance GHC.Classes.Ord t => GHC.Classes.Ord (GraphQL.Internal.Schema.AnnotatedType t) instance GHC.Classes.Eq t => GHC.Classes.Eq (GraphQL.Internal.Schema.AnnotatedType t) instance GHC.Show.Show t => GHC.Show.Show (GraphQL.Internal.Schema.ListType t) instance GHC.Classes.Ord t => GHC.Classes.Ord (GraphQL.Internal.Schema.ListType t) instance GHC.Classes.Eq t => GHC.Classes.Eq (GraphQL.Internal.Schema.ListType t) instance GHC.Show.Show t => GHC.Show.Show (GraphQL.Internal.Schema.NonNullType t) instance GHC.Classes.Ord t => GHC.Classes.Ord (GraphQL.Internal.Schema.NonNullType t) instance GHC.Classes.Eq t => GHC.Classes.Eq (GraphQL.Internal.Schema.NonNullType t) instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.GType instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.TypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.ObjectTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.FieldDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.ArgumentDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.InterfaceTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.UnionTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.ScalarTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.EnumTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.InputType instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.InputTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.GType instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.TypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.ObjectTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.FieldDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InterfaceTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.UnionTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.TypeExtensionDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.ArgumentDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InputObjectTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InputObjectFieldDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InputType instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InputTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.EnumTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.EnumValueDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.Builtin instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.ScalarTypeDefinition instance GraphQL.Internal.Name.HasName t => GraphQL.Internal.Name.HasName (GraphQL.Internal.Schema.AnnotatedType t) module GraphQL.Internal.Output -- | GraphQL response. -- -- A GraphQL response must: -- --
-- \xs -> findDuplicates @Int xs == ordNub (findDuplicates @Int xs) --findDuplicates :: Ord a => [a] -> [a] -- | Utility function for tests, format ErrorTypes to their text -- representation returns a list of error messages formatErrors :: [ValidationError] -> [Text] instance GHC.Base.Monad (GraphQL.Internal.Validation.Validator e) instance GHC.Base.Functor (GraphQL.Internal.Validation.Validator e) instance (GHC.Show.Show e, GHC.Show.Show a) => GHC.Show.Show (GraphQL.Internal.Validation.Validator e a) instance (GHC.Classes.Eq e, GHC.Classes.Eq a) => GHC.Classes.Eq (GraphQL.Internal.Validation.Validator e a) instance GHC.Show.Show GraphQL.Internal.Validation.ValidationError instance GHC.Classes.Eq GraphQL.Internal.Validation.ValidationError instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.QueryDocument value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.QueryDocument value) instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.Operation value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.Operation value) instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.FragmentSpread value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.FragmentSpread value) instance (GHC.Show.Show value, GHC.Show.Show (spread value)) => GHC.Show.Show (GraphQL.Internal.Validation.FragmentDefinition spread value) instance (GHC.Classes.Eq value, GHC.Classes.Eq (spread value)) => GHC.Classes.Eq (GraphQL.Internal.Validation.FragmentDefinition spread value) instance (GHC.Show.Show value, GHC.Show.Show (spread value)) => GHC.Show.Show (GraphQL.Internal.Validation.InlineFragment spread value) instance (GHC.Classes.Eq value, GHC.Classes.Eq (spread value)) => GHC.Classes.Eq (GraphQL.Internal.Validation.InlineFragment spread value) instance Data.Traversable.Traversable spread => Data.Traversable.Traversable (GraphQL.Internal.Validation.Selection' spread) instance Data.Foldable.Foldable spread => Data.Foldable.Foldable (GraphQL.Internal.Validation.Selection' spread) instance GHC.Base.Functor spread => GHC.Base.Functor (GraphQL.Internal.Validation.Selection' spread) instance (GHC.Show.Show value, GHC.Show.Show (spread value)) => GHC.Show.Show (GraphQL.Internal.Validation.Selection' spread value) instance (GHC.Classes.Eq value, GHC.Classes.Eq (spread value)) => GHC.Classes.Eq (GraphQL.Internal.Validation.Selection' spread value) instance (GHC.Show.Show value, GHC.Show.Show (spread value)) => GHC.Show.Show (GraphQL.Internal.Validation.Field' spread value) instance (GHC.Classes.Eq value, GHC.Classes.Eq (spread value)) => GHC.Classes.Eq (GraphQL.Internal.Validation.Field' spread value) instance GHC.Base.Functor GraphQL.Internal.Validation.UnresolvedFragmentSpread instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.UnresolvedFragmentSpread value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.UnresolvedFragmentSpread value) instance Data.Traversable.Traversable GraphQL.Internal.Validation.Directives instance GHC.Base.Functor GraphQL.Internal.Validation.Directives instance Data.Foldable.Foldable GraphQL.Internal.Validation.Directives instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.Directives value) instance GHC.Classes.Ord value => GHC.Classes.Ord (GraphQL.Internal.Validation.Directives value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.Directives value) instance GHC.Show.Show GraphQL.Internal.Validation.VariableDefinition instance GHC.Classes.Ord GraphQL.Internal.Validation.VariableDefinition instance GHC.Classes.Eq GraphQL.Internal.Validation.VariableDefinition instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.SelectionSet value) instance GHC.Classes.Ord value => GHC.Classes.Ord (GraphQL.Internal.Validation.SelectionSet value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.SelectionSet value) instance Data.Traversable.Traversable GraphQL.Internal.Validation.SelectionSetByType instance Data.Foldable.Foldable GraphQL.Internal.Validation.SelectionSetByType instance GHC.Base.Functor GraphQL.Internal.Validation.SelectionSetByType instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.SelectionSetByType value) instance GHC.Classes.Ord value => GHC.Classes.Ord (GraphQL.Internal.Validation.SelectionSetByType value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.SelectionSetByType value) instance Data.Traversable.Traversable GraphQL.Internal.Validation.Field instance Data.Foldable.Foldable GraphQL.Internal.Validation.Field instance GHC.Base.Functor GraphQL.Internal.Validation.Field instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.Field value) instance GHC.Classes.Ord value => GHC.Classes.Ord (GraphQL.Internal.Validation.Field value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.Field value) instance Data.Traversable.Traversable GraphQL.Internal.Validation.Arguments instance Data.Foldable.Foldable GraphQL.Internal.Validation.Arguments instance GHC.Base.Functor GraphQL.Internal.Validation.Arguments instance GHC.Show.Show value => GHC.Show.Show (GraphQL.Internal.Validation.Arguments value) instance GHC.Classes.Ord value => GHC.Classes.Ord (GraphQL.Internal.Validation.Arguments value) instance GHC.Classes.Eq value => GHC.Classes.Eq (GraphQL.Internal.Validation.Arguments value) instance GHC.Show.Show GraphQL.Internal.Validation.OperationType instance GHC.Classes.Eq GraphQL.Internal.Validation.OperationType instance GHC.Base.Applicative (GraphQL.Internal.Validation.Validator e) instance GraphQL.Internal.Output.GraphQLError GraphQL.Internal.Validation.ValidationError instance GHC.Base.Functor GraphQL.Internal.Validation.Operation instance Data.Foldable.Foldable GraphQL.Internal.Validation.Operation instance Data.Traversable.Traversable GraphQL.Internal.Validation.Operation instance GHC.Base.Functor GraphQL.Internal.Validation.FragmentSpread instance Data.Foldable.Foldable GraphQL.Internal.Validation.FragmentSpread instance Data.Traversable.Traversable GraphQL.Internal.Validation.FragmentSpread instance GHC.Base.Functor spread => GHC.Base.Functor (GraphQL.Internal.Validation.FragmentDefinition spread) instance Data.Foldable.Foldable spread => Data.Foldable.Foldable (GraphQL.Internal.Validation.FragmentDefinition spread) instance Data.Traversable.Traversable spread => Data.Traversable.Traversable (GraphQL.Internal.Validation.FragmentDefinition spread) instance GraphQL.Internal.Name.HasName (GraphQL.Internal.Validation.Field' spread value) instance GHC.Base.Functor spread => GHC.Base.Functor (GraphQL.Internal.Validation.Field' spread) instance Data.Foldable.Foldable spread => Data.Foldable.Foldable (GraphQL.Internal.Validation.Field' spread) instance Data.Traversable.Traversable spread => Data.Traversable.Traversable (GraphQL.Internal.Validation.Field' spread) instance GHC.Base.Functor spread => GHC.Base.Functor (GraphQL.Internal.Validation.InlineFragment spread) instance Data.Foldable.Foldable spread => Data.Foldable.Foldable (GraphQL.Internal.Validation.InlineFragment spread) instance Data.Traversable.Traversable spread => Data.Traversable.Traversable (GraphQL.Internal.Validation.InlineFragment spread) instance Data.Foldable.Foldable GraphQL.Internal.Validation.UnresolvedFragmentSpread instance Data.Traversable.Traversable GraphQL.Internal.Validation.UnresolvedFragmentSpread instance GraphQL.Internal.Name.HasName (GraphQL.Internal.Validation.Field value) module GraphQL.Internal.API.Enum -- | For each enum type we need 1) a list of all possible values 2) a way -- to serialise and 3) deserialise. -- -- TODO: Update this comment to explain what a GraphQLEnum is, why you -- might want an instance, and any laws that apply to method relations. class GraphQLEnum a enumValues :: GraphQLEnum a => [Either NameError Name] enumValues :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => [Either NameError Name] enumFromValue :: GraphQLEnum a => Name -> Either Text a enumFromValue :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => Name -> Either Text a enumToValue :: GraphQLEnum a => a -> Name enumToValue :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => a -> Name instance (GHC.TypeLits.KnownSymbol conName, GHC.TypeLits.KnownSymbol m, GHC.TypeLits.KnownSymbol p, GraphQL.Internal.API.Enum.GenericEnumValues f) => GraphQL.Internal.API.Enum.GenericEnumValues (GHC.Generics.M1 GHC.Generics.D ('GHC.Generics.MetaData conName m p nt) f) instance (GraphQL.Internal.API.Enum.GenericEnumValues left, GraphQL.Internal.API.Enum.GenericEnumValues right) => GraphQL.Internal.API.Enum.GenericEnumValues (left GHC.Generics.:+: right) instance GHC.TypeLits.KnownSymbol conName => GraphQL.Internal.API.Enum.GenericEnumValues (GHC.Generics.C1 ('GHC.Generics.MetaCons conName p b) GHC.Generics.U1) instance ((TypeError ...), GHC.TypeLits.KnownSymbol conName) => GraphQL.Internal.API.Enum.GenericEnumValues (GHC.Generics.C1 ('GHC.Generics.MetaCons conName p b) (GHC.Generics.S1 sa sb)) instance ((TypeError ...), GHC.TypeLits.KnownSymbol conName) => GraphQL.Internal.API.Enum.GenericEnumValues (GHC.Generics.C1 ('GHC.Generics.MetaCons conName p b) (GHC.Generics.S1 sa sb) GHC.Generics.:+: f) module GraphQL.Internal.API data Object (name :: Symbol) (interfaces :: [Type]) (fields :: [Type]) data Field (name :: Symbol) (fieldType :: Type) data Argument (name :: Symbol) (argType :: Type) data Union (name :: Symbol) (types :: [Type]) data List (elemType :: Type) data Enum (name :: Symbol) (values :: Type) -- | For each enum type we need 1) a list of all possible values 2) a way -- to serialise and 3) deserialise. -- -- TODO: Update this comment to explain what a GraphQLEnum is, why you -- might want an instance, and any laws that apply to method relations. class GraphQLEnum a enumValues :: GraphQLEnum a => [Either NameError Name] enumValues :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => [Either NameError Name] enumFromValue :: GraphQLEnum a => Name -> Either Text a enumFromValue :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => Name -> Either Text a enumToValue :: GraphQLEnum a => a -> Name enumToValue :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => a -> Name data Interface (name :: Symbol) (fields :: [Type]) -- | Argument operator. Can only be used with Field. -- -- Say we have a Company object that has a field that shows -- whether someone is an employee, e.g. -- --
-- type Company {
-- hasEmployee(employeeName: String!): String!
-- }
--
--
-- Then we might represent that as:
--
-- -- >>> type Company = Object "Company" '[] '[Argument "employeeName" Text :> Field "hasEmployee" Bool] ---- -- For multiple arguments, simply chain them together with :>, -- ending finally with Field. e.g. -- --
-- Argument "foo" String :> Argument "bar" Int :> Field "qux" Int --data a :> b (:>) :: a -> b -> (:>) a b infixr 8 :> infixr 8 :> -- | Specify a default value for a type in a GraphQL schema. -- -- GraphQL schema can have default values in certain places. For example, -- arguments to fields can have default values. Because we cannot lift -- arbitrary values to the type level, we need some way of getting at -- those values. This typeclass provides the means. -- -- To specify a default, implement this typeclass. -- -- The default implementation is to say that there *is* no default for -- this type. class Defaultable a -- | defaultFor returns the value to be used when no value has been given. defaultFor :: Defaultable a => Name -> Maybe a class HasAnnotatedType a getAnnotatedType :: HasAnnotatedType a => Either SchemaError (AnnotatedType GType) class HasAnnotatedInputType a class HasObjectDefinition a getDefinition :: HasObjectDefinition a => Either SchemaError ObjectTypeDefinition getArgumentDefinition :: HasArgumentDefinition a => Either SchemaError ArgumentDefinition -- | The type-level schema was somehow invalid. data SchemaError NameError :: NameError -> SchemaError EmptyFieldList :: SchemaError EmptyUnion :: SchemaError nameFromSymbol :: forall (n :: Symbol). KnownSymbol n => Either SchemaError Name getFieldDefinition :: HasFieldDefinition a => Either SchemaError FieldDefinition getInterfaceDefinition :: HasInterfaceDefinition a => Either SchemaError InterfaceTypeDefinition getAnnotatedInputType :: HasAnnotatedInputType a => Either SchemaError (AnnotatedType InputType) instance GHC.Show.Show GraphQL.Internal.API.SchemaError instance GHC.Classes.Eq GraphQL.Internal.API.SchemaError instance (GHC.TypeLits.KnownSymbol dataName, GHC.TypeLits.KnownSymbol consName, GraphQL.Internal.API.GenericInputObjectFieldDefinitions records) => GraphQL.Internal.API.GenericAnnotatedInputType (GHC.Generics.D1 ('GHC.Generics.MetaData dataName s l 'GHC.Types.False) (GHC.Generics.C1 ('GHC.Generics.MetaCons consName p 'GHC.Types.True) records)) instance (GraphQL.Internal.API.GenericInputObjectFieldDefinitions a, GraphQL.Internal.API.GenericInputObjectFieldDefinitions b) => GraphQL.Internal.API.GenericInputObjectFieldDefinitions (a GHC.Generics.:*: b) instance (GHC.TypeLits.KnownSymbol fieldName, GraphQL.Internal.API.HasAnnotatedInputType wrappedType) => GraphQL.Internal.API.GenericInputObjectFieldDefinitions (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Maybe.Just fieldName) u s l) (GHC.Generics.Rec0 wrappedType)) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.HasAnnotatedInputType t) => GraphQL.Internal.API.HasArgumentDefinition (GraphQL.Internal.API.Argument ks t) instance GraphQL.Internal.API.HasAnnotatedInputType a => GraphQL.Internal.API.HasAnnotatedInputType (GHC.Maybe.Maybe a) instance GraphQL.Internal.API.HasAnnotatedInputType GHC.Types.Int instance GraphQL.Internal.API.HasAnnotatedInputType GHC.Int.Int32 instance GraphQL.Internal.API.HasAnnotatedInputType GHC.Types.Bool instance GraphQL.Internal.API.HasAnnotatedInputType Data.Text.Internal.Text instance GraphQL.Internal.API.HasAnnotatedInputType GHC.Types.Double instance GraphQL.Internal.API.HasAnnotatedInputType GHC.Types.Float instance GraphQL.Internal.API.HasAnnotatedInputType t => GraphQL.Internal.API.HasAnnotatedInputType (GraphQL.Internal.API.List t) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.Enum.GraphQLEnum enum) => GraphQL.Internal.API.HasAnnotatedInputType (GraphQL.Internal.API.Enum ks enum) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.HasInterfaceDefinitions is, GraphQL.Internal.API.HasFieldDefinitions ts) => GraphQL.Internal.API.HasAnnotatedType (GraphQL.Internal.API.Object ks is ts) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.HasAnnotatedType t) => GraphQL.Internal.API.HasFieldDefinition (GraphQL.Internal.API.Field ks t) instance GraphQL.Internal.API.HasAnnotatedType a => GraphQL.Internal.API.HasAnnotatedType (GHC.Maybe.Maybe a) instance GraphQL.Internal.API.HasAnnotatedType GHC.Types.Int instance GraphQL.Internal.API.HasAnnotatedType GHC.Int.Int32 instance GraphQL.Internal.API.HasAnnotatedType GHC.Types.Bool instance GraphQL.Internal.API.HasAnnotatedType Data.Text.Internal.Text instance GraphQL.Internal.API.HasAnnotatedType GHC.Types.Double instance GraphQL.Internal.API.HasAnnotatedType GHC.Types.Float instance GraphQL.Internal.API.HasAnnotatedType t => GraphQL.Internal.API.HasAnnotatedType (GraphQL.Internal.API.List t) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.Enum.GraphQLEnum enum) => GraphQL.Internal.API.HasAnnotatedType (GraphQL.Internal.API.Enum ks enum) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.HasUnionTypeObjectTypeDefinitions as) => GraphQL.Internal.API.HasAnnotatedType (GraphQL.Internal.API.Union ks as) instance (TypeError ...) => GraphQL.Internal.API.HasAnnotatedType GHC.Integer.Type.Integer instance (GraphQL.Internal.API.HasArgumentDefinition a, GraphQL.Internal.API.HasFieldDefinition b) => GraphQL.Internal.API.HasFieldDefinition (a GraphQL.Internal.API.:> b) instance forall a1 (a2 :: a1) (as :: [a1]). (GraphQL.Internal.API.HasInterfaceDefinition a2, GraphQL.Internal.API.HasInterfaceDefinitions as) => GraphQL.Internal.API.HasInterfaceDefinitions (a2 : as) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.HasFieldDefinitions fields) => GraphQL.Internal.API.HasInterfaceDefinition (GraphQL.Internal.API.Interface ks fields) instance GraphQL.Internal.API.HasInterfaceDefinitions '[] instance (GHC.TypeLits.KnownSymbol ks, GraphQL.Internal.API.HasInterfaceDefinitions is, GraphQL.Internal.API.HasFieldDefinitions fields) => GraphQL.Internal.API.HasObjectDefinition (GraphQL.Internal.API.Object ks is fields) instance forall a1 (a2 :: a1) (as :: [a1]). (GraphQL.Internal.API.HasObjectDefinition a2, GraphQL.Internal.API.HasUnionTypeObjectTypeDefinitions as) => GraphQL.Internal.API.HasUnionTypeObjectTypeDefinitions (a2 : as) instance GraphQL.Internal.API.HasUnionTypeObjectTypeDefinitions '[] instance forall a1 (a2 :: a1) (as :: [a1]). (GraphQL.Internal.API.HasFieldDefinition a2, GraphQL.Internal.API.HasFieldDefinitions as) => GraphQL.Internal.API.HasFieldDefinitions (a2 : as) instance GraphQL.Internal.API.HasFieldDefinitions '[] instance (TypeError ...) => GraphQL.Internal.API.HasFieldDefinition (GraphQL.Internal.API.Argument ks t) instance GraphQL.Internal.API.Defaultable GHC.Int.Int32 instance GraphQL.Internal.API.Defaultable GHC.Types.Double instance GraphQL.Internal.API.Defaultable GHC.Types.Bool instance GraphQL.Internal.API.Defaultable Data.Text.Internal.Text instance GraphQL.Internal.API.Defaultable (GHC.Maybe.Maybe a) instance GraphQL.Internal.Output.GraphQLError GraphQL.Internal.API.SchemaError module GraphQL.Internal.Resolver data ResolverError -- | There was a problem in the schema. Server-side problem. SchemaError :: SchemaError -> ResolverError -- | Couldn't find the requested field in the object. A client-side -- problem. FieldNotFoundError :: Name -> ResolverError -- | No value provided for name, and no default specified. Client-side -- problem. ValueMissing :: Name -> ResolverError -- | Could not translate value into Haskell. Probably a client-side -- problem. InvalidValue :: Name -> Text -> ResolverError -- | Found validation errors when we tried to merge fields. ValidationError :: ValidationErrors -> ResolverError -- | Tried to get subselection of leaf field. SubSelectionOnLeaf :: SelectionSetByType Value -> ResolverError -- | Tried to treat an object as a leaf. MissingSelectionSet :: ResolverError -- | Error from handler HandlerError :: Text -> ResolverError class HasResolver m a where { type family Handler m a; } resolve :: HasResolver m a => Handler m a -> Maybe (SelectionSetByType Value) -> m (Result Value) type OperationResolverConstraint m fields typeName interfaces = (RunFields m (RunFieldsType m fields), HasObjectDefinition (Object typeName interfaces fields), Monad m) -- | Object field separation operator. -- -- Use this to provide handlers for fields of an object. -- -- Say you had the following GraphQL type with "foo" and "bar" fields, -- e.g. -- --
-- type MyObject {
-- foo: Int!
-- bar: String!
-- }
--
--
-- You could provide handlers for it like this:
--
-- -- >>> :m +System.Environment -- -- >>> let fooHandler = pure 42 -- -- >>> let barHandler = System.Environment.getProgName -- -- >>> let myObjectHandler = pure $ fooHandler :<> barHandler :<> () --data a :<> b (:<>) :: a -> b -> (:<>) a b infixr 8 :<> infixr 8 :<> data Result a Result :: [ResolverError] -> a -> Result a -- | Translate a Handler into a DynamicUnionValue type required by -- Union handlers. This is dynamic, but nevertheless type-safe -- because we can only tag with types that are part of the union. -- -- Use e.g. like "unionValue @Cat" if you have an object like this: -- --
-- >>> type Cat = API.Object "Cat" '[] '[API.Field "name" Text] ---- -- and then use `unionValue @Cat (pure (pure Felix))`. See -- `examples/UnionExample.hs` for more code. unionValue :: forall (object :: Type) (union :: Type) m (name :: Symbol) interfaces fields. (Monad m, Object name interfaces fields ~ object, KnownSymbol name) => TypeIndex m object union -> m (DynamicUnionValue union m) resolveOperation :: forall m fields typeName interfaces. OperationResolverConstraint m fields typeName interfaces => Handler m (Object typeName interfaces fields) -> SelectionSetByType Value -> m (Result Object) -- | returns is a convenience function for a Handler that is -- returning the expected value. returns :: Applicative f => a -> f (HandlerResult a) -- | handlerError is a convenience function for a Handler that has -- encountered an error and is unable to return the expected value. handlerError :: Applicative f => Text -> f (HandlerResult a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GraphQL.Internal.Resolver.Result a) instance GHC.Base.Functor GraphQL.Internal.Resolver.Result instance GHC.Show.Show a => GHC.Show.Show (GraphQL.Internal.Resolver.Result a) instance GHC.Classes.Eq GraphQL.Internal.Resolver.ResolverError instance GHC.Show.Show GraphQL.Internal.Resolver.ResolverError instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, GraphQL.Internal.Resolver.TypeIndex m (GraphQL.Internal.API.Object name interfaces fields) union Data.Type.Equality.~ GraphQL.Internal.Resolver.Handler m (GraphQL.Internal.API.Object name interfaces fields), GraphQL.Internal.Resolver.RunFields m (GraphQL.Internal.Resolver.RunFieldsType m fields), GraphQL.Internal.API.HasObjectDefinition (GraphQL.Internal.API.Object name interfaces fields), GraphQL.Internal.Resolver.RunUnion m union objects) => GraphQL.Internal.Resolver.RunUnion m union (GraphQL.Internal.API.Object name interfaces fields : objects) instance GraphQL.Internal.Resolver.RunUnion m union '[] instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol unionName, GraphQL.Internal.Resolver.RunUnion m (GraphQL.Internal.API.Union unionName objects) objects) => GraphQL.Internal.Resolver.HasResolver m (GraphQL.Internal.API.Union unionName objects) instance (GraphQL.Internal.Resolver.BuildFieldResolver m dispatchType, dispatchType Data.Type.Equality.~ GraphQL.Internal.Resolver.FieldResolverDispatchType f, GraphQL.Internal.Resolver.RunFields m fs, GHC.TypeLits.KnownSymbol (GraphQL.Internal.Resolver.FieldName dispatchType), GHC.Base.Monad m) => GraphQL.Internal.Resolver.RunFields m (f GraphQL.Internal.Resolver.:<> fs) instance (GraphQL.Internal.Resolver.BuildFieldResolver m dispatchType, GHC.TypeLits.KnownSymbol ksM, dispatchType Data.Type.Equality.~ GraphQL.Internal.Resolver.FieldResolverDispatchType (GraphQL.Internal.API.Field ksM t), GHC.Base.Monad m) => GraphQL.Internal.Resolver.RunFields m (GraphQL.Internal.API.Field ksM t) instance (GraphQL.Internal.Resolver.BuildFieldResolver m dispatchType, dispatchType Data.Type.Equality.~ GraphQL.Internal.Resolver.FieldResolverDispatchType (a GraphQL.Internal.API.:> b), GHC.TypeLits.KnownSymbol (GraphQL.Internal.Resolver.FieldName dispatchType), GHC.Base.Monad m) => GraphQL.Internal.Resolver.RunFields m (a GraphQL.Internal.API.:> b) instance (GraphQL.Internal.Resolver.RunFields m (GraphQL.Internal.Resolver.RunFieldsType m fields), GraphQL.Internal.API.HasObjectDefinition (GraphQL.Internal.API.Object typeName interfaces fields), GHC.Base.Monad m) => GraphQL.Internal.Resolver.HasResolver m (GraphQL.Internal.API.Object typeName interfaces fields) instance (GHC.TypeLits.KnownSymbol ksG, GraphQL.Internal.Resolver.HasResolver m t, GraphQL.Internal.API.HasAnnotatedType t, GHC.Base.Monad m) => GraphQL.Internal.Resolver.BuildFieldResolver m (GraphQL.Internal.Resolver.JustHandler (GraphQL.Internal.API.Field ksG t)) instance (GHC.TypeLits.KnownSymbol ksH, GraphQL.Internal.Resolver.BuildFieldResolver m f, GraphQL.Internal.Value.FromValue.FromValue t, GraphQL.Internal.API.Defaultable t, GraphQL.Internal.API.HasAnnotatedInputType t, GHC.Base.Monad m) => GraphQL.Internal.Resolver.BuildFieldResolver m (GraphQL.Internal.Resolver.PlainArgument (GraphQL.Internal.API.Argument ksH t) f) instance (GHC.TypeLits.KnownSymbol ksK, GraphQL.Internal.Resolver.BuildFieldResolver m f, GHC.TypeLits.KnownSymbol name, GraphQL.Internal.API.Defaultable t, GraphQL.Internal.API.Enum.GraphQLEnum t, GHC.Base.Monad m) => GraphQL.Internal.Resolver.BuildFieldResolver m (GraphQL.Internal.Resolver.EnumArgument (GraphQL.Internal.API.Argument ksK (GraphQL.Internal.API.Enum name t)) f) instance GHC.Base.Applicative m => GraphQL.Internal.Resolver.HasResolver m GHC.Int.Int32 instance GHC.Base.Applicative m => GraphQL.Internal.Resolver.HasResolver m GHC.Types.Double instance GHC.Base.Applicative m => GraphQL.Internal.Resolver.HasResolver m Data.Text.Internal.Text instance GHC.Base.Applicative m => GraphQL.Internal.Resolver.HasResolver m GHC.Types.Bool instance (GHC.Base.Monad m, GHC.Base.Applicative m, GraphQL.Internal.Resolver.HasResolver m hg) => GraphQL.Internal.Resolver.HasResolver m (GraphQL.Internal.API.List hg) instance (GHC.Base.Applicative m, GraphQL.Internal.API.Enum.GraphQLEnum enum) => GraphQL.Internal.Resolver.HasResolver m (GraphQL.Internal.API.Enum ksN enum) instance (GraphQL.Internal.Resolver.HasResolver m hg, GHC.Base.Monad m) => GraphQL.Internal.Resolver.HasResolver m (GHC.Maybe.Maybe hg) instance GHC.Base.Applicative GraphQL.Internal.Resolver.Result instance GraphQL.Internal.Output.GraphQLError GraphQL.Internal.Resolver.ResolverError -- | Contains everything you need to write handlers for your GraphQL -- schema. module GraphQL.Resolver type OperationResolverConstraint m fields typeName interfaces = (RunFields m (RunFieldsType m fields), HasObjectDefinition (Object typeName interfaces fields), Monad m) class HasResolver m a where { type family Handler m a; } resolve :: HasResolver m a => Handler m a -> Maybe (SelectionSetByType Value) -> m (Result Value) data Result a Result :: [ResolverError] -> a -> Result a -- | Object field separation operator. -- -- Use this to provide handlers for fields of an object. -- -- Say you had the following GraphQL type with "foo" and "bar" fields, -- e.g. -- --
-- type MyObject {
-- foo: Int!
-- bar: String!
-- }
--
--
-- You could provide handlers for it like this:
--
-- -- >>> :m +System.Environment -- -- >>> let fooHandler = pure 42 -- -- >>> let barHandler = System.Environment.getProgName -- -- >>> let myObjectHandler = pure $ fooHandler :<> barHandler :<> () --data a :<> b (:<>) :: a -> b -> (:<>) a b infixr 8 :<> infixr 8 :<> data ResolverError -- | There was a problem in the schema. Server-side problem. SchemaError :: SchemaError -> ResolverError -- | Couldn't find the requested field in the object. A client-side -- problem. FieldNotFoundError :: Name -> ResolverError -- | No value provided for name, and no default specified. Client-side -- problem. ValueMissing :: Name -> ResolverError -- | Could not translate value into Haskell. Probably a client-side -- problem. InvalidValue :: Name -> Text -> ResolverError -- | Found validation errors when we tried to merge fields. ValidationError :: ValidationErrors -> ResolverError -- | Tried to get subselection of leaf field. SubSelectionOnLeaf :: SelectionSetByType Value -> ResolverError -- | Tried to treat an object as a leaf. MissingSelectionSet :: ResolverError -- | Error from handler HandlerError :: Text -> ResolverError -- | returns is a convenience function for a Handler that is -- returning the expected value. returns :: Applicative f => a -> f (HandlerResult a) -- | handlerError is a convenience function for a Handler that has -- encountered an error and is unable to return the expected value. handlerError :: Applicative f => Text -> f (HandlerResult a) resolveOperation :: forall m fields typeName interfaces. OperationResolverConstraint m fields typeName interfaces => Handler m (Object typeName interfaces fields) -> SelectionSetByType Value -> m (Result Object) -- | Translate a Handler into a DynamicUnionValue type required by -- Union handlers. This is dynamic, but nevertheless type-safe -- because we can only tag with types that are part of the union. -- -- Use e.g. like "unionValue @Cat" if you have an object like this: -- --
-- >>> type Cat = API.Object "Cat" '[] '[API.Field "name" Text] ---- -- and then use `unionValue @Cat (pure (pure Felix))`. See -- `examples/UnionExample.hs` for more code. unionValue :: forall (object :: Type) (union :: Type) m (name :: Symbol) interfaces fields. (Monad m, Object name interfaces fields ~ object, KnownSymbol name) => TypeIndex m object union -> m (DynamicUnionValue union m) -- | Use this to define your GraphQL schema with Haskell types. module GraphQL.API data Object (name :: Symbol) (interfaces :: [Type]) (fields :: [Type]) data Field (name :: Symbol) (fieldType :: Type) data Argument (name :: Symbol) (argType :: Type) data Union (name :: Symbol) (types :: [Type]) data List (elemType :: Type) data Enum (name :: Symbol) (values :: Type) -- | For each enum type we need 1) a list of all possible values 2) a way -- to serialise and 3) deserialise. -- -- TODO: Update this comment to explain what a GraphQLEnum is, why you -- might want an instance, and any laws that apply to method relations. class GraphQLEnum a enumValues :: GraphQLEnum a => [Either NameError Name] enumValues :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => [Either NameError Name] enumFromValue :: GraphQLEnum a => Name -> Either Text a enumFromValue :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => Name -> Either Text a enumToValue :: GraphQLEnum a => a -> Name enumToValue :: (GraphQLEnum a, Generic a, GenericEnumValues (Rep a)) => a -> Name data Interface (name :: Symbol) (fields :: [Type]) -- | Argument operator. Can only be used with Field. -- -- Say we have a Company object that has a field that shows -- whether someone is an employee, e.g. -- --
-- type Company {
-- hasEmployee(employeeName: String!): String!
-- }
--
--
-- Then we might represent that as:
--
-- -- >>> type Company = Object "Company" '[] '[Argument "employeeName" Text :> Field "hasEmployee" Bool] ---- -- For multiple arguments, simply chain them together with :>, -- ending finally with Field. e.g. -- --
-- Argument "foo" String :> Argument "bar" Int :> Field "qux" Int --data a :> b (:>) :: a -> b -> (:>) a b infixr 8 :> infixr 8 :> -- | Specify a default value for a type in a GraphQL schema. -- -- GraphQL schema can have default values in certain places. For example, -- arguments to fields can have default values. Because we cannot lift -- arbitrary values to the type level, we need some way of getting at -- those values. This typeclass provides the means. -- -- To specify a default, implement this typeclass. -- -- The default implementation is to say that there *is* no default for -- this type. class Defaultable a -- | defaultFor returns the value to be used when no value has been given. defaultFor :: Defaultable a => Name -> Maybe a class HasObjectDefinition a getDefinition :: HasObjectDefinition a => Either SchemaError ObjectTypeDefinition class HasAnnotatedInputType a getAnnotatedInputType :: HasAnnotatedInputType a => Either SchemaError (AnnotatedType InputType) getAnnotatedInputType :: (HasAnnotatedInputType a, Generic a, GenericAnnotatedInputType (Rep a)) => Either SchemaError (AnnotatedType InputType) -- | The type-level schema was somehow invalid. data SchemaError NameError :: NameError -> SchemaError EmptyFieldList :: SchemaError EmptyUnion :: SchemaError -- | Actually, most of the execution work takes place in Resolver, -- but there's still a fair bit required to glue together the results of -- Validation and the processing in Resolver. This module -- provides that glue. module GraphQL.Internal.Execution -- | A map of variables to their values. -- -- In GraphQL the variable values are not part of the query itself, they -- are instead passed in through a separate channel. Create a -- VariableValues from this other channel and pass it to -- substituteVariables. -- -- GraphQL allows the values of variables to be specified, but doesn't -- provide a way for doing so in the language. type VariableValues = Map Variable Value -- | An error that occurs while executing a query. Technically, -- ResolverError also falls into the same category, but is -- separate to help our code be a bit better organized. data ExecutionError MissingValue :: Variable -> ExecutionError NoSuchOperation :: Name -> ExecutionError NoAnonymousOperation :: ExecutionError -- | Represent an error as human-readable text, primarily intended for -- developers of GraphQL clients, and secondarily for developers of -- GraphQL servers. formatError :: GraphQLError e => e -> Text -- | Get an operation from a GraphQL document -- -- https://facebook.github.io/graphql/#sec-Executing-Requests -- -- GetOperation(document, operationName): -- --