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.
## 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
### Added

View File

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

View File

@ -67,11 +67,11 @@ operationDefinition formatter (OperationDefinition Mutation name vars dirs sels)
= "mutation " <> node formatter name vars dirs sels
node :: Formatter
-> Maybe Name
-> VariableDefinitions
-> Directives
-> SelectionSet
-> Text
-> Maybe Name
-> [VariableDefinition]
-> [Directive]
-> SelectionSet
-> Text
node formatter name vars dirs sels
= Text.Lazy.fromStrict (fold name)
<> optempty (variableDefinitions formatter) vars
@ -170,7 +170,7 @@ directive :: Formatter -> Directive -> Text
directive formatter (Directive name 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 Minified = spaces (directive Minified)

View File

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