forked from OSS/graphql
Parse interfaces implementing interfaces
This commit is contained in:
parent
6f7bb10a62
commit
97627ffc36
@ -482,12 +482,9 @@ instance Monoid Description
|
||||
data TypeDefinition
|
||||
= ScalarTypeDefinition Description Name [Directive]
|
||||
| ObjectTypeDefinition
|
||||
Description
|
||||
Name
|
||||
(ImplementsInterfaces [])
|
||||
[Directive]
|
||||
[FieldDefinition]
|
||||
| InterfaceTypeDefinition Description Name [Directive] [FieldDefinition]
|
||||
Description Name (ImplementsInterfaces []) [Directive] [FieldDefinition]
|
||||
| InterfaceTypeDefinition
|
||||
Description Name (ImplementsInterfaces []) [Directive] [FieldDefinition]
|
||||
| UnionTypeDefinition Description Name [Directive] (UnionMemberTypes [])
|
||||
| EnumTypeDefinition Description Name [Directive] [EnumValueDefinition]
|
||||
| InputObjectTypeDefinition
|
||||
|
@ -226,10 +226,11 @@ typeDefinition formatter = \case
|
||||
<> optempty (directives formatter) directives'
|
||||
<> eitherFormat formatter " " ""
|
||||
<> bracesList formatter (fieldDefinition nextFormatter) fields'
|
||||
Full.InterfaceTypeDefinition description' name' directives' fields'
|
||||
Full.InterfaceTypeDefinition description' name' ifaces' directives' fields'
|
||||
-> optempty (description formatter) description'
|
||||
<> "interface "
|
||||
<> Lazy.Text.fromStrict name'
|
||||
<> optempty (" " <>) (implementsInterfaces ifaces')
|
||||
<> optempty (directives formatter) directives'
|
||||
<> eitherFormat formatter " " ""
|
||||
<> bracesList formatter (fieldDefinition nextFormatter) fields'
|
||||
|
@ -214,6 +214,7 @@ interfaceTypeDefinition :: Full.Description -> Parser Full.TypeDefinition
|
||||
interfaceTypeDefinition description' = Full.InterfaceTypeDefinition description'
|
||||
<$ symbol "interface"
|
||||
<*> name
|
||||
<*> option (Full.ImplementsInterfaces []) (implementsInterfaces sepBy1)
|
||||
<*> directives
|
||||
<*> braces (many fieldDefinition)
|
||||
<?> "InterfaceTypeDefinition"
|
||||
|
@ -210,7 +210,7 @@ typeDefinition context rule = \case
|
||||
Full.ObjectTypeDefinition _ _ _ directives' fields
|
||||
-> directives context rule objectLocation directives'
|
||||
>< foldMap (fieldDefinition context rule) fields
|
||||
Full.InterfaceTypeDefinition _ _ directives' fields
|
||||
Full.InterfaceTypeDefinition _ _ _ directives' fields
|
||||
-> directives context rule interfaceLocation directives'
|
||||
>< foldMap (fieldDefinition context rule) fields
|
||||
Full.UnionTypeDefinition _ _ directives' _ ->
|
||||
|
@ -181,7 +181,7 @@ spec = do
|
||||
argument = Full.InputValueDefinition mempty "arg" someType Nothing mempty
|
||||
arguments = Full.ArgumentsDefinition [argument]
|
||||
definition' = Full.TypeDefinition
|
||||
$ Full.InterfaceTypeDefinition mempty "UUID" mempty
|
||||
$ Full.InterfaceTypeDefinition mempty "UUID" (Full.ImplementsInterfaces []) mempty
|
||||
$ pure
|
||||
$ Full.FieldDefinition mempty "value" arguments someType mempty
|
||||
expected = "interface UUID {\n\
|
||||
|
@ -103,6 +103,12 @@ spec = describe "Parser" $ do
|
||||
\ name: String\n\
|
||||
\}"
|
||||
|
||||
it "parses ImplementsInterfaces on interfaces" $
|
||||
parse document "" `shouldSucceedOn`
|
||||
"interface Person implements NamedEntity & ValuedEntity {\n\
|
||||
\ name: String\n\
|
||||
\}"
|
||||
|
||||
it "parses minimal enum type definition" $
|
||||
parse document "" `shouldSucceedOn`
|
||||
"enum Direction {\n\
|
||||
|
Loading…
Reference in New Issue
Block a user