Update error messages for enum and union support
This commit is contained in:
parent
aa28bdd7fe
commit
16bcdca066
@ -322,7 +322,7 @@ deriveFromGraphQL typeName = do
|
||||
NewtypeD _ _ _ _ cons' _
|
||||
| RecC dataConName varBangTypes <- cons' ->
|
||||
withRecordConstructor dataConName varBangTypes
|
||||
_ -> error "Only records with a single data constructor are supported"
|
||||
_ -> error "Only input objects and enums are supported if all member types have a FromGraphQL instance"
|
||||
where
|
||||
enumMemberPattern (NormalC normalName []) =
|
||||
let fromGraphQLF = conP (mkName "Type.Enum") [litP $ stringL $ nameBase normalName]
|
||||
@ -376,7 +376,7 @@ deriveToGraphQL typeName = do
|
||||
NewtypeD _ _ _ _ cons' _
|
||||
| RecC dataConName varBangTypes <- cons' ->
|
||||
withRecordConstructor dataConName varBangTypes
|
||||
_ -> error "Only records with a single data constructor are supported"
|
||||
_ -> error "Only objects, unions and enums are supported if all member types have a ToGraphQL instance"
|
||||
where
|
||||
conTName = conT typeName
|
||||
collectEnumMemberNames (NormalC normalName []) = Just normalName
|
||||
@ -397,7 +397,7 @@ deriveToGraphQL typeName = do
|
||||
enumMemberPattern <$> enumMemberNames
|
||||
| Just unionMembers <- traverse collectUnionMembers cons' =
|
||||
unionMemberPattern <$> unionMembers
|
||||
| otherwise = error "Enum member should be a normal constructor without parameters"
|
||||
| otherwise = error "All data constructors should have either no parameters (Enum) or one parameter (Union)"
|
||||
withRecordConstructor dataConName varBangTypes = do
|
||||
fieldAliases <- traverse newFieldAliases varBangTypes
|
||||
let fBody =
|
||||
|
Loading…
Reference in New Issue
Block a user