Remove unused QueryError.TransformationError
This commit is contained in:
parent
1af95345d2
commit
f671645043
@ -33,7 +33,7 @@ execute :: (MonadCatch m, VariableValue a, Serialize b)
|
||||
-> m (Either (ResponseEventStream m b) (Response b))
|
||||
execute schema' operationName subs document =
|
||||
case Transform.document schema' operationName subs document of
|
||||
Left queryError -> pure $ singleError $ Transform.queryError queryError
|
||||
Left queryError -> pure $ singleError $ show queryError
|
||||
Right transformed -> executeRequest transformed
|
||||
|
||||
executeRequest :: (MonadCatch m, Serialize a)
|
||||
|
@ -14,7 +14,7 @@ module Language.GraphQL.Execute.Internal
|
||||
import Control.Monad.Trans.State (modify)
|
||||
import Control.Monad.Catch (MonadCatch)
|
||||
import Data.Sequence ((|>))
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import Language.GraphQL.Execute.Coerce
|
||||
import Language.GraphQL.Error
|
||||
( CollectErrsT
|
||||
@ -32,5 +32,6 @@ addError returnValue error' = modify appender >> pure returnValue
|
||||
{ errors = errors |> error'
|
||||
}
|
||||
|
||||
singleError :: Serialize b => forall a. Text -> Either a (Response b)
|
||||
singleError message = Right $ Response null $ pure $ Error message [] []
|
||||
singleError :: Serialize b => forall a. String -> Either a (Response b)
|
||||
singleError message =
|
||||
Right $ Response null $ pure $ Error (Text.pack message) [] []
|
||||
|
@ -15,8 +15,6 @@ import Data.HashMap.Strict (HashMap)
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
import qualified Data.List.NonEmpty as NonEmpty
|
||||
import Data.Sequence (Seq(..))
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import Language.GraphQL.AST (Name)
|
||||
import Language.GraphQL.Execute.Coerce
|
||||
import Language.GraphQL.Execute.Execution
|
||||
@ -32,7 +30,7 @@ subscribe :: (MonadCatch m, Serialize a)
|
||||
=> HashMap Name (Type m)
|
||||
-> Out.ObjectType m
|
||||
-> Seq (Transform.Selection m)
|
||||
-> m (Either Text (ResponseEventStream m a))
|
||||
-> m (Either String (ResponseEventStream m a))
|
||||
subscribe types' objectType fields = do
|
||||
sourceStream <- createSourceEventStream types' objectType fields
|
||||
traverse (mapSourceToResponseEvent types' objectType fields) sourceStream
|
||||
@ -51,7 +49,7 @@ createSourceEventStream :: MonadCatch m
|
||||
=> HashMap Name (Type m)
|
||||
-> Out.ObjectType m
|
||||
-> Seq (Transform.Selection m)
|
||||
-> m (Either Text (Out.SourceEventStream m))
|
||||
-> m (Either String (Out.SourceEventStream m))
|
||||
createSourceEventStream _types subscriptionType@(Out.ObjectType _ _ _ fieldTypes) fields
|
||||
| [fieldGroup] <- OrderedMap.elems groupedFieldSet
|
||||
, Transform.Field _ fieldName arguments' _ <- NonEmpty.head fieldGroup
|
||||
@ -70,21 +68,19 @@ resolveFieldEventStream :: MonadCatch m
|
||||
=> Type.Value
|
||||
-> Type.Subs
|
||||
-> Out.Subscribe m
|
||||
-> m (Either Text (Out.SourceEventStream m))
|
||||
-> m (Either String (Out.SourceEventStream m))
|
||||
resolveFieldEventStream result args resolver =
|
||||
catch (Right <$> runReaderT resolver context) handleEventStreamError
|
||||
where
|
||||
handleEventStreamError :: MonadCatch m
|
||||
=> ResolverException
|
||||
-> m (Either Text (Out.SourceEventStream m))
|
||||
handleEventStreamError = pure . Left . Text.pack . displayException
|
||||
-> m (Either String (Out.SourceEventStream m))
|
||||
handleEventStreamError = pure . Left . displayException
|
||||
context = Type.Context
|
||||
{ Type.arguments = Type.Arguments args
|
||||
, Type.values = result
|
||||
}
|
||||
|
||||
-- This is actually executeMutation, but we don't distinguish between queries
|
||||
-- and mutations yet.
|
||||
executeSubscriptionEvent :: (MonadCatch m, Serialize a)
|
||||
=> HashMap Name (Type m)
|
||||
-> Out.ObjectType m
|
||||
|
@ -25,7 +25,6 @@ module Language.GraphQL.Execute.Transform
|
||||
, QueryError(..)
|
||||
, Selection(..)
|
||||
, document
|
||||
, queryError
|
||||
) where
|
||||
|
||||
import Control.Monad (foldM, unless)
|
||||
@ -71,8 +70,6 @@ data Selection m
|
||||
| SelectionField (Field m)
|
||||
|
||||
-- | GraphQL has 3 operation types: queries, mutations and subscribtions.
|
||||
--
|
||||
-- Currently only queries and mutations are supported.
|
||||
data Operation m
|
||||
= Query (Maybe Text) (Seq (Selection m))
|
||||
| Mutation (Maybe Text) (Seq (Selection m))
|
||||
@ -98,10 +95,19 @@ data QueryError
|
||||
= OperationNotFound Text
|
||||
| OperationNameRequired
|
||||
| CoercionError
|
||||
| TransformationError
|
||||
| EmptyDocument
|
||||
| UnsupportedRootOperation
|
||||
|
||||
instance Show QueryError where
|
||||
show (OperationNotFound operationName) = unwords
|
||||
["Operation", Text.unpack operationName, "couldn't be found in the document."]
|
||||
show OperationNameRequired = "Missing operation name."
|
||||
show CoercionError = "Coercion error."
|
||||
show EmptyDocument =
|
||||
"The document doesn't contain any executable operations."
|
||||
show UnsupportedRootOperation =
|
||||
"Root operation type couldn't be found in the schema."
|
||||
|
||||
data Input
|
||||
= Int Int32
|
||||
| Float Double
|
||||
@ -114,17 +120,6 @@ data Input
|
||||
| Variable Type.Value
|
||||
deriving (Eq, Show)
|
||||
|
||||
queryError :: QueryError -> Text
|
||||
queryError (OperationNotFound operationName) = Text.unwords
|
||||
["Operation", operationName, "couldn't be found in the document."]
|
||||
queryError OperationNameRequired = "Missing operation name."
|
||||
queryError CoercionError = "Coercion error."
|
||||
queryError TransformationError = "Schema transformation error."
|
||||
queryError EmptyDocument =
|
||||
"The document doesn't contain any executable operations."
|
||||
queryError UnsupportedRootOperation =
|
||||
"Root operation type couldn't be found in the schema."
|
||||
|
||||
getOperation
|
||||
:: Maybe Full.Name
|
||||
-> NonEmpty OperationDefinition
|
||||
|
Loading…
Reference in New Issue
Block a user