Skip to content

Simplify GenericInputObjectFieldDefinitions #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/hpc-ratchet
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Each item represents the number of "things" we are OK with not being covered.
COVERAGE_TOLERANCE = {
ALTERNATIVES: 161,
BOOLEANS: 8,
EXPRESSIONS: 1416,
LOCAL_DECLS: 14,
EXPRESSIONS: 1412,
LOCAL_DECLS: 13,
TOP_LEVEL_DECLS: 669,
}

Expand Down
18 changes: 8 additions & 10 deletions src/GraphQL/Internal/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module GraphQL.Internal.API
import Protolude hiding (Enum, TypeError)

import qualified Data.List.NonEmpty as NonEmpty
import Data.Semigroup as S ((<>))
import GHC.Generics ((:*:)(..))
import GHC.TypeLits (Symbol, KnownSymbol, TypeError, ErrorMessage(..))
import GHC.Types (Type)
Expand Down Expand Up @@ -374,17 +375,14 @@ instance forall dataName consName records s l p.
. Schema.InputObjectTypeDefinition name
) (genericGetInputObjectFieldDefinitions @records)

instance forall wrappedType fieldName rest u s l.
( KnownSymbol fieldName
, HasAnnotatedInputType wrappedType
, GenericInputObjectFieldDefinitions rest
) => GenericInputObjectFieldDefinitions (S1 ('MetaSel ('Just fieldName) u s l) (Rec0 wrappedType) :*: rest) where
instance forall a b.
( GenericInputObjectFieldDefinitions a
, GenericInputObjectFieldDefinitions b
) => GenericInputObjectFieldDefinitions (a :*: b) where
genericGetInputObjectFieldDefinitions = do
name <- nameFromSymbol @fieldName
annotatedInputType <- getAnnotatedInputType @wrappedType
let l = Schema.InputObjectFieldDefinition name annotatedInputType Nothing
r <- genericGetInputObjectFieldDefinitions @rest
pure (NonEmpty.cons l r)
l <- genericGetInputObjectFieldDefinitions @a
r <- genericGetInputObjectFieldDefinitions @b
pure (l S.<> r)

instance forall wrappedType fieldName u s l.
( KnownSymbol fieldName
Expand Down