-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Sketch of GraphQL stuff -- -- Please see README.md @package graphql-api @version 0.2.0 -- | Basic tokenising used by parser. module GraphQL.Internal.Syntax.Tokens tok :: Parser a -> Parser a whiteSpace :: Parser () -- | Data structure for mapping keys to values while preserving order of -- appearance. -- -- 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 value, GHC.Show.Show key) => GHC.Show.Show (GraphQL.Internal.OrderedMap.OrderedMap key value)
instance (GHC.Classes.Ord value, GHC.Classes.Ord key) => GHC.Classes.Ord (GraphQL.Internal.OrderedMap.OrderedMap key value)
instance (GHC.Classes.Eq value, GHC.Classes.Eq key) => 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.Arbitrary
-- | Generate arbitrary Text.
arbitraryText :: Gen Text
-- | Generate an arbitrary NonEmpty list.
arbitraryNonEmpty :: forall a. Arbitrary a => Gen (NonEmpty a)
module GraphQL.Internal.Syntax.AST
-- | A name in GraphQL.
--
-- https://facebook.github.io/graphql/#sec-Names
data Name
-- | Parser for Name.
nameParser :: Parser Name
-- | An invalid name.
newtype NameError
NameError :: Text -> NameError
-- | 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
-- | 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")
--
makeName :: Text -> Either NameError Name
-- | 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 :: Name -> [VariableDefinition] -> [Directive] -> SelectionSet -> Node
getNodeName :: Node -> Name
data VariableDefinition
VariableDefinition :: Variable -> Type -> (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 Type
TypeNamed :: NamedType -> Type
TypeList :: ListType -> Type
TypeNonNull :: NonNullType -> Type
newtype NamedType
NamedType :: Name -> NamedType
newtype ListType
ListType :: Type -> 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 -> Type -> FieldDefinition
type ArgumentsDefinition = [InputValueDefinition]
data InputValueDefinition
InputValueDefinition :: Name -> Type -> (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.Type
instance GHC.Classes.Ord GraphQL.Internal.Syntax.AST.Type
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Type
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 GHC.Show.Show GraphQL.Internal.Syntax.AST.NameError
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.NameError
instance GHC.Show.Show GraphQL.Internal.Syntax.AST.Name
instance GHC.Classes.Ord GraphQL.Internal.Syntax.AST.Name
instance GHC.Classes.Eq GraphQL.Internal.Syntax.AST.Name
instance Data.String.IsString GraphQL.Internal.Syntax.AST.Name
instance Data.Aeson.Types.ToJSON.ToJSON GraphQL.Internal.Syntax.AST.Name
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.Name
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.Variable
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.Value
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Internal.Syntax.AST.StringValue
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
-- | Representation of GraphQL names.
module GraphQL.Internal.Name
-- | A name in GraphQL.
--
-- https://facebook.github.io/graphql/#sec-Names
data Name
-- | 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 Nothing.
--
--
-- >>> 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
-- | 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
module GraphQL.Internal.Syntax.Encoder
queryDocument :: QueryDocument -> Text
schemaDocument :: SchemaDocument -> Text
value :: Value -> Text
module GraphQL.Internal.Syntax.Parser
queryDocument :: Parser QueryDocument
-- | Parser for a schema document.
schemaDocument :: Parser SchemaDocument
value :: Parser Value
-- | Literal GraphQL values.
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
-- | 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
data Name
-- | 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 Nothing.
--
--
-- >>> 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
-- | 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.Value.ObjectField'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Value.ObjectField' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Value.ObjectField' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Value.ObjectField' scalar)
instance GHC.Base.Functor GraphQL.Value.List'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Value.List' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Value.List' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Value.List' scalar)
instance GHC.Base.Functor GraphQL.Value.Value'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Value.Value' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Value.Value' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Value.Value' scalar)
instance GHC.Base.Functor GraphQL.Value.Object'
instance GHC.Show.Show scalar => GHC.Show.Show (GraphQL.Value.Object' scalar)
instance GHC.Classes.Ord scalar => GHC.Classes.Ord (GraphQL.Value.Object' scalar)
instance GHC.Classes.Eq scalar => GHC.Classes.Eq (GraphQL.Value.Object' scalar)
instance GHC.Show.Show GraphQL.Value.ConstScalar
instance GHC.Classes.Ord GraphQL.Value.ConstScalar
instance GHC.Classes.Eq GraphQL.Value.ConstScalar
instance GHC.Show.Show GraphQL.Value.String
instance GHC.Classes.Ord GraphQL.Value.String
instance GHC.Classes.Eq GraphQL.Value.String
instance Data.Foldable.Foldable GraphQL.Value.Value'
instance Data.Traversable.Traversable GraphQL.Value.Value'
instance Data.Aeson.Types.ToJSON.ToJSON scalar => Data.Aeson.Types.ToJSON.ToJSON (GraphQL.Value.Value' scalar)
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Value.Value' scalar)
instance Data.Aeson.Types.ToJSON.ToJSON GraphQL.Value.ConstScalar
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Value.ConstScalar
instance Test.QuickCheck.Arbitrary.Arbitrary GraphQL.Value.String
instance Data.Aeson.Types.ToJSON.ToJSON GraphQL.Value.String
instance Data.Foldable.Foldable GraphQL.Value.List'
instance Data.Traversable.Traversable GraphQL.Value.List'
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Value.List' scalar)
instance Data.Aeson.Types.ToJSON.ToJSON scalar => Data.Aeson.Types.ToJSON.ToJSON (GraphQL.Value.List' scalar)
instance Data.Foldable.Foldable GraphQL.Value.Object'
instance Data.Traversable.Traversable GraphQL.Value.Object'
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Value.Object' scalar)
instance Test.QuickCheck.Arbitrary.Arbitrary scalar => Test.QuickCheck.Arbitrary.Arbitrary (GraphQL.Value.ObjectField' scalar)
instance Data.Aeson.Types.ToJSON.ToJSON scalar => Data.Aeson.Types.ToJSON.ToJSON (GraphQL.Value.Object' scalar)
-- | Fully realized GraphQL schema type system at the value level.
--
-- 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 Type
DefinedType :: TypeDefinition -> Type
BuiltinType :: Builtin -> Type
-- | 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 Type) -> FieldDefinition
type Interfaces = [InterfaceTypeDefinition]
data InterfaceTypeDefinition
InterfaceTypeDefinition :: Name -> (NonEmptyList FieldDefinition) -> InterfaceTypeDefinition
newtype NonEmptyList a
NonEmptyList :: [a] -> NonEmptyList a
data ObjectTypeDefinition
ObjectTypeDefinition :: Name -> Interfaces -> (NonEmptyList FieldDefinition) -> ObjectTypeDefinition
data UnionTypeDefinition
UnionTypeDefinition :: Name -> (NonEmptyList ObjectTypeDefinition) -> UnionTypeDefinition
data InputType
DefinedInputType :: InputTypeDefinition -> InputType
BuiltinInputType :: Builtin -> InputType
data InputTypeDefinition
InputTypeDefinitionObject :: InputObjectTypeDefinition -> InputTypeDefinition
InputTypeDefinitionScalar :: ScalarTypeDefinition -> InputTypeDefinition
InputTypeDefinitionEnum :: EnumTypeDefinition -> InputTypeDefinition
data InputObjectTypeDefinition
InputObjectTypeDefinition :: Name -> (NonEmptyList 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 -- | 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 -- | 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.Type instance GHC.Classes.Ord GraphQL.Internal.Schema.Type instance GHC.Classes.Eq GraphQL.Internal.Schema.Type 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 Data.Foldable.Foldable GraphQL.Internal.Schema.NonEmptyList instance GHC.Base.Functor GraphQL.Internal.Schema.NonEmptyList instance GHC.Show.Show a => GHC.Show.Show (GraphQL.Internal.Schema.NonEmptyList a) instance GHC.Classes.Ord a => GHC.Classes.Ord (GraphQL.Internal.Schema.NonEmptyList a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GraphQL.Internal.Schema.NonEmptyList a) instance GraphQL.Internal.Name.HasName t => GraphQL.Internal.Name.HasName (GraphQL.Internal.Schema.AnnotatedType t) instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.Type instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.Type instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.TypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.TypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.ObjectTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.ObjectTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.FieldDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.FieldDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.ArgumentDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InterfaceTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.InterfaceTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.UnionTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.UnionTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.ScalarTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.ScalarTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.Builtin instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.EnumTypeDefinition instance GraphQL.Internal.Schema.DefinesTypes GraphQL.Internal.Schema.EnumTypeDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.EnumValueDefinition 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.TypeExtensionDefinition instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InputType instance GraphQL.Internal.Name.HasName GraphQL.Internal.Schema.InputTypeDefinition module GraphQL.Value.ToValue -- | Turn a Haskell value into a GraphQL value. class ToValue a toValue :: ToValue a => a -> Value' ConstScalar instance GraphQL.Value.ToValue.ToValue (GraphQL.Value.Value' GraphQL.Value.ConstScalar) instance GraphQL.Value.ToValue.ToValue a => GraphQL.Value.ToValue.ToValue [a] instance GraphQL.Value.ToValue.ToValue a => GraphQL.Value.ToValue.ToValue (GHC.Base.Maybe a) instance GraphQL.Value.ToValue.ToValue a => GraphQL.Value.ToValue.ToValue (Data.List.NonEmpty.NonEmpty a) instance GraphQL.Value.ToValue.ToValue GHC.Types.Bool instance GraphQL.Value.ToValue.ToValue GHC.Int.Int32 instance GraphQL.Value.ToValue.ToValue GHC.Types.Double instance GraphQL.Value.ToValue.ToValue GraphQL.Value.String instance GraphQL.Value.ToValue.ToValue Data.Text.Internal.Text instance GraphQL.Value.ToValue.ToValue GraphQL.Value.List instance GraphQL.Value.ToValue.ToValue (GraphQL.Value.Object' GraphQL.Value.ConstScalar) -- | GraphQL output. -- -- How we encode GraphQL responses. module GraphQL.Internal.Output -- | GraphQL response. -- -- A GraphQL response must: -- --
-- \xs -> findDuplicates @Int xs == ordNub (findDuplicates @Int xs) --findDuplicates :: Ord a => [a] -> [a] 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 (spread value), GHC.Show.Show value) => GHC.Show.Show (GraphQL.Internal.Validation.FragmentDefinition spread value) instance (GHC.Classes.Eq (spread value), GHC.Classes.Eq value) => GHC.Classes.Eq (GraphQL.Internal.Validation.FragmentDefinition spread value) instance (GHC.Show.Show (spread value), GHC.Show.Show value) => GHC.Show.Show (GraphQL.Internal.Validation.InlineFragment spread value) instance (GHC.Classes.Eq (spread value), GHC.Classes.Eq 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 (spread value), GHC.Show.Show value) => GHC.Show.Show (GraphQL.Internal.Validation.Selection' spread value) instance (GHC.Classes.Eq (spread value), GHC.Classes.Eq value) => GHC.Classes.Eq (GraphQL.Internal.Validation.Selection' spread value) instance (GHC.Show.Show (spread value), GHC.Show.Show value) => GHC.Show.Show (GraphQL.Internal.Validation.Field' spread value) instance (GHC.Classes.Eq (spread value), GHC.Classes.Eq 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.Base.Functor GraphQL.Internal.Validation.Operation instance Data.Foldable.Foldable GraphQL.Internal.Validation.Operation instance Data.Traversable.Traversable GraphQL.Internal.Validation.Operation instance GraphQL.Internal.Name.HasName (GraphQL.Internal.Validation.Field value) 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 Data.Foldable.Foldable GraphQL.Internal.Validation.UnresolvedFragmentSpread instance Data.Traversable.Traversable GraphQL.Internal.Validation.UnresolvedFragmentSpread 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.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 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.Output.GraphQLError GraphQL.Internal.Validation.ValidationError instance GHC.Base.Applicative (GraphQL.Internal.Validation.Validator e) -- | Implement the "Execution" part of the GraphQL spec. -- -- 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): -- --
-- 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 class HasAnnotatedType a getAnnotatedType :: HasAnnotatedType a => Either NameError (AnnotatedType Type) class HasAnnotatedInputType a where getAnnotatedInputType = genericGetAnnotatedInputType @(Rep a) getAnnotatedInputType :: HasAnnotatedInputType a => Either NameError (AnnotatedType InputType) getAnnotatedInputType :: (HasAnnotatedInputType a, Generic a, GenericAnnotatedInputType (Rep a)) => Either NameError (AnnotatedType InputType) class HasObjectDefinition a getDefinition :: HasObjectDefinition a => Either NameError ObjectTypeDefinition getArgumentDefinition :: HasArgumentDefinition a => Either NameError ArgumentDefinition getFieldDefinition :: HasFieldDefinition a => Either NameError FieldDefinition getInterfaceDefinition :: HasInterfaceDefinition a => Either NameError InterfaceTypeDefinition getAnnotatedInputType :: HasAnnotatedInputType a => Either NameError (AnnotatedType InputType) instance forall a (a1 :: a) (as :: [a]). (GraphQL.API.HasFieldDefinition a1, GraphQL.API.HasFieldDefinitions as) => GraphQL.API.HasFieldDefinitions (a1 : as) instance GraphQL.API.HasFieldDefinitions '[] instance forall a (a1 :: a) (as :: [a]). (GraphQL.API.HasObjectDefinition a1, GraphQL.API.UnionTypeObjectTypeDefinitionList as) => GraphQL.API.UnionTypeObjectTypeDefinitionList (a1 : as) instance GraphQL.API.UnionTypeObjectTypeDefinitionList '[] instance forall a (a1 :: a) (as :: [a]). (GraphQL.API.HasInterfaceDefinition a1, GraphQL.API.HasInterfaceDefinitions as) => GraphQL.API.HasInterfaceDefinitions (a1 : as) instance GraphQL.API.HasInterfaceDefinitions '[] instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.HasFieldDefinitions fields) => GraphQL.API.HasInterfaceDefinition (GraphQL.API.Interface ks fields) instance (TypeError ...) => GraphQL.API.HasFieldDefinition (GraphQL.API.Argument ks t) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.HasInterfaceDefinitions is, GraphQL.API.HasFieldDefinitions ts) => GraphQL.API.HasAnnotatedType (GraphQL.API.Object ks is ts) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.HasAnnotatedType t) => GraphQL.API.HasFieldDefinition (GraphQL.API.Field ks t) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.HasAnnotatedInputType t) => GraphQL.API.HasArgumentDefinition (GraphQL.API.Argument ks t) instance (GraphQL.API.HasArgumentDefinition a, GraphQL.API.HasFieldDefinition b) => GraphQL.API.HasFieldDefinition (a GraphQL.API.:> b) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.HasInterfaceDefinitions is, GraphQL.API.HasFieldDefinitions fields) => GraphQL.API.HasObjectDefinition (GraphQL.API.Object ks is fields) instance GraphQL.API.HasAnnotatedType a => GraphQL.API.HasAnnotatedType (GHC.Base.Maybe a) instance GraphQL.API.HasAnnotatedType GHC.Types.Int instance GraphQL.API.HasAnnotatedType GHC.Int.Int32 instance GraphQL.API.HasAnnotatedType GHC.Types.Bool instance GraphQL.API.HasAnnotatedType Data.Text.Internal.Text instance GraphQL.API.HasAnnotatedType GHC.Types.Double instance GraphQL.API.HasAnnotatedType GHC.Types.Float instance GraphQL.API.HasAnnotatedType t => GraphQL.API.HasAnnotatedType (GraphQL.API.List t) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.Enum.GraphQLEnum enum) => GraphQL.API.HasAnnotatedType (GraphQL.API.Enum ks enum) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.UnionTypeObjectTypeDefinitionList as) => GraphQL.API.HasAnnotatedType (GraphQL.API.Union ks as) instance (TypeError ...) => GraphQL.API.HasAnnotatedType GHC.Integer.Type.Integer instance GraphQL.API.HasAnnotatedInputType a => GraphQL.API.HasAnnotatedInputType (GHC.Base.Maybe a) instance GraphQL.API.HasAnnotatedInputType GHC.Types.Int instance GraphQL.API.HasAnnotatedInputType GHC.Int.Int32 instance GraphQL.API.HasAnnotatedInputType GHC.Types.Bool instance GraphQL.API.HasAnnotatedInputType Data.Text.Internal.Text instance GraphQL.API.HasAnnotatedInputType GHC.Types.Double instance GraphQL.API.HasAnnotatedInputType GHC.Types.Float instance GraphQL.API.HasAnnotatedInputType t => GraphQL.API.HasAnnotatedInputType (GraphQL.API.List t) instance (GHC.TypeLits.KnownSymbol ks, GraphQL.API.Enum.GraphQLEnum enum) => GraphQL.API.HasAnnotatedInputType (GraphQL.API.Enum ks enum) instance (GHC.TypeLits.KnownSymbol dataName, GHC.TypeLits.KnownSymbol consName, GraphQL.API.GenericInputObjectFieldDefinitions records) => GraphQL.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 (GHC.TypeLits.KnownSymbol fieldName, GraphQL.API.HasAnnotatedInputType wrappedType, GraphQL.API.GenericInputObjectFieldDefinitions rest) => GraphQL.API.GenericInputObjectFieldDefinitions (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Base.Just fieldName) u s l) (GHC.Generics.Rec0 wrappedType) GHC.Generics.:*: rest) instance (GHC.TypeLits.KnownSymbol fieldName, GraphQL.API.HasAnnotatedInputType wrappedType) => GraphQL.API.GenericInputObjectFieldDefinitions (GHC.Generics.S1 ('GHC.Generics.MetaSel ('GHC.Base.Just fieldName) u s l) (GHC.Generics.Rec0 wrappedType)) module GraphQL.Resolver data ResolverError -- | There was a problem in the schema. Server-side problem. SchemaError :: NameError -> 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 class HasResolver m a where type Handler m a where { type family Handler m a; } resolve :: HasResolver m a => Handler m a -> Maybe (SelectionSetByType Value) -> m (Result Value) -- | 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 -- | 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 where defaultFor _ = empty -- | defaultFor returns the value to be used when no value has been given. defaultFor :: Defaultable a => Name -> Maybe a 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) instance GHC.Classes.Eq a => GHC.Classes.Eq (GraphQL.Resolver.Result a) instance GHC.Base.Functor GraphQL.Resolver.Result instance GHC.Show.Show a => GHC.Show.Show (GraphQL.Resolver.Result a) instance GHC.Classes.Eq GraphQL.Resolver.ResolverError instance GHC.Show.Show GraphQL.Resolver.ResolverError instance GraphQL.Internal.Output.GraphQLError GraphQL.Resolver.ResolverError instance GHC.Base.Applicative GraphQL.Resolver.Result instance GraphQL.Resolver.Defaultable GHC.Int.Int32 instance GraphQL.Resolver.Defaultable GHC.Types.Double instance GraphQL.Resolver.Defaultable GHC.Types.Bool instance GraphQL.Resolver.Defaultable Data.Text.Internal.Text instance GraphQL.Resolver.Defaultable (GHC.Base.Maybe a) instance GHC.Base.Applicative m => GraphQL.Resolver.HasResolver m GHC.Int.Int32 instance GHC.Base.Applicative m => GraphQL.Resolver.HasResolver m GHC.Types.Double instance GHC.Base.Applicative m => GraphQL.Resolver.HasResolver m Data.Text.Internal.Text instance GHC.Base.Applicative m => GraphQL.Resolver.HasResolver m GHC.Types.Bool instance (GHC.Base.Monad m, GHC.Base.Applicative m, GraphQL.Resolver.HasResolver m hg) => GraphQL.Resolver.HasResolver m (GraphQL.API.List hg) instance (GHC.Base.Applicative m, GraphQL.API.Enum.GraphQLEnum enum) => GraphQL.Resolver.HasResolver m (GraphQL.API.Enum ksN enum) instance (GraphQL.Resolver.HasResolver m hg, GHC.Base.Monad m) => GraphQL.Resolver.HasResolver m (GHC.Base.Maybe hg) instance (GHC.TypeLits.KnownSymbol ksG, GraphQL.Resolver.HasResolver m t, GraphQL.API.HasAnnotatedType t, GHC.Base.Monad m) => GraphQL.Resolver.BuildFieldResolver m (GraphQL.Resolver.JustHandler (GraphQL.API.Field ksG t)) instance (GHC.TypeLits.KnownSymbol ksH, GraphQL.Resolver.BuildFieldResolver m f, GraphQL.Value.FromValue.FromValue t, GraphQL.Resolver.Defaultable t, GraphQL.API.HasAnnotatedInputType t, GHC.Base.Monad m) => GraphQL.Resolver.BuildFieldResolver m (GraphQL.Resolver.PlainArgument (GraphQL.API.Argument ksH t) f) instance (GHC.TypeLits.KnownSymbol ksK, GraphQL.Resolver.BuildFieldResolver m f, GHC.TypeLits.KnownSymbol name, GraphQL.Resolver.Defaultable t, GraphQL.API.Enum.GraphQLEnum t, GHC.Base.Monad m) => GraphQL.Resolver.BuildFieldResolver m (GraphQL.Resolver.EnumArgument (GraphQL.API.Argument ksK (GraphQL.API.Enum name t)) f) instance (GraphQL.Resolver.BuildFieldResolver m dispatchType, dispatchType ~ GraphQL.Resolver.FieldResolverDispatchType f, GraphQL.Resolver.RunFields m fs, GHC.TypeLits.KnownSymbol (GraphQL.Resolver.FieldName dispatchType), GHC.Base.Monad m) => GraphQL.Resolver.RunFields m (f GraphQL.Resolver.:<> fs) instance (GraphQL.Resolver.BuildFieldResolver m dispatchType, GHC.TypeLits.KnownSymbol ksM, dispatchType ~ GraphQL.Resolver.FieldResolverDispatchType (GraphQL.API.Field ksM t), GHC.Base.Monad m) => GraphQL.Resolver.RunFields m (GraphQL.API.Field ksM t) instance (GraphQL.Resolver.BuildFieldResolver m dispatchType, dispatchType ~ GraphQL.Resolver.FieldResolverDispatchType (a GraphQL.API.:> b), GHC.TypeLits.KnownSymbol (GraphQL.Resolver.FieldName dispatchType), GHC.Base.Monad m) => GraphQL.Resolver.RunFields m (a GraphQL.API.:> b) instance (GraphQL.Resolver.RunFields m (GraphQL.Resolver.RunFieldsType m fields), GraphQL.API.HasObjectDefinition (GraphQL.API.Object typeName interfaces fields), GHC.Base.Monad m) => GraphQL.Resolver.HasResolver m (GraphQL.API.Object typeName interfaces fields) instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, GraphQL.Resolver.TypeIndex m (GraphQL.API.Object name interfaces fields) union ~ GraphQL.Resolver.Handler m (GraphQL.API.Object name interfaces fields), GraphQL.Resolver.RunFields m (GraphQL.Resolver.RunFieldsType m fields), GraphQL.API.HasObjectDefinition (GraphQL.API.Object name interfaces fields), GraphQL.Resolver.RunUnion m union objects) => GraphQL.Resolver.RunUnion m union (GraphQL.API.Object name interfaces fields : objects) instance GraphQL.Resolver.RunUnion m union '[] instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol unionName, GraphQL.Resolver.RunUnion m (GraphQL.API.Union unionName objects) objects) => GraphQL.Resolver.HasResolver m (GraphQL.API.Union unionName objects) -- | Interface for GraphQL API. -- -- Note: This module is highly subject to change. We're still -- figuring where to draw the lines and what to expose. module GraphQL -- | Interpet a GraphQL query. -- -- Compiles then executes a GraphQL query. interpretQuery :: forall api m. (Applicative m, HasResolver m api, HasObjectDefinition api) => Handler m api -> Text -> Maybe Name -> VariableValues -> m Response -- | Interpret an anonymous GraphQL query. -- -- Anonymous queries have no name and take no variables. interpretAnonymousQuery :: forall api m. (Applicative m, HasResolver m api, HasObjectDefinition api) => Handler m api -> Text -> m Response -- | GraphQL response. -- -- A GraphQL response must: -- --