Skip to content

Commit c4fc1d0

Browse files
committed
improve javadoc
1 parent 6d61912 commit c4fc1d0

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

‎src/main/java/graphql/schema/GraphQLSchema.java‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,32 @@ public GraphQLObjectType getIntrospectionSchemaType() {
222222
/**
223223
* Returns the set of "additional types" that were provided when building the schema.
224224
* <p>
225-
* Additional types are types that are not directly reachable via the root operation types
226-
* (Query, Mutation, Subscription) but still need to be part of the schema. The most common
227-
* use case is for interface implementations that are not directly referenced in field return types.
225+
* During schema construction, types are discovered by traversing the schema from multiple roots:
226+
* <ul>
227+
* <li>Root operation types (Query, Mutation, Subscription)</li>
228+
* <li>Directive argument types</li>
229+
* <li>Introspection types</li>
230+
* <li>Types explicitly added via {@link Builder#additionalType(GraphQLType)}</li>
231+
* </ul>
232+
* <p>
233+
* Additional types are types that are not reachable via any of the automatic traversal paths
234+
* but still need to be part of the schema. The most common use case is for interface
235+
* implementations that are not directly referenced elsewhere.
236+
* <p>
237+
* <b>Types that do NOT need to be added as additional types:</b>
238+
* <ul>
239+
* <li>Types reachable from Query, Mutation, or Subscription fields</li>
240+
* <li>Types used as directive arguments (these are discovered via directive traversal)</li>
241+
* </ul>
228242
* <p>
229-
* <b>When additional types are typically needed:</b>
243+
* <b>When additional types ARE typically needed:</b>
230244
* <ul>
231245
* <li><b>Interface implementations:</b> When an interface is used as a field's return type,
232-
* implementing types that are not directly referenced elsewhere need to be added so they
233-
* can be resolved at runtime and appear in introspection.</li>
246+
* implementing object types are not automatically discovered because interfaces do not
247+
* reference their implementors. These need to be added so they can be resolved at runtime
248+
* and appear in introspection.</li>
234249
* <li><b>SDL-defined schemas:</b> When building from SDL, the {@link graphql.schema.idl.SchemaGenerator}
235-
* automatically detects types not connected to root operations and adds them as additional types.</li>
250+
* automatically detects types not connected to any root and adds them as additional types.</li>
236251
* <li><b>Programmatic schemas with type references:</b> When using {@link GraphQLTypeReference}
237252
* to break circular dependencies, the actual type implementations may need to be provided
238253
* as additional types.</li>
@@ -253,7 +268,7 @@ public GraphQLObjectType getIntrospectionSchemaType() {
253268
* }</pre>
254269
* <p>
255270
* <b>Note:</b> There are no restrictions on what types can be added via this mechanism.
256-
* Types that are already reachable from the root operations can also be added without causing
271+
* Types that are already reachable from other roots can also be added without causing
257272
* errors - they will simply be present in both the type map (via traversal) and this set.
258273
* After schema construction, use {@link #getTypeMap()} or {@link #getAllTypesAsList()} to get
259274
* all types in the schema regardless of how they were discovered.

0 commit comments

Comments
 (0)