Deprecate plural type aliases

Fixes #16. Deprecates:

- Language.GraphQL.AST.Arguments
- Language.GraphQL.AST.Directives
- Language.GraphQL.AST.VariableDefinitions
This commit is contained in:
Eugen Wissner 2019-10-01 06:59:30 +02:00
parent 0d142fb01c
commit b2a9ec7d82
4 changed files with 39 additions and 24 deletions

View File

@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## Unreleased ## Unreleased
### Deprecated
- `Language.GraphQL.AST.Arguments`. Use `[Language.GraphQL.AST.Argument]`
instead.
- `Language.GraphQL.AST.Directives`. Use `[Language.GraphQL.AST.Directives]`
instead.
- `Language.GraphQL.AST.VariableDefinitions`. Use
`[Language.GraphQL.AST.VariableDefinition]` instead.
### Added
- Module documentation.
## [0.5.0.1] - 2019-09-10 ## [0.5.0.1] - 2019-09-10
### Added ### Added

View File

@ -45,16 +45,18 @@ type Document = NonEmpty Definition
-- * Operations -- * Operations
-- | Top-level definition of a document, either an operation or a fragment. -- | Top-level definition of a document, either an operation or a fragment.
data Definition = DefinitionOperation OperationDefinition data Definition
= DefinitionOperation OperationDefinition
| DefinitionFragment FragmentDefinition | DefinitionFragment FragmentDefinition
deriving (Eq, Show) deriving (Eq, Show)
-- | Operation definition. -- | Operation definition.
data OperationDefinition = OperationSelectionSet SelectionSet data OperationDefinition
= OperationSelectionSet SelectionSet
| OperationDefinition OperationType | OperationDefinition OperationType
(Maybe Name) (Maybe Name)
VariableDefinitions [VariableDefinition]
Directives [Directive]
SelectionSet SelectionSet
deriving (Eq, Show) deriving (Eq, Show)
@ -82,12 +84,13 @@ data Selection
-- | GraphQL field. -- | GraphQL field.
data Field data Field
= Field (Maybe Alias) Name Arguments Directives SelectionSetOpt = Field (Maybe Alias) Name [Argument] [Directive] SelectionSetOpt
deriving (Eq, Show) deriving (Eq, Show)
-- * Arguments -- * Arguments
-- | Argument list. -- | Argument list.
{-# DEPRECATED Arguments "Use [Argument] instead" #-}
type Arguments = [Argument] type Arguments = [Argument]
-- | Argument. -- | Argument.
@ -96,15 +99,15 @@ data Argument = Argument Name Value deriving (Eq,Show)
-- * Fragments -- * Fragments
-- | Fragment spread. -- | Fragment spread.
data FragmentSpread = FragmentSpread Name Directives deriving (Eq, Show) data FragmentSpread = FragmentSpread Name [Directive] deriving (Eq, Show)
-- | Inline fragment. -- | Inline fragment.
data InlineFragment = InlineFragment (Maybe TypeCondition) Directives SelectionSet data InlineFragment = InlineFragment (Maybe TypeCondition) [Directive] SelectionSet
deriving (Eq, Show) deriving (Eq, Show)
-- | Fragment definition. -- | Fragment definition.
data FragmentDefinition data FragmentDefinition
= FragmentDefinition Name TypeCondition Directives SelectionSet = FragmentDefinition Name TypeCondition [Directive] SelectionSet
deriving (Eq, Show) deriving (Eq, Show)
{-# DEPRECATED FragmentName "Use Name instead" #-} {-# DEPRECATED FragmentName "Use Name instead" #-}
@ -135,6 +138,7 @@ data ObjectField = ObjectField Name Value deriving (Eq, Show)
-- * Variables -- * Variables
-- | Variable definition list. -- | Variable definition list.
{-# DEPRECATED VariableDefinitions "Use [VariableDefinition] instead" #-}
type VariableDefinitions = [VariableDefinition] type VariableDefinitions = [VariableDefinition]
-- | Variable definition. -- | Variable definition.
@ -158,6 +162,7 @@ data NonNullType = NonNullTypeNamed Name
-- * Directives -- * Directives
-- | Directive list. -- | Directive list.
{-# DEPRECATED Directives "Use [Directive] instead" #-}
type Directives = [Directive] type Directives = [Directive]
-- | Directive. -- | Directive.

View File

@ -68,8 +68,8 @@ operationDefinition formatter (OperationDefinition Mutation name vars dirs sels)
node :: Formatter node :: Formatter
-> Maybe Name -> Maybe Name
-> VariableDefinitions -> [VariableDefinition]
-> Directives -> [Directive]
-> SelectionSet -> SelectionSet
-> Text -> Text
node formatter name vars dirs sels node formatter name vars dirs sels
@ -170,7 +170,7 @@ directive :: Formatter -> Directive -> Text
directive formatter (Directive name args) directive formatter (Directive name args)
= "@" <> Text.Lazy.fromStrict name <> optempty (arguments formatter) args = "@" <> Text.Lazy.fromStrict name <> optempty (arguments formatter) args
directives :: Formatter -> Directives -> Text directives :: Formatter -> [Directive] -> Text
directives formatter@(Pretty _) = Text.Lazy.cons ' ' . spaces (directive formatter) directives formatter@(Pretty _) = Text.Lazy.cons ' ' . spaces (directive formatter)
directives Minified = spaces (directive Minified) directives Minified = spaces (directive Minified)

View File

@ -69,7 +69,7 @@ alias = try $ name <* colon
-- * Arguments -- * Arguments
arguments :: Parser Arguments arguments :: Parser [Argument]
arguments = parens $ some argument arguments = parens $ some argument
argument :: Parser Argument argument :: Parser Argument
@ -135,7 +135,7 @@ objectField = ObjectField <$> name <* symbol ":" <*> value
-- * Variables -- * Variables
variableDefinitions :: Parser VariableDefinitions variableDefinitions :: Parser [VariableDefinition]
variableDefinitions = parens $ some variableDefinition variableDefinitions = parens $ some variableDefinition
variableDefinition :: Parser VariableDefinition variableDefinition :: Parser VariableDefinition
@ -164,7 +164,7 @@ nonNullType = NonNullTypeNamed <$> name <* bang
-- * Directives -- * Directives
directives :: Parser Directives directives :: Parser [Directive]
directives = some directive directives = some directive
directive :: Parser Directive directive :: Parser Directive