forked from OSS/graphql
Try type parsers in a different order
This commit is contained in:
parent
73e21661b4
commit
625d7100ca
19
CHANGELOG.md
19
CHANGELOG.md
@ -10,11 +10,24 @@ All notable changes to this project will be documented in this file.
|
|||||||
module should be imported qualified.
|
module should be imported qualified.
|
||||||
- All `Language.GraphQL.AST.Core.Value` data constructor prefixes were removed.
|
- All `Language.GraphQL.AST.Core.Value` data constructor prefixes were removed.
|
||||||
The module should be imported qualified.
|
The module should be imported qualified.
|
||||||
- Make `Language.GraphQL.AST.Core.Object` is now just a HashMap.
|
- `Language.GraphQL.AST.Core.Object` is now just a HashMap.
|
||||||
- `Language.GraphQL.AST.Transform` is now isn't exposed publically anymore.
|
- `Language.GraphQL.AST.Transform` is isn't exposed publically anymore.
|
||||||
|
- `Language.GraphQL.Schema.resolve` accepts a selection `Seq` (`Data.Sequence`)
|
||||||
|
instead of a list. Selections are stored as sequences internally as well.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Nested fragment support.
|
- Nested fragment support.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Consume ignored tokens after `$` and `!`. I mistakenly assumed that
|
||||||
|
`$variable` is a single token, same as `Type!` is a single token. This is not
|
||||||
|
the case, for example `Variable` is defined as `$ Name`, so these are two
|
||||||
|
tokens, therefore whitespaces and commas after `$` and `!` should be
|
||||||
|
consumed.
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- `Language.GraphQL.AST.Parser.type_`: Try type parsers in a variable
|
||||||
|
definition in a different order to avoid using `but`.
|
||||||
|
|
||||||
## [0.5.1.0] - 2019-10-22
|
## [0.5.1.0] - 2019-10-22
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
@ -152,9 +152,9 @@ defaultValue = equals *> value
|
|||||||
-- * Input Types
|
-- * Input Types
|
||||||
|
|
||||||
type_ :: Parser Type
|
type_ :: Parser Type
|
||||||
type_ = try (TypeNamed <$> name <* but "!")
|
type_ = try (TypeNonNull <$> nonNullType)
|
||||||
<|> TypeList <$> brackets type_
|
<|> TypeList <$> brackets type_
|
||||||
<|> TypeNonNull <$> nonNullType
|
<|> TypeNamed <$> name
|
||||||
<?> "type_ error!"
|
<?> "type_ error!"
|
||||||
|
|
||||||
nonNullType :: Parser NonNullType
|
nonNullType :: Parser NonNullType
|
||||||
|
@ -13,12 +13,10 @@ import Control.Monad (foldM, unless)
|
|||||||
import Control.Monad.Trans.Class (lift)
|
import Control.Monad.Trans.Class (lift)
|
||||||
import Control.Monad.Trans.Reader (ReaderT, ask, runReaderT)
|
import Control.Monad.Trans.Reader (ReaderT, ask, runReaderT)
|
||||||
import Control.Monad.Trans.State (StateT, evalStateT, gets, modify)
|
import Control.Monad.Trans.State (StateT, evalStateT, gets, modify)
|
||||||
import Data.Foldable (toList)
|
|
||||||
import Data.HashMap.Strict (HashMap)
|
import Data.HashMap.Strict (HashMap)
|
||||||
import qualified Data.HashMap.Strict as HashMap
|
import qualified Data.HashMap.Strict as HashMap
|
||||||
import qualified Data.List.NonEmpty as NonEmpty
|
import qualified Data.List.NonEmpty as NonEmpty
|
||||||
import Data.Sequence (Seq, (<|), (><))
|
import Data.Sequence (Seq, (<|), (><))
|
||||||
import qualified Data.Sequence as Sequence
|
|
||||||
import qualified Language.GraphQL.AST as Full
|
import qualified Language.GraphQL.AST as Full
|
||||||
import qualified Language.GraphQL.AST.Core as Core
|
import qualified Language.GraphQL.AST.Core as Core
|
||||||
import qualified Language.GraphQL.Schema as Schema
|
import qualified Language.GraphQL.Schema as Schema
|
||||||
@ -99,10 +97,9 @@ collectFragments = do
|
|||||||
fragmentDefinition ::
|
fragmentDefinition ::
|
||||||
Full.FragmentDefinition ->
|
Full.FragmentDefinition ->
|
||||||
TransformT (Seq Core.Selection)
|
TransformT (Seq Core.Selection)
|
||||||
fragmentDefinition (Full.FragmentDefinition name _tc _dirs sels) = do
|
fragmentDefinition (Full.FragmentDefinition name _tc _dirs selections) = do
|
||||||
modify deleteFragmentDefinition
|
modify deleteFragmentDefinition
|
||||||
selections <- traverse selection sels
|
newValue <- appendSelection selections
|
||||||
let newValue = either id pure =<< Sequence.fromList (toList selections)
|
|
||||||
modify $ insertFragment newValue
|
modify $ insertFragment newValue
|
||||||
liftJust newValue
|
liftJust newValue
|
||||||
where
|
where
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
resolver: lts-14.14
|
resolver: lts-14.15
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- .
|
- .
|
||||||
|
Loading…
Reference in New Issue
Block a user