File tree Expand file tree Collapse file tree
src/main/java/graphql/schema/idl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import graphql .PublicApi ;
66import graphql .language .Definition ;
77import graphql .language .Document ;
8+ import graphql .language .SDLDefinition ;
89import graphql .parser .Parser ;
910import graphql .schema .idl .errors .SchemaProblem ;
1011import org .antlr .v4 .runtime .misc .ParseCancellationException ;
@@ -101,7 +102,9 @@ public TypeDefinitionRegistry buildRegistry(Document document) {
101102 TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry ();
102103 List <Definition > definitions = document .getDefinitions ();
103104 for (Definition definition : definitions ) {
104- typeRegistry .add (definition ).ifPresent (errors ::add );
105+ if (definition instanceof SDLDefinition ) {
106+ typeRegistry .add ((SDLDefinition ) definition ).ifPresent (errors ::add );
107+ }
105108 }
106109 if (errors .size () > 0 ) {
107110 throw new SchemaProblem (errors );
Original file line number Diff line number Diff line change 33import graphql .Assert ;
44import graphql .GraphQLError ;
55import graphql .PublicApi ;
6- import graphql .language .Definition ;
76import graphql .language .DirectiveDefinition ;
87import graphql .language .EnumTypeExtensionDefinition ;
98import graphql .language .InputObjectTypeExtensionDefinition ;
@@ -143,7 +142,7 @@ public TypeDefinitionRegistry merge(TypeDefinitionRegistry typeRegistry) throws
143142 *
144143 * @return an optional error
145144 */
146- public Optional <GraphQLError > add (Definition definition ) {
145+ public Optional <GraphQLError > add (SDLDefinition definition ) {
147146 // extensions
148147 if (definition instanceof ObjectTypeExtensionDefinition ) {
149148 ObjectTypeExtensionDefinition newEntry = (ObjectTypeExtensionDefinition ) definition ;
@@ -181,6 +180,8 @@ public Optional<GraphQLError> add(Definition definition) {
181180 } else {
182181 schema = newSchema ;
183182 }
183+ } else {
184+ return Assert .assertShouldNeverHappen ();
184185 }
185186 return Optional .empty ();
186187 }
You can’t perform that action at this time.
0 commit comments