From 1c1393d8eda4b7170d819f7bfaf0e4ff6b2d7b2e Mon Sep 17 00:00:00 2001 From: theobat Date: Thu, 21 Jun 2018 14:01:06 +0200 Subject: [PATCH] test: first solve --- graphql-api.cabal | 5 ++--- src/GraphQL/Internal/Schema.hs | 4 ++++ tests/ValidationTests.hs | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/graphql-api.cabal b/graphql-api.cabal index 3628830..5450b8b 100644 --- a/graphql-api.cabal +++ b/graphql-api.cabal @@ -1,8 +1,8 @@ --- This file has been generated from package.yaml by hpack version 0.20.0. +-- This file has been generated from package.yaml by hpack version 0.28.2. -- -- see: https://github.com/sol/hpack -- --- hash: 6a38b887cec0d4a157469f5d73041fd16cb286d8f445f4e213c6f08965dbc563 +-- hash: 6db006b020fe198ac64b8a50f8335017251389b7c34dfc553675e38eb001a428 name: graphql-api version: 0.3.0 @@ -23,7 +23,6 @@ license: Apache license-file: LICENSE.Apache-2.0 build-type: Simple cabal-version: >= 1.10 - extra-source-files: CHANGELOG.rst diff --git a/src/GraphQL/Internal/Schema.hs b/src/GraphQL/Internal/Schema.hs index dacf06b..91e2b86 100644 --- a/src/GraphQL/Internal/Schema.hs +++ b/src/GraphQL/Internal/Schema.hs @@ -37,6 +37,7 @@ module GraphQL.Internal.Schema -- * The schema , Schema , makeSchema + , emptySchema , lookupType ) where @@ -59,6 +60,9 @@ newtype Schema = Schema (Map Name TypeDefinition) deriving (Eq, Ord, Show) makeSchema :: ObjectTypeDefinition -> Schema makeSchema = Schema . getDefinedTypes +emptySchema :: Schema +emptySchema = Schema (Map.empty :: (Map Name TypeDefinition)) + -- | Find the type with the given name in the schema. lookupType :: Schema -> Name -> Maybe TypeDefinition lookupType (Schema schema) name = Map.lookup name schema diff --git a/tests/ValidationTests.hs b/tests/ValidationTests.hs index 25ab059..9ee2e4c 100644 --- a/tests/ValidationTests.hs +++ b/tests/ValidationTests.hs @@ -1,4 +1,5 @@ {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE DataKinds #-} -- | Tests for query validation. module ValidationTests (tests) where @@ -11,8 +12,9 @@ import Test.Tasty (TestTree) import Test.Tasty.Hspec (testSpec, describe, it, shouldBe) import GraphQL.Internal.Name (Name) +import qualified Data.Map as Map import qualified GraphQL.Internal.Syntax.AST as AST -import GraphQL.Internal.Schema (Schema) +import GraphQL.Internal.Schema (Schema, emptySchema) import GraphQL.Internal.Validation ( ValidationError(..) , findDuplicates @@ -27,11 +29,11 @@ someName = "name" dog :: Name dog = "dog" - + -- | Schema used for these tests. Since none of them do type-level stuff, we -- don't need to define it. schema :: Schema -schema = panic "schema evaluated. We weren't expecting that." +schema = emptySchema tests :: IO TestTree tests = testSpec "Validation" $ do