mirror of
https://github.com/hasura/graphql-engine.git
synced 2025-01-07 08:13:18 +03:00
server: Move the schema parsers to their own library.
It's about time. To do this I had to check a few more boxes. * I copied the flags from `graphql-engine.cabal` to the libraries in `server/lib`. * I moved `Cacheable` instances of schema parser types beside the typeclass declaration. * I removed imports of `Hasura.Prelude` from the tests, and rewrote them accordingly. * I copied the `TestMonad` parse monad into `server/src-test/Hasura/GraphQL/Schema/RemoteTest.hs`, which was using it. I think this could be done with the real thing, but I tried replacing it with constraints and it messed with my head somewhat. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5311 GitOrigin-RevId: ebebcc50a16f2d517b7f730fe72410827ca3e86c
This commit is contained in:
parent
a61741fbf5
commit
aa18f65217
@ -28,3 +28,8 @@ cradle:
|
|||||||
- path: "server/lib/error-message/test"
|
- path: "server/lib/error-message/test"
|
||||||
component: "hasura-error-message:test:tests"
|
component: "hasura-error-message:test:tests"
|
||||||
|
|
||||||
|
- path: "server/lib/schema-parsers/src"
|
||||||
|
component: "hasura-schema-parsers:lib:hasura-schema-parsers"
|
||||||
|
- path: "server/lib/schema-parsers/test"
|
||||||
|
component: "hasura-schema-parsers:test:tests"
|
||||||
|
|
||||||
|
@ -56,6 +56,6 @@ build-multitenant-integration-tests: $(GENERATED_CABAL_FILES)
|
|||||||
# See the documentation for more information:
|
# See the documentation for more information:
|
||||||
# https://www.gnu.org/software/make/manual/html_node/Static-Pattern.html
|
# https://www.gnu.org/software/make/manual/html_node/Static-Pattern.html
|
||||||
# https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
|
# https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
|
||||||
$(GENERATED_CABAL_FILES): %.cabal: $$(dir %)/package.yaml
|
$(GENERATED_CABAL_FILES): %.cabal: $$(dir %)/package.yaml server/lib/common.yaml $$(shell find $$(dir %) -name '*.hs')
|
||||||
./scripts/hpack.sh $@
|
./scripts/hpack.sh $@
|
||||||
@ touch $@ # Required because `hpack` will not change the modified timestamp if the file is up-to-date.
|
@ touch $@ # Required because `hpack` will not change the modified timestamp if the file is up-to-date.
|
||||||
|
@ -159,6 +159,7 @@ common lib-depends
|
|||||||
, free
|
, free
|
||||||
, hashable
|
, hashable
|
||||||
, hasura-error-message
|
, hasura-error-message
|
||||||
|
, hasura-schema-parsers
|
||||||
, http-client-tls
|
, http-client-tls
|
||||||
, http-conduit
|
, http-conduit
|
||||||
, http-media
|
, http-media
|
||||||
@ -796,26 +797,6 @@ library
|
|||||||
, Hasura.GraphQL.Explain
|
, Hasura.GraphQL.Explain
|
||||||
, Hasura.GraphQL.Namespace
|
, Hasura.GraphQL.Namespace
|
||||||
, Hasura.GraphQL.ParameterizedQueryHash
|
, Hasura.GraphQL.ParameterizedQueryHash
|
||||||
, Hasura.GraphQL.Parser
|
|
||||||
, Hasura.GraphQL.Parser.Class
|
|
||||||
, Hasura.GraphQL.Parser.Collect
|
|
||||||
, Hasura.GraphQL.Parser.DirectiveName
|
|
||||||
, Hasura.GraphQL.Parser.Directives
|
|
||||||
, Hasura.GraphQL.Parser.ErrorCode
|
|
||||||
, Hasura.GraphQL.Parser.Internal.Convert
|
|
||||||
, Hasura.GraphQL.Parser.Internal.Input
|
|
||||||
, Hasura.GraphQL.Parser.Internal.Parser
|
|
||||||
, Hasura.GraphQL.Parser.Internal.Scalars
|
|
||||||
, Hasura.GraphQL.Parser.Internal.TypeChecking
|
|
||||||
, Hasura.GraphQL.Parser.Internal.Types
|
|
||||||
, Hasura.GraphQL.Parser.Monad
|
|
||||||
, Hasura.GraphQL.Parser.Name
|
|
||||||
, Hasura.GraphQL.Parser.Name.Introspection
|
|
||||||
, Hasura.GraphQL.Parser.Name.TypeSystem
|
|
||||||
, Hasura.GraphQL.Parser.Names
|
|
||||||
, Hasura.GraphQL.Parser.Schema
|
|
||||||
, Hasura.GraphQL.Parser.Schema.Convert
|
|
||||||
, Hasura.GraphQL.Parser.Variable
|
|
||||||
, Hasura.GraphQL.RemoteServer
|
, Hasura.GraphQL.RemoteServer
|
||||||
, Hasura.GraphQL.Schema
|
, Hasura.GraphQL.Schema
|
||||||
, Hasura.GraphQL.Schema.Action
|
, Hasura.GraphQL.Schema.Action
|
||||||
@ -864,7 +845,6 @@ library
|
|||||||
, Hasura.Eventing.ScheduledTrigger
|
, Hasura.Eventing.ScheduledTrigger
|
||||||
, Hasura.Eventing.ScheduledTrigger.Types
|
, Hasura.Eventing.ScheduledTrigger.Types
|
||||||
, Hasura.Name
|
, Hasura.Name
|
||||||
, Data.GADT.Compare.Extended
|
|
||||||
, Hasura.SQL.AnyBackend
|
, Hasura.SQL.AnyBackend
|
||||||
, Hasura.SQL.Backend
|
, Hasura.SQL.Backend
|
||||||
, Hasura.SQL.BackendMap
|
, Hasura.SQL.BackendMap
|
||||||
@ -1058,10 +1038,6 @@ test-suite graphql-engine-tests
|
|||||||
Hasura.EventingSpec
|
Hasura.EventingSpec
|
||||||
Hasura.Generator.Common
|
Hasura.Generator.Common
|
||||||
Hasura.GraphQL.NamespaceSpec
|
Hasura.GraphQL.NamespaceSpec
|
||||||
Hasura.GraphQL.Parser.DirectivesTest
|
|
||||||
Hasura.GraphQL.Parser.MonadParseTest
|
|
||||||
Hasura.GraphQL.Parser.TestInstances
|
|
||||||
Hasura.GraphQL.Parser.TestUtils
|
|
||||||
Hasura.GraphQL.Schema.Build.UpdateSpec
|
Hasura.GraphQL.Schema.Build.UpdateSpec
|
||||||
Hasura.GraphQL.Schema.RemoteTest
|
Hasura.GraphQL.Schema.RemoteTest
|
||||||
Hasura.IncrementalSpec
|
Hasura.IncrementalSpec
|
||||||
|
43
server/lib/common.yaml
Normal file
43
server/lib/common.yaml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
common-boilerplate: &common-boilerplate
|
||||||
|
version: 1.0.0
|
||||||
|
author:
|
||||||
|
- Hasura, Inc.
|
||||||
|
github: hasura/github-engine
|
||||||
|
extra-source-files:
|
||||||
|
- ../../../LICENSE
|
||||||
|
|
||||||
|
common-lib: &common-lib
|
||||||
|
flags:
|
||||||
|
optimize-hasura:
|
||||||
|
description: Compile hasura code with appropriate optimizations
|
||||||
|
default: true
|
||||||
|
manual: false
|
||||||
|
|
||||||
|
profiling:
|
||||||
|
description: Configures the project to be profiling-compatible
|
||||||
|
default: false
|
||||||
|
manual: true
|
||||||
|
|
||||||
|
ghc-options:
|
||||||
|
- "-foptimal-applicative-do"
|
||||||
|
- "-Wall"
|
||||||
|
- "-Werror"
|
||||||
|
- "-Wcompat"
|
||||||
|
- "-Wincomplete-record-updates"
|
||||||
|
- "-Wincomplete-uni-patterns"
|
||||||
|
- "-Wredundant-constraints"
|
||||||
|
- "-Wmissing-export-lists"
|
||||||
|
|
||||||
|
when:
|
||||||
|
- condition: flag(profiling)
|
||||||
|
cpp-options: -DPROFILING
|
||||||
|
|
||||||
|
- condition: flag(optimize-hasura)
|
||||||
|
then:
|
||||||
|
ghc-options:
|
||||||
|
- "-fexpose-all-unfoldings"
|
||||||
|
- "-O2"
|
||||||
|
else:
|
||||||
|
# we just want to build fast
|
||||||
|
ghc-options:
|
||||||
|
- "-O0"
|
@ -23,6 +23,16 @@ source-repository head
|
|||||||
type: git
|
type: git
|
||||||
location: https://github.com/hasura/github-engine
|
location: https://github.com/hasura/github-engine
|
||||||
|
|
||||||
|
flag optimize-hasura
|
||||||
|
description: Compile hasura code with appropriate optimizations
|
||||||
|
manual: False
|
||||||
|
default: True
|
||||||
|
|
||||||
|
flag profiling
|
||||||
|
description: Configures the project to be profiling-compatible
|
||||||
|
manual: True
|
||||||
|
default: False
|
||||||
|
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Hasura.Base.ErrorMessage
|
Hasura.Base.ErrorMessage
|
||||||
@ -39,13 +49,19 @@ library
|
|||||||
ImportQualifiedPost
|
ImportQualifiedPost
|
||||||
OverloadedStrings
|
OverloadedStrings
|
||||||
ScopedTypeVariables
|
ScopedTypeVariables
|
||||||
ghc-options: -Wall -Werror
|
ghc-options: -foptimal-applicative-do -Wall -Werror -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wmissing-export-lists
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson
|
aeson
|
||||||
, base
|
, base
|
||||||
, graphql-parser
|
, graphql-parser
|
||||||
, text
|
, text
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
|
if flag(profiling)
|
||||||
|
cpp-options: -DPROFILING
|
||||||
|
if flag(optimize-hasura)
|
||||||
|
ghc-options: -fexpose-all-unfoldings -O2
|
||||||
|
else
|
||||||
|
ghc-options: -O0
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
test-suite tests
|
test-suite tests
|
||||||
@ -63,7 +79,7 @@ test-suite tests
|
|||||||
ImportQualifiedPost
|
ImportQualifiedPost
|
||||||
OverloadedStrings
|
OverloadedStrings
|
||||||
ScopedTypeVariables
|
ScopedTypeVariables
|
||||||
ghc-options: -Wall -Werror -main-is Main
|
ghc-options: -foptimal-applicative-do -Wall -Werror -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wmissing-export-lists -main-is Main
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson
|
aeson
|
||||||
, base
|
, base
|
||||||
@ -74,4 +90,10 @@ test-suite tests
|
|||||||
, text
|
, text
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
, vector
|
, vector
|
||||||
|
if flag(profiling)
|
||||||
|
cpp-options: -DPROFILING
|
||||||
|
if flag(optimize-hasura)
|
||||||
|
ghc-options: -fexpose-all-unfoldings -O2
|
||||||
|
else
|
||||||
|
ghc-options: -O0
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
@ -3,17 +3,10 @@ spec-version: 0.34.7
|
|||||||
name: hasura-error-message
|
name: hasura-error-message
|
||||||
description: >
|
description: >
|
||||||
An error message type that makes it difficult to convert back to text.
|
An error message type that makes it difficult to convert back to text.
|
||||||
version: 1.0.0
|
|
||||||
author:
|
|
||||||
- Hasura, Inc.
|
|
||||||
github: hasura/github-engine
|
|
||||||
|
|
||||||
extra-source-files:
|
_common: !include "../common.yaml"
|
||||||
- ../../../LICENSE
|
<<: *common-boilerplate
|
||||||
|
<<: *common-lib
|
||||||
ghc-options:
|
|
||||||
- "-Wall"
|
|
||||||
- "-Werror"
|
|
||||||
|
|
||||||
default-extensions:
|
default-extensions:
|
||||||
- BlockArguments
|
- BlockArguments
|
||||||
|
@ -1 +1,2 @@
|
|||||||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
||||||
|
{-# OPTIONS_GHC -Wno-missing-export-lists #-}
|
||||||
|
202
server/lib/schema-parsers/hasura-schema-parsers.cabal
Normal file
202
server/lib/schema-parsers/hasura-schema-parsers.cabal
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
cabal-version: 1.12
|
||||||
|
|
||||||
|
-- This file is generated using hpack.
|
||||||
|
-- Do not modify it directly. Instead, edit package.yaml and then run:
|
||||||
|
-- make server/lib/schema-parsers/hasura-schema-parsers.cabal
|
||||||
|
|
||||||
|
-- This file has been generated from package.yaml by hpack version 0.34.7.
|
||||||
|
--
|
||||||
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
|
name: hasura-schema-parsers
|
||||||
|
version: 1.0.0
|
||||||
|
description: Parsers built from GraphQL schemas.
|
||||||
|
homepage: https://github.com/hasura/github-engine#readme
|
||||||
|
bug-reports: https://github.com/hasura/github-engine/issues
|
||||||
|
author: Hasura, Inc.
|
||||||
|
maintainer: Hasura, Inc.
|
||||||
|
build-type: Simple
|
||||||
|
extra-source-files:
|
||||||
|
../../../LICENSE
|
||||||
|
|
||||||
|
source-repository head
|
||||||
|
type: git
|
||||||
|
location: https://github.com/hasura/github-engine
|
||||||
|
|
||||||
|
flag optimize-hasura
|
||||||
|
description: Compile hasura code with appropriate optimizations
|
||||||
|
manual: False
|
||||||
|
default: True
|
||||||
|
|
||||||
|
flag profiling
|
||||||
|
description: Configures the project to be profiling-compatible
|
||||||
|
manual: True
|
||||||
|
default: False
|
||||||
|
|
||||||
|
library
|
||||||
|
exposed-modules:
|
||||||
|
Data.GADT.Compare.Extended
|
||||||
|
Hasura.GraphQL.Parser
|
||||||
|
Hasura.GraphQL.Parser.Class
|
||||||
|
Hasura.GraphQL.Parser.Collect
|
||||||
|
Hasura.GraphQL.Parser.DirectiveName
|
||||||
|
Hasura.GraphQL.Parser.Directives
|
||||||
|
Hasura.GraphQL.Parser.ErrorCode
|
||||||
|
Hasura.GraphQL.Parser.Internal.Convert
|
||||||
|
Hasura.GraphQL.Parser.Internal.Input
|
||||||
|
Hasura.GraphQL.Parser.Internal.Parser
|
||||||
|
Hasura.GraphQL.Parser.Internal.Scalars
|
||||||
|
Hasura.GraphQL.Parser.Internal.TypeChecking
|
||||||
|
Hasura.GraphQL.Parser.Internal.Types
|
||||||
|
Hasura.GraphQL.Parser.Monad
|
||||||
|
Hasura.GraphQL.Parser.Name
|
||||||
|
Hasura.GraphQL.Parser.Name.Introspection
|
||||||
|
Hasura.GraphQL.Parser.Name.TypeSystem
|
||||||
|
Hasura.GraphQL.Parser.Names
|
||||||
|
Hasura.GraphQL.Parser.Schema
|
||||||
|
Hasura.GraphQL.Parser.Schema.Convert
|
||||||
|
Hasura.GraphQL.Parser.Variable
|
||||||
|
other-modules:
|
||||||
|
Paths_hasura_schema_parsers
|
||||||
|
hs-source-dirs:
|
||||||
|
src
|
||||||
|
default-extensions:
|
||||||
|
AllowAmbiguousTypes
|
||||||
|
ApplicativeDo
|
||||||
|
BangPatterns
|
||||||
|
BlockArguments
|
||||||
|
DataKinds
|
||||||
|
DeriveFoldable
|
||||||
|
DeriveFunctor
|
||||||
|
DeriveLift
|
||||||
|
DeriveGeneric
|
||||||
|
DeriveTraversable
|
||||||
|
DerivingStrategies
|
||||||
|
ExplicitNamespaces
|
||||||
|
FlexibleContexts
|
||||||
|
FlexibleInstances
|
||||||
|
FunctionalDependencies
|
||||||
|
GADTs
|
||||||
|
GeneralizedNewtypeDeriving
|
||||||
|
ImportQualifiedPost
|
||||||
|
KindSignatures
|
||||||
|
LambdaCase
|
||||||
|
MultiWayIf
|
||||||
|
MultiParamTypeClasses
|
||||||
|
NamedFieldPuns
|
||||||
|
OverloadedStrings
|
||||||
|
RankNTypes
|
||||||
|
RecordWildCards
|
||||||
|
ScopedTypeVariables
|
||||||
|
StandaloneDeriving
|
||||||
|
StrictData
|
||||||
|
TupleSections
|
||||||
|
TypeApplications
|
||||||
|
TypeFamilies
|
||||||
|
TypeOperators
|
||||||
|
ghc-options: -foptimal-applicative-do -Wall -Werror -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wmissing-export-lists
|
||||||
|
build-depends:
|
||||||
|
aeson
|
||||||
|
, base
|
||||||
|
, dependent-map
|
||||||
|
, dependent-sum
|
||||||
|
, graphql-parser
|
||||||
|
, hashable
|
||||||
|
, hasura-error-message
|
||||||
|
, insert-ordered-containers
|
||||||
|
, lens
|
||||||
|
, mtl
|
||||||
|
, scientific
|
||||||
|
, some
|
||||||
|
, template-haskell
|
||||||
|
, text
|
||||||
|
, th-lift
|
||||||
|
, unordered-containers
|
||||||
|
, uuid
|
||||||
|
, vector
|
||||||
|
, witherable
|
||||||
|
if flag(profiling)
|
||||||
|
cpp-options: -DPROFILING
|
||||||
|
if flag(optimize-hasura)
|
||||||
|
ghc-options: -fexpose-all-unfoldings -O2
|
||||||
|
else
|
||||||
|
ghc-options: -O0
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
test-suite tests
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Hasura.GraphQL.Parser.DirectivesTest
|
||||||
|
Hasura.GraphQL.Parser.MonadParseTest
|
||||||
|
Hasura.GraphQL.Parser.TestInstances
|
||||||
|
Hasura.GraphQL.Parser.TestUtils
|
||||||
|
Paths_hasura_schema_parsers
|
||||||
|
hs-source-dirs:
|
||||||
|
test
|
||||||
|
default-extensions:
|
||||||
|
AllowAmbiguousTypes
|
||||||
|
ApplicativeDo
|
||||||
|
BangPatterns
|
||||||
|
BlockArguments
|
||||||
|
DataKinds
|
||||||
|
DeriveFoldable
|
||||||
|
DeriveFunctor
|
||||||
|
DeriveLift
|
||||||
|
DeriveGeneric
|
||||||
|
DeriveTraversable
|
||||||
|
DerivingStrategies
|
||||||
|
ExplicitNamespaces
|
||||||
|
FlexibleContexts
|
||||||
|
FlexibleInstances
|
||||||
|
FunctionalDependencies
|
||||||
|
GADTs
|
||||||
|
GeneralizedNewtypeDeriving
|
||||||
|
ImportQualifiedPost
|
||||||
|
KindSignatures
|
||||||
|
LambdaCase
|
||||||
|
MultiWayIf
|
||||||
|
MultiParamTypeClasses
|
||||||
|
NamedFieldPuns
|
||||||
|
OverloadedStrings
|
||||||
|
RankNTypes
|
||||||
|
RecordWildCards
|
||||||
|
ScopedTypeVariables
|
||||||
|
StandaloneDeriving
|
||||||
|
StrictData
|
||||||
|
TupleSections
|
||||||
|
TypeApplications
|
||||||
|
TypeFamilies
|
||||||
|
TypeOperators
|
||||||
|
ghc-options: -foptimal-applicative-do -Wall -Werror -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wmissing-export-lists -main-is Main
|
||||||
|
build-depends:
|
||||||
|
hasura-schema-parsers
|
||||||
|
, hspec
|
||||||
|
if flag(profiling)
|
||||||
|
cpp-options: -DPROFILING
|
||||||
|
if flag(optimize-hasura)
|
||||||
|
ghc-options: -fexpose-all-unfoldings -O2
|
||||||
|
else
|
||||||
|
ghc-options: -O0
|
||||||
|
if true
|
||||||
|
build-depends:
|
||||||
|
aeson
|
||||||
|
, base
|
||||||
|
, dependent-map
|
||||||
|
, dependent-sum
|
||||||
|
, graphql-parser
|
||||||
|
, hashable
|
||||||
|
, hasura-error-message
|
||||||
|
, insert-ordered-containers
|
||||||
|
, lens
|
||||||
|
, mtl
|
||||||
|
, scientific
|
||||||
|
, some
|
||||||
|
, template-haskell
|
||||||
|
, text
|
||||||
|
, th-lift
|
||||||
|
, unordered-containers
|
||||||
|
, uuid
|
||||||
|
, vector
|
||||||
|
, witherable
|
||||||
|
default-language: Haskell2010
|
83
server/lib/schema-parsers/package.yaml
Normal file
83
server/lib/schema-parsers/package.yaml
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
spec-version: 0.34.7
|
||||||
|
|
||||||
|
name: hasura-schema-parsers
|
||||||
|
description: >
|
||||||
|
Parsers built from GraphQL schemas.
|
||||||
|
|
||||||
|
_common: !include "../common.yaml"
|
||||||
|
<<: *common-boilerplate
|
||||||
|
<<: *common-lib
|
||||||
|
|
||||||
|
default-extensions:
|
||||||
|
- AllowAmbiguousTypes
|
||||||
|
- ApplicativeDo
|
||||||
|
- BangPatterns
|
||||||
|
- BlockArguments
|
||||||
|
- DataKinds
|
||||||
|
- DeriveFoldable
|
||||||
|
- DeriveFunctor
|
||||||
|
- DeriveLift
|
||||||
|
- DeriveGeneric
|
||||||
|
- DeriveTraversable
|
||||||
|
- DerivingStrategies
|
||||||
|
- ExplicitNamespaces
|
||||||
|
- FlexibleContexts
|
||||||
|
- FlexibleInstances
|
||||||
|
- FunctionalDependencies
|
||||||
|
- GADTs
|
||||||
|
- GeneralizedNewtypeDeriving
|
||||||
|
- ImportQualifiedPost
|
||||||
|
- KindSignatures
|
||||||
|
- LambdaCase
|
||||||
|
- MultiWayIf
|
||||||
|
- MultiParamTypeClasses
|
||||||
|
- NamedFieldPuns
|
||||||
|
- OverloadedStrings
|
||||||
|
- RankNTypes
|
||||||
|
- RecordWildCards
|
||||||
|
- ScopedTypeVariables
|
||||||
|
- StandaloneDeriving
|
||||||
|
- StrictData
|
||||||
|
- TupleSections
|
||||||
|
- TypeApplications
|
||||||
|
- TypeFamilies
|
||||||
|
- TypeOperators
|
||||||
|
|
||||||
|
library:
|
||||||
|
source-dirs:
|
||||||
|
- src
|
||||||
|
dependencies: &library-dependencies
|
||||||
|
- base
|
||||||
|
|
||||||
|
- aeson
|
||||||
|
- dependent-map
|
||||||
|
- dependent-sum
|
||||||
|
- graphql-parser
|
||||||
|
- hashable
|
||||||
|
- hasura-error-message
|
||||||
|
- insert-ordered-containers
|
||||||
|
- lens
|
||||||
|
- mtl
|
||||||
|
- scientific
|
||||||
|
- some
|
||||||
|
- template-haskell
|
||||||
|
- text
|
||||||
|
- th-lift
|
||||||
|
- unordered-containers
|
||||||
|
- uuid
|
||||||
|
- vector
|
||||||
|
- witherable
|
||||||
|
|
||||||
|
tests:
|
||||||
|
tests:
|
||||||
|
source-dirs:
|
||||||
|
- test
|
||||||
|
main: Main
|
||||||
|
dependencies:
|
||||||
|
- hasura-schema-parsers
|
||||||
|
- hspec
|
||||||
|
|
||||||
|
when:
|
||||||
|
# Merges the library dependencies with the above list, using `when:` to cheat.
|
||||||
|
- condition: true
|
||||||
|
dependencies: *library-dependencies
|
@ -7,8 +7,7 @@ module Data.GADT.Compare.Extended
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import "some" Data.GADT.Compare
|
import Data.GADT.Compare
|
||||||
import Prelude
|
|
||||||
|
|
||||||
strengthenOrdering :: Ordering -> GOrdering a a
|
strengthenOrdering :: Ordering -> GOrdering a a
|
||||||
strengthenOrdering LT = GLT
|
strengthenOrdering LT = GLT
|
@ -20,7 +20,6 @@ import Hasura.GraphQL.Parser.Class
|
|||||||
import Hasura.GraphQL.Parser.Directives
|
import Hasura.GraphQL.Parser.Directives
|
||||||
import Hasura.GraphQL.Parser.Variable
|
import Hasura.GraphQL.Parser.Variable
|
||||||
import Language.GraphQL.Draft.Syntax
|
import Language.GraphQL.Draft.Syntax
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- | Collects the effective set of fields queried by a selection set by
|
-- | Collects the effective set of fields queried by a selection set by
|
||||||
-- flattening fragments and merging duplicate fields.
|
-- flattening fragments and merging duplicate fields.
|
@ -48,7 +48,6 @@ import Hasura.GraphQL.Parser.Variable
|
|||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
import Type.Reflection (Typeable, typeRep, (:~:) (..))
|
import Type.Reflection (Typeable, typeRep, (:~:) (..))
|
||||||
import Witherable (catMaybes)
|
import Witherable (catMaybes)
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
||||||
{-# ANN module ("HLint: ignore Use onNothing" :: String) #-}
|
{-# ANN module ("HLint: ignore Use onNothing" :: String) #-}
|
@ -1,7 +1,5 @@
|
|||||||
module Hasura.GraphQL.Parser.ErrorCode (ParseErrorCode (..)) where
|
module Hasura.GraphQL.Parser.ErrorCode (ParseErrorCode (..)) where
|
||||||
|
|
||||||
import Prelude
|
|
||||||
|
|
||||||
data ParseErrorCode
|
data ParseErrorCode
|
||||||
= ValidationFailed
|
= ValidationFailed
|
||||||
| ParseFailed
|
| ParseFailed
|
@ -23,7 +23,6 @@ import Hasura.GraphQL.Parser.Class
|
|||||||
import Hasura.GraphQL.Parser.Internal.TypeChecking
|
import Hasura.GraphQL.Parser.Internal.TypeChecking
|
||||||
import Hasura.GraphQL.Parser.Variable
|
import Hasura.GraphQL.Parser.Variable
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
||||||
{-# ANN module ("HLint: ignore Use onNothing" :: String) #-}
|
{-# ANN module ("HLint: ignore Use onNothing" :: String) #-}
|
@ -40,7 +40,6 @@ import Hasura.GraphQL.Parser.Internal.Types
|
|||||||
import Hasura.GraphQL.Parser.Schema
|
import Hasura.GraphQL.Parser.Schema
|
||||||
import Hasura.GraphQL.Parser.Variable
|
import Hasura.GraphQL.Parser.Variable
|
||||||
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
||||||
{-# ANN module ("HLint: ignore Use onNothing" :: String) #-}
|
{-# ANN module ("HLint: ignore Use onNothing" :: String) #-}
|
@ -45,7 +45,6 @@ import Hasura.GraphQL.Parser.Variable
|
|||||||
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
import Witherable (catMaybes, mapMaybe)
|
import Witherable (catMaybes, mapMaybe)
|
||||||
import Prelude
|
|
||||||
|
|
||||||
infixl 1 `bind`
|
infixl 1 `bind`
|
||||||
|
|
@ -42,7 +42,6 @@ import Hasura.GraphQL.Parser.Name qualified as GName
|
|||||||
import Hasura.GraphQL.Parser.Schema
|
import Hasura.GraphQL.Parser.Schema
|
||||||
import Hasura.GraphQL.Parser.Variable
|
import Hasura.GraphQL.Parser.Variable
|
||||||
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
||||||
{-# ANN module ("HLint: ignore Use onLeft" :: String) #-}
|
{-# ANN module ("HLint: ignore Use onLeft" :: String) #-}
|
@ -20,7 +20,6 @@ import Hasura.GraphQL.Parser.Class
|
|||||||
import Hasura.GraphQL.Parser.Names
|
import Hasura.GraphQL.Parser.Names
|
||||||
import Hasura.GraphQL.Parser.Variable
|
import Hasura.GraphQL.Parser.Variable
|
||||||
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- | Peeling a variable.
|
-- | Peeling a variable.
|
||||||
--
|
--
|
@ -11,7 +11,6 @@ import Hasura.GraphQL.Parser.Names
|
|||||||
import Hasura.GraphQL.Parser.Schema
|
import Hasura.GraphQL.Parser.Schema
|
||||||
import Hasura.GraphQL.Parser.Variable
|
import Hasura.GraphQL.Parser.Variable
|
||||||
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
import Language.GraphQL.Draft.Syntax hiding (Definition)
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
-- -----------------------------------------------------------------------------
|
||||||
-- type definitions
|
-- type definitions
|
@ -14,16 +14,13 @@ import Hasura.GraphQL.Parser.Class
|
|||||||
import Hasura.GraphQL.Parser.ErrorCode
|
import Hasura.GraphQL.Parser.ErrorCode
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
-- Disable custom prelude warnings in preparation for extracting this module into a separate package.
|
|
||||||
{-# ANN module ("HLint: ignore Use onLeft" :: String) #-}
|
|
||||||
|
|
||||||
-- -------------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------------
|
||||||
-- query parsing
|
-- query parsing
|
||||||
|
|
||||||
newtype Parse a = Parse
|
newtype Parse a = Parse
|
||||||
{ unParse :: Except ParseError a
|
{ unParse :: Except ParseError a
|
||||||
}
|
}
|
||||||
deriving (Functor, Applicative, Monad)
|
deriving newtype (Functor, Applicative, Monad)
|
||||||
|
|
||||||
runParse ::
|
runParse ::
|
||||||
MonadError ParseError m =>
|
MonadError ParseError m =>
|
@ -1,7 +1,6 @@
|
|||||||
module Hasura.GraphQL.Parser.Names (HasName (..)) where
|
module Hasura.GraphQL.Parser.Names (HasName (..)) where
|
||||||
|
|
||||||
import Language.GraphQL.Draft.Syntax (Name)
|
import Language.GraphQL.Draft.Syntax (Name)
|
||||||
import Prelude
|
|
||||||
|
|
||||||
class HasName a where
|
class HasName a where
|
||||||
getName :: a -> Name
|
getName :: a -> Name
|
@ -72,7 +72,6 @@ import Language.GraphQL.Draft.Syntax
|
|||||||
Value (..),
|
Value (..),
|
||||||
)
|
)
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-- | GraphQL types are divided into two classes: input types and output types.
|
-- | GraphQL types are divided into two classes: input types and output types.
|
||||||
-- The GraphQL spec does not use the word “kind” to describe these classes, but
|
-- The GraphQL spec does not use the word “kind” to describe these classes, but
|
@ -8,7 +8,6 @@ where
|
|||||||
import Data.List.NonEmpty qualified as NonEmpty
|
import Data.List.NonEmpty qualified as NonEmpty
|
||||||
import Hasura.GraphQL.Parser.Schema
|
import Hasura.GraphQL.Parser.Schema
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
import Prelude
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
@ -10,14 +10,12 @@ import Data.Hashable (Hashable)
|
|||||||
import Data.Void (Void)
|
import Data.Void (Void)
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
import Hasura.GraphQL.Parser.Names
|
import Hasura.GraphQL.Parser.Names
|
||||||
import Hasura.Incremental (Cacheable)
|
|
||||||
import Language.GraphQL.Draft.Syntax
|
import Language.GraphQL.Draft.Syntax
|
||||||
( GType (..),
|
( GType (..),
|
||||||
Name (..),
|
Name (..),
|
||||||
Value (..),
|
Value (..),
|
||||||
)
|
)
|
||||||
import Language.Haskell.TH.Lift qualified as TH
|
import Language.Haskell.TH.Lift qualified as TH
|
||||||
import Prelude
|
|
||||||
|
|
||||||
{- Note [Parsing variable values]
|
{- Note [Parsing variable values]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -81,8 +79,6 @@ data InputValue v
|
|||||||
|
|
||||||
instance (Hashable v) => Hashable (InputValue v)
|
instance (Hashable v) => Hashable (InputValue v)
|
||||||
|
|
||||||
instance (Cacheable v) => Cacheable (InputValue v)
|
|
||||||
|
|
||||||
data Variable = Variable
|
data Variable = Variable
|
||||||
{ vInfo :: VariableInfo,
|
{ vInfo :: VariableInfo,
|
||||||
vType :: GType,
|
vType :: GType,
|
||||||
@ -94,8 +90,6 @@ data Variable = Variable
|
|||||||
|
|
||||||
instance Hashable Variable
|
instance Hashable Variable
|
||||||
|
|
||||||
instance Cacheable Variable
|
|
||||||
|
|
||||||
instance HasName Variable where
|
instance HasName Variable where
|
||||||
getName = getName . vInfo
|
getName = getName . vInfo
|
||||||
|
|
||||||
@ -109,8 +103,6 @@ data VariableInfo
|
|||||||
|
|
||||||
instance Hashable VariableInfo
|
instance Hashable VariableInfo
|
||||||
|
|
||||||
instance Cacheable VariableInfo
|
|
||||||
|
|
||||||
instance HasName VariableInfo where
|
instance HasName VariableInfo where
|
||||||
getName (VIRequired name) = name
|
getName (VIRequired name) = name
|
||||||
getName (VIOptional name _) = name
|
getName (VIOptional name _) = name
|
@ -1,11 +1,13 @@
|
|||||||
module Hasura.GraphQL.Parser.DirectivesTest (spec) where
|
module Hasura.GraphQL.Parser.DirectivesTest (spec) where
|
||||||
|
|
||||||
|
import Control.Monad.Identity (Identity (..))
|
||||||
import Data.Dependent.Map qualified as DM
|
import Data.Dependent.Map qualified as DM
|
||||||
|
import Data.Maybe (isJust)
|
||||||
import Data.Text qualified as T
|
import Data.Text qualified as T
|
||||||
import Hasura.GraphQL.Parser.Directives hiding (Directive)
|
import Hasura.GraphQL.Parser.Directives
|
||||||
|
import Hasura.GraphQL.Parser.Schema
|
||||||
|
import Hasura.GraphQL.Parser.TestInstances ()
|
||||||
import Hasura.GraphQL.Parser.TestUtils
|
import Hasura.GraphQL.Parser.TestUtils
|
||||||
import Hasura.GraphQL.Schema.Parser
|
|
||||||
import Hasura.Prelude
|
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ spec = do
|
|||||||
testDirective cachedDirective cached
|
testDirective cachedDirective cached
|
||||||
testDirective multipleRootFieldsDirective multipleRootFields
|
testDirective multipleRootFieldsDirective multipleRootFields
|
||||||
|
|
||||||
testDirective :: Directive TestMonad -> DirectiveKey a -> Spec
|
testDirective :: Directive origin TestMonad -> DirectiveKey a -> Spec
|
||||||
testDirective dir key = do
|
testDirective dir key = do
|
||||||
let name = diName $ dDefinition dir
|
let name = diName $ dDefinition dir
|
||||||
location = head $ diLocations $ dDefinition dir
|
location = head $ diLocations $ dDefinition dir
|
@ -6,7 +6,6 @@ import Hasura.GraphQL.Parser.Class
|
|||||||
import Hasura.GraphQL.Parser.ErrorCode
|
import Hasura.GraphQL.Parser.ErrorCode
|
||||||
import Hasura.GraphQL.Parser.Monad
|
import Hasura.GraphQL.Parser.Monad
|
||||||
import Hasura.GraphQL.Parser.TestInstances ()
|
import Hasura.GraphQL.Parser.TestInstances ()
|
||||||
import Hasura.Prelude
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
|
|
||||||
runParse' :: Parse () -> Either ParseError ()
|
runParse' :: Parse () -> Either ParseError ()
|
@ -0,0 +1,16 @@
|
|||||||
|
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||||
|
|
||||||
|
module Hasura.GraphQL.Parser.TestInstances () where
|
||||||
|
|
||||||
|
import Data.Text qualified as Text
|
||||||
|
import Hasura.Base.ErrorMessage (ErrorMessage, fromErrorMessage)
|
||||||
|
import Hasura.GraphQL.Parser.Monad (ParseError (..))
|
||||||
|
|
||||||
|
-- Orphan instances so that we can write assertions over 'Either ErrorMessage a'.
|
||||||
|
instance Show ErrorMessage where
|
||||||
|
show = Text.unpack . fromErrorMessage
|
||||||
|
|
||||||
|
-- Orphan instances so that we can write assertions over 'Either ParseError a'.
|
||||||
|
deriving stock instance Eq ParseError
|
||||||
|
|
||||||
|
deriving stock instance Show ParseError
|
@ -6,36 +6,36 @@ module Hasura.GraphQL.Parser.TestUtils
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
import Data.Functor ((<&>))
|
||||||
import Data.HashMap.Strict qualified as M
|
import Data.HashMap.Strict qualified as M
|
||||||
import Data.List.NonEmpty qualified as NE
|
import Data.List.NonEmpty qualified as NE
|
||||||
import Data.Text qualified as T
|
import Hasura.Base.ErrorMessage (ErrorMessage)
|
||||||
import Hasura.Base.ErrorMessage (fromErrorMessage)
|
import Hasura.GraphQL.Parser
|
||||||
import Hasura.GraphQL.Schema.Parser
|
import Hasura.GraphQL.Parser.Name qualified as GName
|
||||||
import Hasura.Prelude
|
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
|
|
||||||
-- test monad
|
-- test monad
|
||||||
|
|
||||||
newtype TestMonad a = TestMonad {runTest :: Either Text a}
|
newtype TestMonad a = TestMonad {runTest :: Either ErrorMessage a}
|
||||||
deriving (Functor, Applicative, Monad)
|
deriving newtype (Functor, Applicative, Monad)
|
||||||
|
|
||||||
instance MonadParse TestMonad where
|
instance MonadParse TestMonad where
|
||||||
withKey = const id
|
withKey = const id
|
||||||
parseErrorWith = const $ TestMonad . Left . fromErrorMessage
|
parseErrorWith = const $ TestMonad . Left
|
||||||
|
|
||||||
-- values generation
|
-- values generation
|
||||||
|
|
||||||
fakeScalar :: G.Name -> G.Value Variable
|
fakeScalar :: G.Name -> G.Value Variable
|
||||||
fakeScalar =
|
fakeScalar name =
|
||||||
G.unName >>> \case
|
if
|
||||||
"Int" -> G.VInt 4242
|
| name == GName._Int -> G.VInt 4242
|
||||||
"Boolean" -> G.VBoolean False
|
| name == GName._Boolean -> G.VBoolean False
|
||||||
name -> error $ "no test value implemented for scalar " <> T.unpack name
|
| otherwise -> error $ "no test value implemented for scalar " <> show name
|
||||||
|
|
||||||
fakeInputFieldValue :: InputFieldInfo -> G.Value Variable
|
fakeInputFieldValue :: forall origin. InputFieldInfo origin -> G.Value Variable
|
||||||
fakeInputFieldValue (InputFieldInfo t _) = go t
|
fakeInputFieldValue (InputFieldInfo t _) = go t
|
||||||
where
|
where
|
||||||
go :: forall k. ('Input <: k) => Type k -> G.Value Variable
|
go :: forall k. ('Input <: k) => Type origin k -> G.Value Variable
|
||||||
go = \case
|
go = \case
|
||||||
TList _ t' -> G.VList [go t', go t']
|
TList _ t' -> G.VList [go t', go t']
|
||||||
TNamed _ (Definition name _ _ _ info) -> case (info, subKind @'Input @k) of
|
TNamed _ (Definition name _ _ _ info) -> case (info, subKind @'Input @k) of
|
||||||
@ -47,7 +47,7 @@ fakeInputFieldValue (InputFieldInfo t _) = go t
|
|||||||
pure (fieldName, fakeInputFieldValue fieldInfo)
|
pure (fieldName, fakeInputFieldValue fieldInfo)
|
||||||
_ -> error "fakeInputFieldValue: non-exhaustive. FIXME"
|
_ -> error "fakeInputFieldValue: non-exhaustive. FIXME"
|
||||||
|
|
||||||
fakeDirective :: DirectiveInfo -> G.Directive Variable
|
fakeDirective :: DirectiveInfo origin -> G.Directive Variable
|
||||||
fakeDirective DirectiveInfo {..} =
|
fakeDirective DirectiveInfo {..} =
|
||||||
G.Directive diName $
|
G.Directive diName $
|
||||||
M.fromList $
|
M.fromList $
|
2
server/lib/schema-parsers/test/Main.hs
Normal file
2
server/lib/schema-parsers/test/Main.hs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
||||||
|
{-# OPTIONS_GHC -Wno-missing-export-lists #-}
|
@ -45,6 +45,7 @@ import GHC.Generics
|
|||||||
(:*:) (..),
|
(:*:) (..),
|
||||||
(:+:) (..),
|
(:+:) (..),
|
||||||
)
|
)
|
||||||
|
import Hasura.GraphQL.Parser qualified as P
|
||||||
import Hasura.Incremental.Select
|
import Hasura.Incremental.Select
|
||||||
import Hasura.Prelude
|
import Hasura.Prelude
|
||||||
import Language.GraphQL.Draft.Syntax qualified as G
|
import Language.GraphQL.Draft.Syntax qualified as G
|
||||||
@ -403,6 +404,12 @@ instance Cacheable Scheme
|
|||||||
|
|
||||||
instance Cacheable BaseUrl
|
instance Cacheable BaseUrl
|
||||||
|
|
||||||
|
instance (Cacheable v) => Cacheable (P.InputValue v)
|
||||||
|
|
||||||
|
instance Cacheable P.Variable
|
||||||
|
|
||||||
|
instance Cacheable P.VariableInfo
|
||||||
|
|
||||||
class GCacheable f where
|
class GCacheable f where
|
||||||
gunchanged :: f p -> f p -> Accesses -> Bool
|
gunchanged :: f p -> f p -> Accesses -> Bool
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
|
||||||
|
|
||||||
module Hasura.GraphQL.Parser.TestInstances () where
|
|
||||||
|
|
||||||
import Hasura.Base.ErrorMessage (fromErrorMessage)
|
|
||||||
import Hasura.GraphQL.Parser.Monad (ParseError (..))
|
|
||||||
import Hasura.Prelude
|
|
||||||
|
|
||||||
-- Orphan instances so that we can write assertions over 'Either ParseError a'.
|
|
||||||
deriving stock instance Eq ParseError
|
|
||||||
|
|
||||||
-- This cannot be automatically derived because 'ErrorMessage' doesn't have a 'Show' instance.
|
|
||||||
instance Show ParseError where
|
|
||||||
show ParseError {pePath, peMessage, peCode} =
|
|
||||||
"ParseError { pePath = " <> show pePath <> ", peMessage = " <> show (fromErrorMessage peMessage) <> ", peCode = " <> show peCode <> "}"
|
|
@ -14,13 +14,13 @@ import Data.Text qualified as T
|
|||||||
import Data.Text.Extended
|
import Data.Text.Extended
|
||||||
import Data.Text.RawString
|
import Data.Text.RawString
|
||||||
import Hasura.Base.Error
|
import Hasura.Base.Error
|
||||||
|
import Hasura.Base.ErrorMessage (ErrorMessage, fromErrorMessage)
|
||||||
import Hasura.GraphQL.Execute.Inline
|
import Hasura.GraphQL.Execute.Inline
|
||||||
import Hasura.GraphQL.Execute.Remote (resolveRemoteVariable, runVariableCache)
|
import Hasura.GraphQL.Execute.Remote (resolveRemoteVariable, runVariableCache)
|
||||||
import Hasura.GraphQL.Execute.Resolve
|
import Hasura.GraphQL.Execute.Resolve
|
||||||
import Hasura.GraphQL.Namespace
|
import Hasura.GraphQL.Namespace
|
||||||
import Hasura.GraphQL.Parser.Name qualified as GName
|
import Hasura.GraphQL.Parser.Name qualified as GName
|
||||||
import Hasura.GraphQL.Parser.Names
|
import Hasura.GraphQL.Parser.Names
|
||||||
import Hasura.GraphQL.Parser.TestUtils
|
|
||||||
import Hasura.GraphQL.Parser.Variable
|
import Hasura.GraphQL.Parser.Variable
|
||||||
import Hasura.GraphQL.Schema.Common
|
import Hasura.GraphQL.Schema.Common
|
||||||
import Hasura.GraphQL.Schema.NamingCase
|
import Hasura.GraphQL.Schema.NamingCase
|
||||||
@ -44,6 +44,15 @@ import Language.GraphQL.Draft.Syntax.QQ qualified as G
|
|||||||
import Network.URI qualified as N
|
import Network.URI qualified as N
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
|
|
||||||
|
-- test monad
|
||||||
|
|
||||||
|
newtype TestMonad a = TestMonad {runTest :: Either ErrorMessage a}
|
||||||
|
deriving newtype (Functor, Applicative, Monad)
|
||||||
|
|
||||||
|
instance P.MonadParse TestMonad where
|
||||||
|
withKey = const id
|
||||||
|
parseErrorWith = const $ TestMonad . Left
|
||||||
|
|
||||||
-- test tools
|
-- test tools
|
||||||
|
|
||||||
runError :: Monad m => ExceptT QErr m a -> m a
|
runError :: Monad m => ExceptT QErr m a -> m a
|
||||||
@ -159,7 +168,7 @@ runQueryParser parser (varDefs, selSet) vars = runIdentity . runError $ do
|
|||||||
field <- case resolvedSelSet of
|
field <- case resolvedSelSet of
|
||||||
[G.SelectionField f] -> pure f
|
[G.SelectionField f] -> pure f
|
||||||
_ -> error "expecting only one field in the query"
|
_ -> error "expecting only one field in the query"
|
||||||
runTest (P.fParser parser field) `onLeft` throw500
|
runTest (P.fParser parser field) `onLeft` (throw500 . fromErrorMessage)
|
||||||
|
|
||||||
run ::
|
run ::
|
||||||
-- | schema
|
-- | schema
|
||||||
|
Loading…
Reference in New Issue
Block a user