summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/Execute/Transform.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-05-25 07:41:21 +0200
committerEugen Wissner <belka@caraus.de>2020-05-25 07:41:21 +0200
commit61dbe6c7280a899b485146aa8557948417e78360 (patch)
tree2b3bb2ea7144dd57a44076ab8f5af3321d5a95f1 /src/Language/GraphQL/Execute/Transform.hs
parenteb90a4091c1f2586640ee49d6f91fc83c05239f6 (diff)
downloadgraphql-61dbe6c7280a899b485146aa8557948417e78360.tar.gz
Split input/output types and values into 2 modules
Diffstat (limited to 'src/Language/GraphQL/Execute/Transform.hs')
-rw-r--r--src/Language/GraphQL/Execute/Transform.hs37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/Language/GraphQL/Execute/Transform.hs b/src/Language/GraphQL/Execute/Transform.hs
index 9768675..849a646 100644
--- a/src/Language/GraphQL/Execute/Transform.hs
+++ b/src/Language/GraphQL/Execute/Transform.hs
@@ -30,7 +30,6 @@ import qualified Language.GraphQL.AST as Full
import qualified Language.GraphQL.AST.Core as Core
import Language.GraphQL.Execute.Coerce
import qualified Language.GraphQL.Schema as Schema
-import qualified Language.GraphQL.Type.Definition as Definition
import qualified Language.GraphQL.Type.Directive as Directive
import qualified Language.GraphQL.Type.In as In
import Language.GraphQL.Type.Schema
@@ -86,31 +85,31 @@ getOperation (Just operationName) operations
lookupInputType
:: Full.Type
- -> HashMap.HashMap Full.Name (Definition.TypeDefinition m)
- -> Maybe Definition.InputType
+ -> HashMap.HashMap Full.Name (Type m)
+ -> Maybe In.Type
lookupInputType (Full.TypeNamed name) types =
case HashMap.lookup name types of
- Just (Definition.ScalarTypeDefinition scalarType) ->
- Just $ Definition.ScalarInputType scalarType
- Just (Definition.EnumTypeDefinition enumType) ->
- Just $ Definition.EnumInputType enumType
- Just (Definition.InputObjectTypeDefinition objectType) ->
- Just $ Definition.ObjectInputType objectType
+ Just (ScalarType scalarType) ->
+ Just $ In.NamedScalarType scalarType
+ Just (EnumType enumType) ->
+ Just $ In.NamedEnumType enumType
+ Just (InputObjectType objectType) ->
+ Just $ In.NamedInputObjectType objectType
_ -> Nothing
lookupInputType (Full.TypeList list) types
- = Definition.ListInputType
+ = In.ListType
<$> lookupInputType list types
lookupInputType (Full.TypeNonNull (Full.NonNullTypeNamed nonNull)) types =
case HashMap.lookup nonNull types of
- Just (Definition.ScalarTypeDefinition scalarType) ->
- Just $ Definition.NonNullScalarInputType scalarType
- Just (Definition.EnumTypeDefinition enumType) ->
- Just $ Definition.NonNullEnumInputType enumType
- Just (Definition.InputObjectTypeDefinition objectType) ->
- Just $ Definition.NonNullObjectInputType objectType
+ Just (ScalarType scalarType) ->
+ Just $ In.NonNullScalarType scalarType
+ Just (EnumType enumType) ->
+ Just $ In.NonNullEnumType enumType
+ Just (InputObjectType objectType) ->
+ Just $ In.NonNullInputObjectType objectType
_ -> Nothing
lookupInputType (Full.TypeNonNull (Full.NonNullTypeList nonNull)) types
- = Definition.NonNullListInputType
+ = In.NonNullListType
<$> lookupInputType nonNull types
coerceVariableValues :: (Monad m, VariableValue a)
@@ -137,10 +136,10 @@ coerceVariableValues schema operationDefinition variableValues' =
<*> coercedValues
choose Nothing defaultValue variableType
| Just _ <- defaultValue = defaultValue
- | not (isNonNullInputType variableType) = Just In.Null
+ | not (In.isNonNullType variableType) = Just In.Null
choose (Just value') _ variableType
| Just coercedValue <- coerceVariableValue variableType value'
- , not (isNonNullInputType variableType) || coercedValue /= In.Null =
+ , not (In.isNonNullType variableType) || coercedValue /= In.Null =
Just coercedValue
choose _ _ _ = Nothing