mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-20 15:09:02 +03:00
Remove several outdated backend constraints
## Description This PR removes as many constraints as possible from Backend without refactoring the code. Thanks to #1844, a few ToJSON functions can be removed from the IR, and several constraints were simply redundant. This PR borrows from similar work done as part of #1666. ## Note To remove constraints more aggressively, I have explored the possibility of _removing Representable altogether_, in a [separate commit](https://github.com/hasura/graphql-engine-mono/compare/nicuveo/remove-extension-constraints..nicuveo/tentative-remove-representable). I am not convinced it's a good idea in terms of readability of the code, but it's a possibility. Further work includes deciding what we want to do with `Show` and `ToTxt`; see #1747. https://github.com/hasura/graphql-engine-mono/pull/1843 GitOrigin-RevId: 337324ad90cb8f86f06e1c5a36aa44bb414e195a
This commit is contained in:
parent
7bead93827
commit
a978b6d683
@ -52,7 +52,6 @@ import Data.Aeson.Internal
|
||||
import Data.Aeson.TH
|
||||
import Data.Monoid
|
||||
import Data.Text.Extended
|
||||
import Data.Typeable (Typeable)
|
||||
|
||||
import Hasura.Incremental (Cacheable)
|
||||
import Hasura.RQL.Types.Backend
|
||||
@ -129,7 +128,7 @@ data GExists (b :: BackendType) a
|
||||
} deriving (Functor, Foldable, Traversable, Generic)
|
||||
deriving instance (Backend b, Show a) => Show (GExists b a)
|
||||
deriving instance (Backend b, Eq a) => Eq (GExists b a)
|
||||
deriving instance (Backend b, Typeable a, Data a) => Data (GExists b a)
|
||||
deriving instance (Backend b, Data a) => Data (GExists b a)
|
||||
instance (Backend b, NFData a) => NFData (GExists b a)
|
||||
instance (Backend b, Data a) => Plated (GExists b a)
|
||||
instance (Backend b, Cacheable a) => Cacheable (GExists b a)
|
||||
@ -189,8 +188,7 @@ data PartialSQLExp (b :: BackendType)
|
||||
= PSESessVar !(SessionVarType b) !SessionVariable
|
||||
| PSESQLExp !(SQLExpression b)
|
||||
deriving (Generic)
|
||||
deriving instance (Backend b) => Eq (PartialSQLExp b)
|
||||
deriving instance (Backend b) => Data (PartialSQLExp b)
|
||||
deriving instance (Backend b) => Eq (PartialSQLExp b)
|
||||
instance (Backend b, NFData (BooleanOperators b (PartialSQLExp b))) => NFData (PartialSQLExp b)
|
||||
instance (Backend b, Cacheable (BooleanOperators b (PartialSQLExp b))) => Hashable (PartialSQLExp b)
|
||||
instance (Backend b, Hashable (BooleanOperators b (PartialSQLExp b))) => Cacheable (PartialSQLExp b)
|
||||
|
@ -29,13 +29,6 @@ instance FromJSON OrderByCol where
|
||||
(String t) -> orderByColFromToks $ T.split (=='.') t
|
||||
v -> parseJSON v >>= orderByColFromToks
|
||||
|
||||
instance ToJSON OrderByCol where
|
||||
toJSON = toJSON . orderByColToTxt
|
||||
|
||||
orderByColToTxt :: OrderByCol -> Text
|
||||
orderByColToTxt = \case
|
||||
OCPG pgCol -> getFieldNameTxt pgCol
|
||||
OCRel rel obCol -> getFieldNameTxt rel <> "." <> orderByColToTxt obCol
|
||||
|
||||
orderByColFromToks
|
||||
:: (MonadFail m)
|
||||
@ -70,6 +63,3 @@ deriving instance (Backend b, Eq a) => Eq (OrderByItemG b a)
|
||||
instance (Backend b, Hashable a) => Hashable (OrderByItemG b a)
|
||||
|
||||
type OrderByItem b = OrderByItemG b OrderByCol
|
||||
|
||||
instance (Backend b, ToJSON a) => ToJSON (OrderByItemG b a) where
|
||||
toJSON = genericToJSON hasuraJSON{omitNothingFields=True}
|
||||
|
@ -16,7 +16,7 @@ import Hasura.SQL.Tag
|
||||
import Hasura.SQL.Types
|
||||
|
||||
|
||||
type Representable a = (Show a, Eq a, Hashable a, Cacheable a, NFData a, Typeable a)
|
||||
type Representable a = (Show a, Eq a, Hashable a, Cacheable a, NFData a)
|
||||
|
||||
type SessionVarType b = CollectableType (ScalarType b)
|
||||
|
||||
@ -53,42 +53,28 @@ class
|
||||
, Representable (ScalarType b)
|
||||
, Representable (SQLExpression b)
|
||||
, Representable (SQLOperator b)
|
||||
, Representable (SessionVarType b)
|
||||
, Representable (SourceConnConfiguration b)
|
||||
, Representable (ExtraTableMetadata b)
|
||||
, Representable (XRelay b)
|
||||
, Representable (XNodesAgg b)
|
||||
, Representable (XComputedField b)
|
||||
, Generic (Column b)
|
||||
, Eq (RawFunctionInfo b)
|
||||
, Ord (TableName b)
|
||||
, Ord (FunctionName b)
|
||||
, Ord (ScalarType b)
|
||||
, Ord (XRelay b)
|
||||
, Ord (Column b)
|
||||
, Data (TableName b)
|
||||
, Data (ScalarType b)
|
||||
, Traversable (BooleanOperators b)
|
||||
, Data (SQLExpression b)
|
||||
, FromJSON (BasicOrderType b)
|
||||
, FromJSON (Column b)
|
||||
, FromJSON (ConstraintName b)
|
||||
, FromJSON (FunctionName b)
|
||||
, FromJSON (NullsOrderType b)
|
||||
, FromJSON (ScalarType b)
|
||||
, FromJSON (TableName b)
|
||||
, FromJSON (SourceConnConfiguration b)
|
||||
, FromJSON (ExtraTableMetadata b)
|
||||
, FromJSONKey (Column b)
|
||||
, ToJSON (BasicOrderType b)
|
||||
, ToJSON (Column b)
|
||||
, ToJSON (ConstraintName b)
|
||||
, ToJSON (FunctionArgType b)
|
||||
, ToJSON (FunctionName b)
|
||||
, ToJSON (NullsOrderType b)
|
||||
, ToJSON (ScalarType b)
|
||||
, ToJSON (SourceConfig b)
|
||||
, ToJSON (SourceConfig b)
|
||||
, ToJSON (TableName b)
|
||||
, ToJSON (SourceConnConfiguration b)
|
||||
, ToJSON (ExtraTableMetadata b)
|
||||
@ -103,6 +89,8 @@ class
|
||||
, ToTxt (TableName b)
|
||||
, ToTxt (ConstraintName b)
|
||||
, Cacheable (SourceConfig b)
|
||||
, Typeable (TableName b)
|
||||
, Typeable (ConstraintName b)
|
||||
, Typeable b
|
||||
, HasTag b
|
||||
) => Backend (b :: BackendType) where
|
||||
|
Loading…
Reference in New Issue
Block a user