Skip to content

Commit 072165b

Browse files
andimarekclaude
andcommitted
Clean up OperationValidator: remove dead code and fix warnings
- Remove unused import (GraphQLCodeRegistry) - Remove unused method parameters (checkSelectionSet, leaveOperationDefinition, leaveSelectionSet, documentFinished, validateUniqueArgumentNames_directive) - Remove always-false null check (validationContext in isExperimentalApiKeyEnabled) - Remove redundant @SuppressWarnings("deprecation") - Remove always-false value == null check in validateProvidedNonNullArguments - Simplify typeA/typeB null check (typeA never null in context) - Rename sameType -> notSameType, doTypesOverlap -> typesDoNotOverlap (always inverted) - Extract common validateUniqueArgumentNames to deduplicate field/directive variants - Convert indexed for-loop to enhanced for-each - Simplify ifArgumentMightBeFalse return - Remove dead query-type branch (schema always has query type) - Add null safety for getSourceLocation() and StringValue.getValue() - Add @nullable to GraphQLSchema.getDirective() (can return null per javadoc) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c0cf41c commit 072165b

2 files changed

Lines changed: 146 additions & 90 deletions

File tree

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public Map<String, GraphQLDirective> getDirectivesByName() {
565565
*
566566
* @return the directive or null if there is not one with that name
567567
*/
568-
public GraphQLDirective getDirective(String directiveName) {
568+
public @Nullable GraphQLDirective getDirective(String directiveName) {
569569
return directiveDefinitionsHolder.getDirective(directiveName);
570570
}
571571

@@ -1215,6 +1215,7 @@ public FastBuilder(GraphQLCodeRegistry.Builder codeRegistryBuilder,
12151215
* multiple FastBuilder instances.
12161216
*
12171217
* @param type the named type to add
1218+
*
12181219
* @return this builder for chaining
12191220
*/
12201221
public FastBuilder addType(GraphQLNamedType type) {
@@ -1264,6 +1265,7 @@ public FastBuilder addType(GraphQLNamedType type) {
12641265
* All non-root types added via this method will be included in {@link GraphQLSchema#getAdditionalTypes()}.
12651266
*
12661267
* @param types the named types to add
1268+
*
12671269
* @return this builder for chaining
12681270
*/
12691271
public FastBuilder addTypes(Collection<? extends GraphQLNamedType> types) {
@@ -1275,6 +1277,7 @@ public FastBuilder addTypes(Collection<? extends GraphQLNamedType> types) {
12751277
* Adds a directive definition to the schema.
12761278
*
12771279
* @param directive the directive to add
1280+
*
12781281
* @return this builder for chaining
12791282
*/
12801283
public FastBuilder additionalDirective(GraphQLDirective directive) {
@@ -1296,6 +1299,7 @@ public FastBuilder additionalDirective(GraphQLDirective directive) {
12961299
* Adds multiple directive definitions to the schema.
12971300
*
12981301
* @param directives the directives to add
1302+
*
12991303
* @return this builder for chaining
13001304
*/
13011305
public FastBuilder additionalDirectives(Collection<? extends GraphQLDirective> directives) {
@@ -1307,6 +1311,7 @@ public FastBuilder additionalDirectives(Collection<? extends GraphQLDirective> d
13071311
* Adds a schema-level directive (deprecated, use applied directives).
13081312
*
13091313
* @param directive the directive to add
1314+
*
13101315
* @return this builder for chaining
13111316
*/
13121317
public FastBuilder withSchemaDirective(GraphQLDirective directive) {
@@ -1318,6 +1323,7 @@ public FastBuilder withSchemaDirective(GraphQLDirective directive) {
13181323
* Adds multiple schema-level directives.
13191324
*
13201325
* @param directives the directives to add
1326+
*
13211327
* @return this builder for chaining
13221328
*/
13231329
public FastBuilder withSchemaDirectives(Collection<? extends GraphQLDirective> directives) {
@@ -1329,6 +1335,7 @@ public FastBuilder withSchemaDirectives(Collection<? extends GraphQLDirective> d
13291335
* Adds a schema-level applied directive.
13301336
*
13311337
* @param applied the applied directive to add
1338+
*
13321339
* @return this builder for chaining
13331340
*/
13341341
public FastBuilder withSchemaAppliedDirective(GraphQLAppliedDirective applied) {
@@ -1342,6 +1349,7 @@ public FastBuilder withSchemaAppliedDirective(GraphQLAppliedDirective applied) {
13421349
* Adds multiple schema-level applied directives.
13431350
*
13441351
* @param appliedList the applied directives to add
1352+
*
13451353
* @return this builder for chaining
13461354
*/
13471355
public FastBuilder withSchemaAppliedDirectives(Collection<? extends GraphQLAppliedDirective> appliedList) {
@@ -1355,6 +1363,7 @@ public FastBuilder withSchemaAppliedDirectives(Collection<? extends GraphQLAppli
13551363
* Sets the schema definition (AST).
13561364
*
13571365
* @param def the schema definition
1366+
*
13581367
* @return this builder for chaining
13591368
*/
13601369
public FastBuilder definition(SchemaDefinition def) {
@@ -1366,6 +1375,7 @@ public FastBuilder definition(SchemaDefinition def) {
13661375
* Sets the schema extension definitions (AST).
13671376
*
13681377
* @param defs the extension definitions
1378+
*
13691379
* @return this builder for chaining
13701380
*/
13711381
public FastBuilder extensionDefinitions(List<SchemaExtensionDefinition> defs) {
@@ -1377,6 +1387,7 @@ public FastBuilder extensionDefinitions(List<SchemaExtensionDefinition> defs) {
13771387
* Sets the schema description.
13781388
*
13791389
* @param description the description
1390+
*
13801391
* @return this builder for chaining
13811392
*/
13821393
public FastBuilder description(String description) {
@@ -1388,6 +1399,7 @@ public FastBuilder description(String description) {
13881399
* Sets the introspection schema type.
13891400
*
13901401
* @param type the introspection schema type
1402+
*
13911403
* @return this builder for chaining
13921404
*/
13931405
public FastBuilder introspectionSchemaType(GraphQLObjectType type) {
@@ -1399,6 +1411,7 @@ public FastBuilder introspectionSchemaType(GraphQLObjectType type) {
13991411
* Enables or disables schema validation.
14001412
*
14011413
* @param enabled true to enable validation, false to disable
1414+
*
14021415
* @return this builder for chaining
14031416
*/
14041417
public FastBuilder withValidation(boolean enabled) {
@@ -1415,9 +1428,10 @@ public FastBuilder withValidation(boolean enabled) {
14151428
* should not be reused with another FastBuilder.
14161429
*
14171430
* @return the built schema
1431+
*
14181432
* @throws InvalidSchemaException if validation is enabled and the schema is invalid
1419-
* @throws AssertException if a type reference cannot be resolved or if an interface/union
1420-
* type is missing a type resolver
1433+
* @throws AssertException if a type reference cannot be resolved or if an interface/union
1434+
* type is missing a type resolver
14211435
*/
14221436
public GraphQLSchema build() {
14231437
// Validate type resolvers for all interfaces and unions

0 commit comments

Comments
 (0)