@@ -54,8 +54,11 @@ public class GraphQLSchema {
5454 private final Map <String , GraphQLNamedType > typeMap ;
5555 private final Map <String , List <GraphQLObjectType >> byInterface ;
5656
57+ private final String description ;
58+
5759 /**
5860 * @param queryType the query type
61+ *
5962 * @deprecated use the {@link #newSchema()} builder pattern instead, as this constructor will be made private in a future version.
6063 */
6164 @ Internal
@@ -68,6 +71,7 @@ public GraphQLSchema(GraphQLObjectType queryType) {
6871 * @param queryType the query type
6972 * @param mutationType the mutation type
7073 * @param additionalTypes additional types
74+ *
7175 * @deprecated use the {@link #newSchema()} builder pattern instead, as this constructor will be made private in a future version.
7276 */
7377 @ Internal
@@ -81,6 +85,7 @@ public GraphQLSchema(GraphQLObjectType queryType, GraphQLObjectType mutationType
8185 * @param mutationType the mutation type
8286 * @param subscriptionType the subscription type
8387 * @param additionalTypes additional types
88+ *
8489 * @deprecated use the {@link #newSchema()} builder pattern instead, as this constructor will be made private in a future version.
8590 */
8691 @ Internal
@@ -110,6 +115,7 @@ private GraphQLSchema(Builder builder, boolean afterTransform) {
110115 SchemaUtil schemaUtil = new SchemaUtil ();
111116 this .typeMap = new TreeMap <>(schemaUtil .allTypes (this , additionalTypes , afterTransform ));
112117 this .byInterface = new TreeMap <>(schemaUtil .groupImplementations (this ));
118+ this .description = builder .description ;
113119 }
114120
115121 // This can be removed once we no longer extract legacy code from types such as data fetchers but for now
@@ -128,6 +134,7 @@ private GraphQLSchema(GraphQLSchema otherSchema, GraphQLCodeRegistry codeRegistr
128134
129135 this .typeMap = otherSchema .typeMap ;
130136 this .byInterface = otherSchema .byInterface ;
137+ this .description = otherSchema .description ;
131138 }
132139
133140
@@ -147,7 +154,9 @@ public GraphQLType getType(String typeName) {
147154 * Called to return a named {@link graphql.schema.GraphQLObjectType} from the schema
148155 *
149156 * @param typeName the name of the type
157+ *
150158 * @return a graphql object type or null if there is one
159+ *
151160 * @throws graphql.GraphQLException if the type is NOT a object type
152161 */
153162 public GraphQLObjectType getObjectType (String typeName ) {
@@ -172,6 +181,7 @@ public List<GraphQLNamedType> getAllTypesAsList() {
172181 * interface type.
173182 *
174183 * @param type interface type to obtain implementations of.
184+ *
175185 * @return list of types implementing provided interface
176186 */
177187 public List <GraphQLObjectType > getImplementations (GraphQLInterfaceType type ) {
@@ -189,6 +199,7 @@ public List<GraphQLObjectType> getImplementations(GraphQLInterfaceType type) {
189199 *
190200 * @param abstractType abstract type either interface or union
191201 * @param concreteType concrete type
202+ *
192203 * @return true if possible type, false otherwise.
193204 */
194205 public boolean isPossibleType (GraphQLNamedType abstractType , GraphQLObjectType concreteType ) {
@@ -219,6 +230,7 @@ public GraphQLObjectType getSubscriptionType() {
219230
220231 /**
221232 * @return the field visibility
233+ *
222234 * @deprecated use {@link GraphQLCodeRegistry#getFieldVisibility()} instead
223235 */
224236 @ Deprecated
@@ -307,11 +319,16 @@ public boolean isSupportingSubscriptions() {
307319 return subscriptionType != null ;
308320 }
309321
322+ public String getDescription () {
323+ return description ;
324+ }
325+
310326 /**
311327 * This helps you transform the current GraphQLSchema object into another one by starting a builder with all
312328 * the current values and allows you to transform it how you want.
313329 *
314330 * @param builderConsumer the consumer code that will be given a builder to transform
331+ *
315332 * @return a new GraphQLSchema object based on calling build on that builder
316333 */
317334 public GraphQLSchema transform (Consumer <Builder > builderConsumer ) {
@@ -332,6 +349,7 @@ public static Builder newSchema() {
332349 * schema and then allows you to replace them.
333350 *
334351 * @param existingSchema the existing schema
352+ *
335353 * @return a new schema builder
336354 */
337355 public static Builder newSchema (GraphQLSchema existingSchema ) {
@@ -345,7 +363,8 @@ public static Builder newSchema(GraphQLSchema existingSchema) {
345363 .additionalDirectives (existingSchema .directives )
346364 .clearSchemaDirectives ()
347365 .withSchemaDirectives (schemaDirectivesArray (existingSchema ))
348- .additionalTypes (existingSchema .additionalTypes );
366+ .additionalTypes (existingSchema .additionalTypes )
367+ .description (existingSchema .getDescription ());
349368 }
350369
351370 private static GraphQLDirective [] schemaDirectivesArray (GraphQLSchema existingSchema ) {
@@ -361,6 +380,7 @@ public static class Builder {
361380 private Set <GraphQLType > additionalTypes = new LinkedHashSet <>();
362381 private SchemaDefinition definition ;
363382 private List <SchemaExtensionDefinition > extensionDefinitions ;
383+ private String description ;
364384
365385 // we default these in
366386 private Set <GraphQLDirective > additionalDirectives = new LinkedHashSet <>(
@@ -399,7 +419,9 @@ public Builder subscription(GraphQLObjectType subscriptionType) {
399419
400420 /**
401421 * @param fieldVisibility the field visibility
422+ *
402423 * @return this builder
424+ *
403425 * @deprecated use {@link graphql.schema.GraphQLCodeRegistry.Builder#fieldVisibility(graphql.schema.visibility.GraphqlFieldVisibility)} instead
404426 */
405427 @ Deprecated
@@ -481,11 +503,18 @@ public Builder extensionDefinitions(List<SchemaExtensionDefinition> extensionDef
481503 return this ;
482504 }
483505
506+ public Builder description (String description ) {
507+ this .description = description ;
508+ return this ;
509+ }
510+
484511 /**
485512 * Builds the schema
486513 *
487514 * @param additionalTypes - please dont use this any more
515+ *
488516 * @return the built schema
517+ *
489518 * @deprecated - Use the {@link #additionalType(GraphQLType)} methods
490519 */
491520 @ Deprecated
@@ -498,7 +527,9 @@ public GraphQLSchema build(Set<GraphQLType> additionalTypes) {
498527 *
499528 * @param additionalTypes - please don't use this any more
500529 * @param additionalDirectives - please don't use this any more
530+ *
501531 * @return the built schema
532+ *
502533 * @deprecated - Use the {@link #additionalType(GraphQLType)} and {@link #additionalDirective(GraphQLDirective)} methods
503534 */
504535 @ Deprecated
0 commit comments