Merge branch 'master' into master

This commit is contained in:
PrathamJaiswal001 2023-01-09 22:11:36 +05:30 committed by GitHub
commit 0cc79ee195
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 22 additions and 89 deletions

View File

@ -17,18 +17,10 @@ source-repository head
location: https://github.com/hasura/graphql-parser-hs
common common-all
-- This warning strategy was inspired by Max Tagher's 'Enable All the
-- Warnings' blog post.
--
-- NOTE: '-Wno-prepositive-qualified-module' is currently a workaround for
-- https://github.com/haskell/cabal/pull/7352
ghc-options:
-Weverything -Wno-missing-exported-signatures
-Wno-missing-import-lists -Wno-missing-export-lists
-Wno-missed-specialisations -Wno-all-missed-specializations
-Wno-unsafe -Wno-safe -Wno-missing-safe-haskell-mode
-Wno-missing-local-signatures -Wno-monomorphism-restriction
-Wno-prepositive-qualified-module -Wno-unrecognised-pragmas
-Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
-- Insisting on export lists might help with compile times, and help to document modules:
-Wmissing-export-lists
if impl(ghc >=9.2)
ghc-options: -Wno-implicit-lift
@ -57,7 +49,6 @@ common common-all
RankNTypes
RecordWildCards
RoleAnnotations
StandaloneKindSignatures
StrictData
TupleSections

View File

@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
module Language.GraphQL.Draft.Generator
( -- * Generator
Generator (..),
@ -72,7 +74,6 @@ where
import Control.Monad.IO.Class (MonadIO)
import Data.HashMap.Strict as M
import Data.Kind (Constraint, Type)
import Data.Scientific (fromFloatDigits)
import Data.Text (Text)
import Data.Text qualified as T
@ -86,7 +87,6 @@ import Prelude
-------------------------------------------------------------------------------
-- | *Generator*
type Generator :: Type -> Constraint
class Generator a where
genValue :: Gen (Value a)

View File

@ -2,6 +2,7 @@
{-# HLINT ignore "Use mkName" #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
-- | Description: Parse text into GraphQL ASTs
module Language.GraphQL.Draft.Parser
@ -50,7 +51,6 @@ import Data.Char
import Data.Functor (($>))
import Data.HashMap.Strict (HashMap)
import Data.HashMap.Strict qualified as M
import Data.Kind (Constraint, Type)
import Data.Maybe (fromMaybe)
import Data.Scientific (Scientific)
import Data.Text (Text, find)
@ -121,7 +121,6 @@ variableDefinition =
defaultValue :: Parser (AST.Value Void)
defaultValue = tok "=" *> value
type Variable :: Type -> Constraint
class Variable var where
variable :: Parser var
@ -131,7 +130,6 @@ instance Variable Void where
instance Variable AST.Name where
variable = tok "$" *> nameParser <?> "variable"
type PossibleTypes :: Type -> Constraint
class PossibleTypes pos where
possibleTypes :: Parser pos
@ -531,13 +529,11 @@ between open close p = tok open *> p <* tok close
optempty :: Monoid a => Parser a -> Parser a
optempty = option mempty
type Expecting :: Type
data Expecting
= Anything
| Open
| Closed
type BlockState :: Type
data BlockState
= Escaped Expecting
| Quoting Expecting

View File

@ -1,6 +1,17 @@
{-# HLINT ignore "Use tshow" #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
module Language.GraphQL.Draft.Printer where
module Language.GraphQL.Draft.Printer
( Printer (..),
executableDocument,
graphQLType,
renderExecutableDoc,
schemaDocument,
selectionSet,
typeDefinitionP,
value,
)
where
-------------------------------------------------------------------------------
@ -11,7 +22,6 @@ import Data.ByteString.Builder.Scientific qualified as BSBS
import Data.Char (isControl)
import Data.HashMap.Strict (HashMap)
import Data.HashMap.Strict qualified as M
import Data.Kind (Constraint, Type)
import Data.List (intersperse, sort)
import Data.Scientific (Scientific)
import Data.String (IsString)
@ -32,7 +42,6 @@ import Prelude
-------------------------------------------------------------------------------
type Printer :: Type -> Constraint
class (Monoid a, IsString a) => Printer a where
textP :: Text -> a
charP :: Char -> a
@ -114,7 +123,6 @@ instance Printer T.Text where
intP = T.pack . show
doubleP = T.pack . show
type Print :: Type -> Constraint
class Print a where
printP :: Printer b => a -> b
@ -369,7 +377,6 @@ schemaDocument (SchemaDocument typeDefns) =
-- According to https://spec.graphql.org/June2018/#sec-Scalars:
-- > When representing a GraphQL schema using the type system definition language, the builtin scalar types should
-- > be omitted for brevity.
isNotBuiltInScalar :: TypeSystemDefinition -> Bool
isNotBuiltInScalar
( TypeSystemDefinitionType
(TypeDefinitionScalar (ScalarTypeDefinition _ name _))

View File

@ -1,6 +1,7 @@
{-# HLINT ignore "Use onLeft" #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
-- | Description: The GraphQL AST
module Language.GraphQL.Draft.Syntax
@ -99,7 +100,6 @@ import Data.Bifunctor (Bifunctor (bimap))
import Data.Bool (bool)
import Data.HashMap.Strict (HashMap)
import Data.Hashable (Hashable)
import Data.Kind (Type)
import Data.Scientific (Scientific)
import Data.String (IsString (..))
import Data.Text (Text)
@ -121,11 +121,9 @@ import Prelude
-- * Documents
type Document :: Type
newtype Document = Document {getDefinitions :: [Definition]}
deriving stock (Eq, Lift, Ord, Show)
type Definition :: Type
data Definition
= DefinitionExecutable (ExecutableDefinition Name)
| DefinitionTypeSystem TypeSystemDefinition
@ -133,7 +131,6 @@ data Definition
instance Hashable Definition
type ExecutableDocument :: Type -> Type
newtype ExecutableDocument var = ExecutableDocument {getExecutableDefinitions :: [ExecutableDefinition var]}
deriving stock (Eq, Lift, Ord, Show, Functor, Foldable, Traversable)
deriving newtype (Hashable, NFData)
@ -147,7 +144,6 @@ instance J.FromJSON (ExecutableDocument Name) where
instance J.ToJSON (ExecutableDocument Name) where
toJSON = J.String . renderExecutableDoc
type ExecutableDefinition :: Type -> Type
data ExecutableDefinition var
= ExecutableDefinitionOperation (OperationDefinition FragmentSpread var)
| ExecutableDefinitionFragment FragmentDefinition
@ -173,14 +169,12 @@ partitionExDefs = foldr f ([], [], [])
ExecutableDefinitionFragment frag ->
(selSets, ops, frag : frags)
type TypeSystemDefinition :: Type
data TypeSystemDefinition
= TypeSystemDefinitionSchema SchemaDefinition
| TypeSystemDefinitionType (TypeDefinition () InputValueDefinition) -- No 'possibleTypes' specified for interfaces
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type SchemaDefinition :: Type
data SchemaDefinition = SchemaDefinition
{ _sdDirectives :: Maybe [Directive Void],
_sdRootOperationTypeDefinitions :: [RootOperationTypeDefinition]
@ -188,7 +182,6 @@ data SchemaDefinition = SchemaDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type RootOperationTypeDefinition :: Type
data RootOperationTypeDefinition = RootOperationTypeDefinition
{ _rotdOperationType :: OperationType,
_rotdOperationTypeType :: Name
@ -196,7 +189,6 @@ data RootOperationTypeDefinition = RootOperationTypeDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type OperationType :: Type
data OperationType
= OperationTypeQuery
| OperationTypeMutation
@ -204,7 +196,6 @@ data OperationType
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type SchemaDocument :: Type
newtype SchemaDocument
= SchemaDocument [TypeSystemDefinition]
deriving stock (Eq, Generic, Lift, Ord, Show)
@ -219,20 +210,17 @@ instance J.FromJSON SchemaDocument where
-- | A variant of 'SchemaDocument' that additionally stores, for each interface,
-- the list of object types that implement that interface. Types are indexed by
-- their name for fast lookups.
type SchemaIntrospection :: Type
newtype SchemaIntrospection
= SchemaIntrospection (HashMap Name (TypeDefinition [Name] InputValueDefinition))
deriving stock (Eq, Generic, Ord, Show)
deriving newtype (Hashable)
type OperationDefinition :: (Type -> Type) -> Type -> Type
data OperationDefinition frag var
= OperationDefinitionTyped (TypedOperationDefinition frag var)
| OperationDefinitionUnTyped (SelectionSet frag var)
deriving stock (Eq, Generic, Lift, Ord, Show, Functor, Foldable, Traversable)
deriving anyclass (Hashable, NFData)
type TypedOperationDefinition :: (Type -> Type) -> Type -> Type
data TypedOperationDefinition frag var = TypedOperationDefinition
{ _todType :: OperationType,
_todName :: Maybe Name,
@ -243,7 +231,6 @@ data TypedOperationDefinition frag var = TypedOperationDefinition
deriving stock (Eq, Generic, Lift, Ord, Show, Functor, Foldable, Traversable)
deriving anyclass (Hashable, NFData)
type VariableDefinition :: Type
data VariableDefinition = VariableDefinition
{ _vdName :: Name,
_vdType :: GType,
@ -252,10 +239,8 @@ data VariableDefinition = VariableDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type SelectionSet :: (Type -> Type) -> Type -> Type
type SelectionSet frag var = [Selection frag var]
type Selection :: (Type -> Type) -> Type -> Type
data Selection frag var
= SelectionField (Field frag var)
| SelectionFragmentSpread (frag var)
@ -263,7 +248,6 @@ data Selection frag var
deriving stock (Eq, Generic, Lift, Ord, Show, Functor, Foldable, Traversable)
deriving anyclass (Hashable, NFData)
type Field :: (Type -> Type) -> Type -> Type
data Field frag var = Field
{ _fAlias :: Maybe Name,
_fName :: Name,
@ -288,7 +272,6 @@ instance (Lift (frag var), Lift var) => Lift (Field frag var) where
-- * Fragments
type FragmentSpread :: Type -> Type
data FragmentSpread var = FragmentSpread
{ _fsName :: Name,
_fsDirectives :: [Directive var]
@ -301,12 +284,10 @@ data FragmentSpread var = FragmentSpread
--
-- Note: This is equivalent to @'Const' 'Void'@, but annoyingly, 'Const' does
-- not provide a 'Lift' instance as of GHC 8.6.
type NoFragments :: Type -> Type
data NoFragments var
deriving stock (Eq, Generic, Lift, Ord, Show, Functor, Foldable, Traversable)
deriving anyclass (Hashable, NFData)
type InlineFragment :: (Type -> Type) -> Type -> Type
data InlineFragment frag var = InlineFragment
{ _ifTypeCondition :: Maybe Name,
_ifDirectives :: [Directive var],
@ -315,7 +296,6 @@ data InlineFragment frag var = InlineFragment
deriving stock (Eq, Generic, Lift, Ord, Show, Functor, Foldable, Traversable)
deriving anyclass (Hashable, NFData)
type FragmentDefinition :: Type
data FragmentDefinition = FragmentDefinition
{ _fdName :: Name,
_fdTypeCondition :: Name,
@ -327,7 +307,6 @@ data FragmentDefinition = FragmentDefinition
-- * Values
type Value :: Type -> Type
data Value var
= VVariable var
| VNull
@ -357,7 +336,6 @@ literal = fmap absurd
-- * Directives
type Directive :: Type -> Type
data Directive var = Directive
{ _dName :: Name,
_dArguments :: HashMap Name (Value var)
@ -376,12 +354,10 @@ instance Lift var => Lift (Directive var) where
-- * Type Reference
type Nullability :: Type
newtype Nullability = Nullability {unNullability :: Bool}
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving newtype (Hashable, NFData)
type GType :: Type
data GType
= TypeNamed Nullability Name
| TypeList Nullability GType
@ -422,7 +398,6 @@ isNotNull = not . isNullable
-- * Type definition
type TypeDefinition :: Type -> Type -> Type
data TypeDefinition possibleTypes inputType
= TypeDefinitionScalar ScalarTypeDefinition
| TypeDefinitionObject (ObjectTypeDefinition inputType)
@ -442,12 +417,10 @@ instance Bifunctor TypeDefinition where
TypeDefinitionEnum d -> TypeDefinitionEnum d
TypeDefinitionInputObject d -> TypeDefinitionInputObject $ fmap g d
type Description :: Type
newtype Description = Description {unDescription :: Text}
deriving stock (Eq, Lift, Ord, Show)
deriving newtype (Hashable, IsString, Monoid, NFData, Semigroup, J.FromJSON, J.ToJSON)
type ObjectTypeDefinition :: Type -> Type
data ObjectTypeDefinition inputType = ObjectTypeDefinition
{ _otdDescription :: Maybe Description,
_otdName :: Name,
@ -458,7 +431,6 @@ data ObjectTypeDefinition inputType = ObjectTypeDefinition
deriving stock (Eq, Generic, Lift, Ord, Show, Functor)
deriving anyclass (Hashable, NFData)
type FieldDefinition :: Type -> Type
data FieldDefinition inputType = FieldDefinition
{ _fldDescription :: Maybe Description,
_fldName :: Name,
@ -469,10 +441,8 @@ data FieldDefinition inputType = FieldDefinition
deriving stock (Eq, Generic, Lift, Ord, Show, Functor)
deriving anyclass (Hashable, NFData)
type ArgumentsDefinition :: Type -> Type
type ArgumentsDefinition inputType = [inputType]
type InputValueDefinition :: Type
data InputValueDefinition = InputValueDefinition
{ _ivdDescription :: Maybe Description,
_ivdName :: Name,
@ -483,7 +453,6 @@ data InputValueDefinition = InputValueDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type InterfaceTypeDefinition :: Type -> Type -> Type
data InterfaceTypeDefinition possibleTypes inputType = InterfaceTypeDefinition
{ _itdDescription :: Maybe Description,
_itdName :: Name,
@ -502,7 +471,6 @@ instance Bifunctor InterfaceTypeDefinition where
..
}
type UnionTypeDefinition :: Type
data UnionTypeDefinition = UnionTypeDefinition
{ _utdDescription :: Maybe Description,
_utdName :: Name,
@ -512,7 +480,6 @@ data UnionTypeDefinition = UnionTypeDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type ScalarTypeDefinition :: Type
data ScalarTypeDefinition = ScalarTypeDefinition
{ _stdDescription :: Maybe Description,
_stdName :: Name,
@ -521,7 +488,6 @@ data ScalarTypeDefinition = ScalarTypeDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type EnumTypeDefinition :: Type
data EnumTypeDefinition = EnumTypeDefinition
{ _etdDescription :: Maybe Description,
_etdName :: Name,
@ -531,7 +497,6 @@ data EnumTypeDefinition = EnumTypeDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type EnumValueDefinition :: Type
data EnumValueDefinition = EnumValueDefinition
{ _evdDescription :: Maybe Description,
_evdName :: EnumValue,
@ -540,12 +505,10 @@ data EnumValueDefinition = EnumValueDefinition
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type EnumValue :: Type
newtype EnumValue = EnumValue {unEnumValue :: Name}
deriving stock (Eq, Lift, Ord, Show)
deriving newtype (Hashable, NFData, J.ToJSON, J.FromJSON)
type InputObjectTypeDefinition :: Type -> Type
data InputObjectTypeDefinition inputType = InputObjectTypeDefinition
{ _iotdDescription :: Maybe Description,
_iotdName :: Name,
@ -555,7 +518,6 @@ data InputObjectTypeDefinition inputType = InputObjectTypeDefinition
deriving stock (Eq, Generic, Lift, Ord, Show, Functor)
deriving anyclass (Hashable, NFData)
type DirectiveDefinition :: Type -> Type
data DirectiveDefinition inputType = DirectiveDefinition
{ _ddDescription :: Maybe Description,
_ddName :: Name,
@ -565,14 +527,12 @@ data DirectiveDefinition inputType = DirectiveDefinition
deriving stock (Eq, Generic, Lift, Ord, Show, Functor)
deriving anyclass (Hashable, NFData)
type DirectiveLocation :: Type
data DirectiveLocation
= DLExecutable ExecutableDirectiveLocation
| DLTypeSystem TypeSystemDirectiveLocation
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type ExecutableDirectiveLocation :: Type
data ExecutableDirectiveLocation
= EDLQUERY
| EDLMUTATION
@ -584,7 +544,6 @@ data ExecutableDirectiveLocation
deriving stock (Eq, Generic, Lift, Ord, Show)
deriving anyclass (Hashable, NFData)
type TypeSystemDirectiveLocation :: Type
data TypeSystemDirectiveLocation
= TSDLSCHEMA
| TSDLSCALAR

View File

@ -4,14 +4,10 @@ module Language.GraphQL.Draft.Syntax
)
where
import Data.Kind (Type)
-------------------------------------------------------------------------------
type role ExecutableDocument nominal
type ExecutableDocument :: Type -> Type
data ExecutableDocument var
type SchemaDocument :: Type
data SchemaDocument

View File

@ -1,5 +1,6 @@
{-# HLINT ignore "Use onNothing" #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
-- | Internal functionality for Name values.
--
@ -28,7 +29,6 @@ import Data.Aeson qualified as J
import Data.Char qualified as C
import Data.Coerce (coerce)
import Data.Hashable (Hashable)
import Data.Kind (Type)
import Data.Text (Text)
import Data.Text qualified as T
import Instances.TH.Lift ()
@ -40,7 +40,6 @@ import Prelude
-------------------------------------------------------------------------------
-- Defined here and re-exported in the public module to avoid exporting `unName`.`
type Name :: Type
newtype Name = Name {unName :: Text}
deriving stock (Eq, Lift, Ord, Show)
deriving newtype (Semigroup, Hashable, NFData, Pretty, J.ToJSONKey, J.ToJSON)
@ -48,7 +47,6 @@ newtype Name = Name {unName :: Text}
-- | @NameSuffix@ is essentially a GQL identifier that can be used as Suffix
-- It is slightely different from @Name@ as it relaxes the criteria that a
-- @Name@ cannot start with a digit.
type NameSuffix :: Type
newtype NameSuffix = Suffix {unNameSuffix :: Text}
deriving stock (Eq, Lift, Ord, Show)
deriving newtype (Semigroup, Hashable, NFData, Pretty, J.ToJSONKey, J.ToJSON)

View File

@ -1,8 +1,5 @@
module Language.GraphQL.Draft.Syntax.Name (Name) where
import Data.Kind (Type)
-------------------------------------------------------------------------------
type Name :: Type
data Name

View File

@ -11,7 +11,6 @@ import BlockStrings (blockTest)
import Control.Monad (unless)
import Data.ByteString.Builder qualified as BSB
import Data.ByteString.Lazy qualified as LBS
import Data.Kind (Type)
import Data.Text (Text)
import Data.Text qualified as T
import Data.Text.Encoding.Error qualified as TEE
@ -44,7 +43,6 @@ import Prelude
-------------------------------------------------------------------------------
type TestMode :: Type
data TestMode = TMDev | TMQuick | TMRelease
deriving stock (Show)

View File

@ -1,4 +1,3 @@
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE UndecidableInstances #-}
-- | Postgres Types Insert
@ -9,7 +8,6 @@ module Hasura.Backends.Postgres.Types.Insert
)
where
import Data.Kind (Type)
import Hasura.Prelude
import Hasura.RQL.IR.Conflict (OnConflictClause)
import Hasura.RQL.Types.Backend (Backend)
@ -20,7 +18,6 @@ import Hasura.SQL.Backend
-- This is parameterised over @v@ which enables different phases of IR
-- transformation to maintain the overall structure while enriching/transforming
-- the data at the leaves.
type BackendInsert :: PostgresKind -> Type -> Type
newtype BackendInsert pgKind v = BackendInsert
{ _biConflictClause :: Maybe (OnConflictClause ('Postgres pgKind) v)
}

View File

@ -1,4 +1,3 @@
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE UndecidableInstances #-}
-- | Postgres Types Update
@ -13,17 +12,15 @@ module Hasura.Backends.Postgres.Types.Update
where
import Data.HashMap.Strict qualified as Map
import Data.Kind (Type)
import Data.Monoid (All (..))
import Data.Typeable (Typeable)
import Hasura.Backends.Postgres.SQL.Types (PGCol)
import Hasura.Prelude
import Hasura.RQL.IR.BoolExp (AnnBoolExp, AnnBoolExpFld)
import Hasura.RQL.Types.Backend (Backend)
import Hasura.SQL.Backend (BackendType (Postgres), PostgresKind)
import Hasura.SQL.Backend (BackendType (Postgres))
-- | Represents an entry in an /update_table_many/ update.
type MultiRowUpdate :: PostgresKind -> Type -> Type
data MultiRowUpdate pgKind v = MultiRowUpdate
{ -- | The /where/ clause for each individual update.
--
@ -69,7 +66,6 @@ deriving instance
-- This is parameterised over @v@ which enables different phases of IR
-- transformation to maintain the overall structure while enriching/transforming
-- the data at the leaves.
type BackendUpdate :: PostgresKind -> Type -> Type
data BackendUpdate pgKind v
= -- | The update operations to perform on each colum.
BackendUpdate (HashMap PGCol (UpdateOpExpression v))

View File

@ -1,6 +1,5 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE UndecidableInstances #-}
-- | The 'Transform' typeclass with various types and helper functions
@ -33,7 +32,7 @@ import Data.ByteString (ByteString)
import Data.ByteString.Builder.Extra (toLazyByteStringWith, untrimmedStrategy)
import Data.ByteString.Builder.Scientific (scientificBuilder)
import Data.ByteString.Lazy qualified as LBS
import Data.Kind (Constraint, Type)
import Data.Kind (Type)
import Data.Text.Encoding (encodeUtf8)
import Data.Validation (Validation)
import Hasura.Prelude
@ -42,7 +41,6 @@ import Hasura.Prelude
-- | 'Transform' describes how to reify a defunctionalized transformation for
-- a particular request field.
type Transform :: Type -> Constraint
class Transform a where
-- | The associated type 'TransformFn a' is the defunctionalized version
-- of some transformation that should be applied to a given request field.