Polishing
This commit is contained in:
@@ -110,7 +110,9 @@ public final class ConnectionFieldTypeVisitor extends GraphQLTypeVisitorStub {
|
||||
return TraversalControl.CONTINUE;
|
||||
}
|
||||
|
||||
private static boolean isUnderSubscriptionOperation(TypeVisitorHelper visitorHelper, TraverserContext<GraphQLSchemaElement> context) {
|
||||
private static boolean isUnderSubscriptionOperation(
|
||||
TypeVisitorHelper visitorHelper, TraverserContext<GraphQLSchemaElement> context) {
|
||||
|
||||
return context.getBreadcrumbs().stream()
|
||||
.filter(GraphQLFieldsContainer.class::isInstance)
|
||||
.map(GraphQLFieldsContainer.class::cast)
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.graphql.execution;
|
||||
|
||||
import graphql.schema.GraphQLNamedType;
|
||||
import graphql.schema.GraphQLObjectType;
|
||||
import graphql.schema.GraphQLSchema;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link TypeVisitorHelper} that performs checks
|
||||
* against {@link GraphQLSchema}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
final class DefaultTypeVisitorHelper implements TypeVisitorHelper {
|
||||
|
||||
@Nullable
|
||||
private final String subscriptionTypeName;
|
||||
|
||||
|
||||
/**
|
||||
* Package private constructor.
|
||||
*/
|
||||
DefaultTypeVisitorHelper(GraphQLSchema schema) {
|
||||
GraphQLObjectType subscriptionType = schema.getSubscriptionType();
|
||||
this.subscriptionTypeName = (subscriptionType != null) ? subscriptionType.getName() : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the given type is the subscription type.
|
||||
*/
|
||||
@Override
|
||||
public boolean isSubscriptionType(GraphQLNamedType type) {
|
||||
return (type.getName().equals(this.subscriptionTypeName));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,15 +16,13 @@
|
||||
|
||||
package org.springframework.graphql.execution;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import graphql.schema.GraphQLNamedType;
|
||||
import graphql.schema.GraphQLSchema;
|
||||
|
||||
/**
|
||||
* Helper for {@link graphql.schema.GraphQLTypeVisitor}s registered via
|
||||
* {@link GraphQlSource.Builder#typeVisitors(List)} that is exposed as a
|
||||
* variable in {@link graphql.util.TraverserContext}.
|
||||
* Helps {@link graphql.schema.GraphQLTypeVisitor}s to recognize whether a type
|
||||
* is the subscription type. Exposed as a variable in
|
||||
* {@link graphql.util.TraverserContext}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 1.2.1
|
||||
@@ -43,7 +41,8 @@ public interface TypeVisitorHelper {
|
||||
* @param schema the GraphQL schema to use
|
||||
*/
|
||||
static TypeVisitorHelper create(GraphQLSchema schema) {
|
||||
return new DefaultTypeVisitorHelper(schema);
|
||||
String name = (schema.getSubscriptionType() != null) ? schema.getSubscriptionType().getName() : null;
|
||||
return (candidate) -> candidate.getName().equals(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user