|
45 | 45 | import static graphql.Assert.assertNotNull; |
46 | 46 | import static graphql.schema.idl.SchemaExtensionsChecker.defineOperationDefs; |
47 | 47 | import static graphql.schema.idl.SchemaExtensionsChecker.gatherOperationDefs; |
| 48 | +import static graphql.schema.idl.TypeInfo.typeName; |
48 | 49 | import static java.util.Optional.ofNullable; |
49 | 50 |
|
50 | 51 | /** |
@@ -492,19 +493,33 @@ public Map<String, DirectiveDefinition> getDirectiveDefinitions() { |
492 | 493 | return new LinkedHashMap<>(directiveDefinitions); |
493 | 494 | } |
494 | 495 |
|
| 496 | + /** |
| 497 | + * Returns true if the registry has a type of the specified {@link TypeName} |
| 498 | + * |
| 499 | + * @param typeName the type name to check |
| 500 | + * |
| 501 | + * @return true if the registry has a type by that type name |
| 502 | + */ |
495 | 503 | public boolean hasType(TypeName typeName) { |
496 | 504 | String name = typeName.getName(); |
497 | | - return types.containsKey(name) || ScalarInfo.GRAPHQL_SPECIFICATION_SCALARS_DEFINITIONS.containsKey(name) || scalarTypes.containsKey(name) || objectTypeExtensions.containsKey(name); |
| 505 | + return hasType(name); |
498 | 506 | } |
499 | 507 |
|
500 | | - private static String typeName(Type type) { |
501 | | - return TypeInfo.getTypeName(type).getName(); |
| 508 | + /** |
| 509 | + * Returns true if the registry has a type of the specified name |
| 510 | + * |
| 511 | + * @param name the name to check |
| 512 | + * |
| 513 | + * @return true if the registry has a type by that name |
| 514 | + */ |
| 515 | + public boolean hasType(String name) { |
| 516 | + return types.containsKey(name) || ScalarInfo.GRAPHQL_SPECIFICATION_SCALARS_DEFINITIONS.containsKey(name) || scalarTypes.containsKey(name) || objectTypeExtensions.containsKey(name); |
502 | 517 | } |
503 | 518 |
|
504 | 519 | /** |
505 | 520 | * Returns am optional {@link TypeDefinition} of the specified type or {@link Optional#empty()} |
506 | 521 | * |
507 | | - * @param type the type to check |
| 522 | + * @param type the type to check |
508 | 523 | * |
509 | 524 | * @return an optional {@link TypeDefinition} or empty if it's not found |
510 | 525 | */ |
|
0 commit comments