module Hasura.GraphQL.Schema.NamingCase
( isGraphqlCase,
hasNamingConventionChanged,
)
where
import Data.HashSet qualified as Set
import Hasura.Prelude
import Hasura.RQL.Types.NamingCase
import Hasura.Server.Types (ExperimentalFeature (..))
isGraphqlCase :: NamingCase -> Bool
isGraphqlCase :: NamingCase -> Bool
isGraphqlCase NamingCase
GraphqlCase = Bool
True
isGraphqlCase NamingCase
_ = Bool
False
hasNamingConventionChanged :: (Set.HashSet ExperimentalFeature, NamingCase) -> (Set.HashSet ExperimentalFeature, NamingCase) -> Bool
hasNamingConventionChanged :: (HashSet ExperimentalFeature, NamingCase)
-> (HashSet ExperimentalFeature, NamingCase) -> Bool
hasNamingConventionChanged (HashSet ExperimentalFeature
prevExperimentalFeatures, NamingCase
prevDefaultNamingCase) (HashSet ExperimentalFeature
currExperimentalFeatures, NamingCase
currDefaultNamingCase) =
case ((ExperimentalFeature
EFNamingConventions ExperimentalFeature -> HashSet ExperimentalFeature -> Bool
forall a. Eq a => a -> HashSet a -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` HashSet ExperimentalFeature
prevExperimentalFeatures, NamingCase
prevDefaultNamingCase), (ExperimentalFeature
EFNamingConventions ExperimentalFeature -> HashSet ExperimentalFeature -> Bool
forall a. Eq a => a -> HashSet a -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` HashSet ExperimentalFeature
currExperimentalFeatures, NamingCase
currDefaultNamingCase)) of
((Bool
False, NamingCase
_), (Bool
True, NamingCase
GraphqlCase)) -> Bool
True
((Bool
True, NamingCase
GraphqlCase), (Bool
True, NamingCase
HasuraCase)) -> Bool
True
((Bool
True, NamingCase
HasuraCase), (Bool
True, NamingCase
GraphqlCase)) -> Bool
True
((Bool
True, NamingCase
GraphqlCase), (Bool
False, NamingCase
_)) -> Bool
True
((Bool, NamingCase), (Bool, NamingCase))
_ -> Bool
False