Skip to content

Commit

Permalink
Merge pull request #169 from wilhelmeek/intermediate-interfaces
Browse files Browse the repository at this point in the history
Support intermediate interfaces
  • Loading branch information
StevenACoffman authored Feb 21, 2022
2 parents 2776c98 + 9b0e4a7 commit 3e7886d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions parser/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func (p *parser) parseInterfaceTypeDefinition(description string) *Definition {
def.Kind = Interface
def.Description = description
def.Name = p.parseName()
def.Interfaces = p.parseImplementsInterfaces()
def.Directives = p.parseDirectives(true)
def.Fields = p.parseFieldsDefinition()
return &def
Expand Down
42 changes: 42 additions & 0 deletions parser/schema_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,48 @@ interface:
message: "expected at least one definition, found }"
locations: [{ line: 1, column: 18 }]

- name: may define intermediate interfaces
input: |
interface IA {
id: ID!
}
interface IIA implements IA {
id: ID!
}
type A implements IIA {
id: ID!
}
ast: |
<SchemaDocument>
Definitions: [Definition]
- <Definition>
Kind: DefinitionKind("INTERFACE")
Name: "IA"
Fields: [FieldDefinition]
- <FieldDefinition>
Name: "id"
Type: ID!
- <Definition>
Kind: DefinitionKind("INTERFACE")
Name: "IIA"
Interfaces: [string]
- "IA"
Fields: [FieldDefinition]
- <FieldDefinition>
Name: "id"
Type: ID!
- <Definition>
Kind: DefinitionKind("OBJECT")
Name: "A"
Interfaces: [string]
- "IIA"
Fields: [FieldDefinition]
- <FieldDefinition>
Name: "id"
Type: ID!
unions:
- name: simple
input: "union Hello = World"
Expand Down
19 changes: 17 additions & 2 deletions validator/schema_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object types:
message: 'Name "__bar" must not begin with "__", which is reserved by GraphQL introspection.'
locations: [{line: 2, column: 7}]

- name: must not allow input object as field type
- name: must not allow input object as field type
input: |
input Input {
id: ID
Expand Down Expand Up @@ -151,6 +151,7 @@ interfaces:
error:
message: 'INTERFACE must define one or more fields.'
locations: [{line: 6, column: 11}]

- name: check reserved names on type name
input: |
interface __FooBar {
Expand All @@ -160,7 +161,7 @@ interfaces:
message: 'Name "__FooBar" must not begin with "__", which is reserved by GraphQL introspection.'
locations: [{line: 1, column: 11}]

- name: must not allow input object as field type
- name: must not allow input object as field type
input: |
input Input {
id: ID
Expand Down Expand Up @@ -275,6 +276,20 @@ interfaces:
f: U!
}
- name: may define intermediate interfaces
input: |
interface IA {
id: ID!
}
interface IIA implements IA {
id: ID!
}
type A implements IIA {
id: ID!
}
inputs:
- name: must define one or more input fields
input: |
Expand Down

0 comments on commit 3e7886d

Please sign in to comment.