forked from OSS/graphql
Parse interface type definition
This commit is contained in:
parent
f4ed06741d
commit
adffa185bb
@ -38,6 +38,7 @@ typeSystemDefinition = schemaDefinition
|
||||
typeDefinition :: Parser TypeDefinition
|
||||
typeDefinition = scalarTypeDefinition
|
||||
<|> objectTypeDefinition
|
||||
<|> interfaceTypeDefinition
|
||||
<|> unionTypeDefinition
|
||||
<?> "TypeDefinition"
|
||||
|
||||
@ -83,6 +84,15 @@ unionMemberTypes sepBy' = UnionMemberTypes
|
||||
<*> name `sepBy'` pipe
|
||||
<?> "UnionMemberTypes"
|
||||
|
||||
interfaceTypeDefinition :: Parser TypeDefinition
|
||||
interfaceTypeDefinition = InterfaceTypeDefinition
|
||||
<$> description
|
||||
<* symbol "interface"
|
||||
<*> name
|
||||
<*> opt directives
|
||||
<*> braces (many fieldDefinition)
|
||||
<?> "InterfaceTypeDefinition"
|
||||
|
||||
implementsInterfaces ::
|
||||
Foldable t =>
|
||||
(Parser Text -> Parser Text -> Parser (t NamedType)) ->
|
||||
|
@ -94,7 +94,7 @@ resolveFieldValue f resolveRight fld@(Field _ _ args _) = do
|
||||
_ <- addErrMsg err
|
||||
return $ HashMap.singleton (aliasOrName fld) Aeson.Null
|
||||
|
||||
-- | Helper function to facilitate 'Argument' handling.
|
||||
-- | Helper function to facilitate error handling and result emitting.
|
||||
withField :: (MonadIO m, Aeson.ToJSON a)
|
||||
=> CollectErrsT m a -> Field -> CollectErrsT m (HashMap Text Aeson.Value)
|
||||
withField v fld
|
||||
|
@ -74,3 +74,10 @@ spec = describe "Parser" $ do
|
||||
parse document "" `shouldSucceedOn` [r|
|
||||
union SearchResult = Photo | Person
|
||||
|]
|
||||
|
||||
it "parses minimal interface type definition" $
|
||||
parse document "" `shouldSucceedOn` [r|
|
||||
interface NamedEntity {
|
||||
name: String
|
||||
}
|
||||
|]
|
||||
|
Loading…
Reference in New Issue
Block a user