Skip to content
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

resolve #82 -- add support for interface extensions #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 4 additions & 0 deletions ast/ast.ast
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ O SchemaDefinition
O ScalarTypeDefinition
O ObjectTypeDefinition
O InterfaceTypeDefinition
O InterfaceExtensionDefinition
O UnionTypeDefinition
O EnumTypeDefinition
O InputObjectTypeDefinition
Expand Down Expand Up @@ -175,6 +176,9 @@ S Name name
P? Directive directives
P FieldDefinition fields

T InterfaceExtensionDefinition
S InterfaceTypeDefinition definition

T UnionTypeDefinition
S Name name
P? Directive directives
Expand Down
7 changes: 7 additions & 0 deletions parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ using facebook::graphql::ast::SchemaDefinition;
using facebook::graphql::ast::ScalarTypeDefinition;
using facebook::graphql::ast::ObjectTypeDefinition;
using facebook::graphql::ast::InterfaceTypeDefinition;
using facebook::graphql::ast::InterfaceExtensionDefinition;
using facebook::graphql::ast::UnionTypeDefinition;
using facebook::graphql::ast::EnumTypeDefinition;
using facebook::graphql::ast::InputObjectTypeDefinition;
Expand Down Expand Up @@ -125,6 +126,7 @@ union yystype { \
ScalarTypeDefinition *scalarTypeDefinition; \
ObjectTypeDefinition *objectTypeDefinition; \
InterfaceTypeDefinition *interfaceTypeDefinition; \
InterfaceExtensionDefinition *interfaceExtensionDefinition; \
UnionTypeDefinition *unionTypeDefinition; \
EnumTypeDefinition *enumTypeDefinition; \
InputObjectTypeDefinition *inputObjectTypeDefinition; \
Expand Down Expand Up @@ -266,6 +268,7 @@ union yystype { \
%type <scalarTypeDefinition> scalar_type_definition;
%type <objectTypeDefinition> object_type_definition;
%type <interfaceTypeDefinition> interface_type_definition;
%type <interfaceExtensionDefinition> interface_extension_definition;
%type <unionTypeDefinition> union_type_definition;
%type <enumTypeDefinition> enum_type_definition;
%type <inputObjectTypeDefinition> input_object_type_definition;
Expand Down Expand Up @@ -360,6 +363,7 @@ schema_gate: schema_definition { $$ = static_cast<Definition *>($1); }
| enum_type_definition { $$ = static_cast<Definition *>($1); }
| input_object_type_definition { $$ = static_cast<Definition *>($1); }
| type_extension_definition { $$ = static_cast<Definition *>($1); }
| interface_extension_definition { $$ = static_cast<Definition *>($1); }
| directive_definition { $$ = static_cast<Definition *>($1); }
;

Expand Down Expand Up @@ -644,6 +648,9 @@ input_value_definition: name ":" type default_value_opt directives_opt { $$ = ne
interface_type_definition: INTERFACE name directives_opt "{" field_definition_list "}" { $$ = new InterfaceTypeDefinition(@$, $2, $3, $5); }
;

interface_extension_definition: EXTEND interface_type_definition { $$ = new InterfaceExtensionDefinition(@$, $2); }
;

union_type_definition: UNION name directives_opt "=" union_members { $$ = new UnionTypeDefinition(@$, $2, $3, $5); }
;

Expand Down
2 changes: 2 additions & 0 deletions test/ParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ TEST(SchemaParserTests, SimpleSchema) {
"otherField: otherType }");
expectSchemaParsing("extend type SomeType " DIRECTIVES
"{ anotherField : AnotherType }");
expectSchemaParsing("extend interface SomeInterface " DIRECTIVES
"{ anotherField : AnotherType }");
expectSchemaParsing("directive @somedirective(a1 : t1 = 1 " DIRECTIVES
", a2 : t2) on foo | bar");
}
4 changes: 4 additions & 0 deletions test/schema-kitchen-sink.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ extend type Foo {
seven(argument: [String]): Type
}

extend interface Bar {
name: String
}

# NOTE: out-of-spec test cases commented out until the spec is clarified; see
# https://github.com/graphql/graphql-js/issues/650 .
# extend type Foo @onType {}
Expand Down
2 changes: 1 addition & 1 deletion test/schema-kitchen-sink.json

Large diffs are not rendered by default.