2525import static graphql .Assert .assertNotNull ;
2626import static graphql .Assert .assertShouldNeverHappen ;
2727import static graphql .Assert .assertTrue ;
28+ import static graphql .DirectivesUtil .directivesByName ;
2829import static graphql .schema .GraphqlTypeComparators .byNameAsc ;
2930import static graphql .schema .GraphqlTypeComparators .sortTypes ;
3031import static java .util .Arrays .asList ;
@@ -225,10 +226,26 @@ public GraphqlFieldVisibility getFieldVisibility() {
225226 return codeRegistry .getFieldVisibility ();
226227 }
227228
229+ /**
230+ * This returns the list of directives that are associated with this schema object including
231+ * built in ones.
232+ *
233+ * @return a list of directives
234+ */
228235 public List <GraphQLDirective > getDirectives () {
229236 return new ArrayList <>(directives );
230237 }
231238
239+ /**
240+ * This returns a map of directives that are associated with this schema object including
241+ * built in ones.
242+ *
243+ * @return a map of directives
244+ */
245+ public Map <String , GraphQLDirective > getDirectiveByName () {
246+ return directivesByName (getDirectives ());
247+ }
248+
232249 public GraphQLDirective getDirective (String name ) {
233250 for (GraphQLDirective directive : getDirectives ()) {
234251 if (directive .getName ().equals (name )) {
@@ -250,6 +267,18 @@ public List<GraphQLDirective> getSchemaDirectives() {
250267 return new ArrayList <>(schemaDirectives .values ());
251268 }
252269
270+ /**
271+ * This returns a map of directives that have been explicitly put on the
272+ * schema object. Note that {@link {@link #getDirectives()}} will return
273+ * directives for all schema elements, whereas this is just for the schema
274+ * element itself
275+ *
276+ * @return a list of directives
277+ */
278+ public Map <String , GraphQLDirective > getSchemaDirectiveByName () {
279+ return directivesByName (getSchemaDirectives ());
280+ }
281+
253282 /**
254283 * This returns the named directive that have been explicitly put on the
255284 * schema object. Note that {@link {@link #getDirective(String)} ()}} will return
0 commit comments