{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} module Data.Morpheus.Server.Deriving.Schema.TypeContent ( buildTypeContent, ) where import Data.Morpheus.Server.Deriving.Schema.Enum ( buildEnumTypeContent, ) import Data.Morpheus.Server.Deriving.Schema.Internal ( KindedType (..), TyContent, ) import Data.Morpheus.Server.Deriving.Schema.Object ( buildObjectTypeContent, ) import Data.Morpheus.Server.Deriving.Schema.Union (buildUnionTypeContent) import Data.Morpheus.Server.Deriving.Utils ( ConsRep (..), isEmptyConstraint, ) import Data.Morpheus.Server.Deriving.Utils.Kinded ( CategoryValue (..), ) import Data.Morpheus.Server.Types.GQLType (GQLType) import Data.Morpheus.Server.Types.SchemaT (SchemaT) import Data.Morpheus.Types.Internal.AST buildTypeContent :: (GQLType a, CategoryValue kind) => KindedType kind a -> [ConsRep (TyContent kind)] -> SchemaT kind (TypeContent TRUE kind CONST) buildTypeContent :: KindedType kind a -> [ConsRep (TyContent kind)] -> SchemaT kind (TypeContent TRUE kind CONST) buildTypeContent KindedType kind a scope [ConsRep {[FieldRep (TyContent kind)] consFields :: forall v. ConsRep v -> [FieldRep v] consFields :: [FieldRep (TyContent kind)] consFields}] = KindedType kind a -> [FieldRep (TyContent kind)] -> SchemaT kind (TypeContent TRUE kind CONST) forall (f :: * -> *) a (cat :: TypeCategory). (Applicative f, GQLType a) => KindedType cat a -> [FieldRep (Maybe (FieldContent TRUE cat CONST))] -> f (TypeContent TRUE cat CONST) buildObjectTypeContent KindedType kind a scope [FieldRep (TyContent kind)] consFields buildTypeContent KindedType kind a scope [ConsRep (TyContent kind)] cons | (ConsRep (TyContent kind) -> Bool) -> [ConsRep (TyContent kind)] -> Bool forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool all ConsRep (TyContent kind) -> Bool forall a. ConsRep a -> Bool isEmptyConstraint [ConsRep (TyContent kind)] cons = KindedType kind a -> [TypeName] -> SchemaT kind (TypeContent TRUE kind CONST) forall a (kind :: TypeCategory) (c :: TypeCategory). GQLType a => KindedType kind a -> [TypeName] -> SchemaT c (TypeContent TRUE kind CONST) buildEnumTypeContent KindedType kind a scope (ConsRep (TyContent kind) -> TypeName forall v. ConsRep v -> TypeName consName (ConsRep (TyContent kind) -> TypeName) -> [ConsRep (TyContent kind)] -> [TypeName] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [ConsRep (TyContent kind)] cons) buildTypeContent KindedType kind a scope [ConsRep (TyContent kind)] cons = KindedType kind a -> [ConsRep (TyContent kind)] -> SchemaT kind (TypeContent TRUE kind CONST) forall a (kind :: TypeCategory) (c :: TypeCategory). (GQLType a, CategoryValue kind) => KindedType kind a -> [ConsRep (Maybe (FieldContent TRUE kind CONST))] -> SchemaT c (TypeContent TRUE kind CONST) buildUnionTypeContent KindedType kind a scope [ConsRep (TyContent kind)] cons