Remove APIs deprecated in 1.0.x
Closes gh-941
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -31,21 +31,6 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public interface ResponseField {
|
||||
|
||||
/**
|
||||
* Whether the field has a value.
|
||||
* <ul>
|
||||
* <li>{@code "true"} means the field is not {@code null}, and therefore valid,
|
||||
* although it may be partial with nested field {@link #getErrors() errors}.
|
||||
* <li>{@code "false"} means the field is {@code null} or doesn't exist; use
|
||||
* {@link #getErrors()} to check for field errors, and
|
||||
* {@link GraphQlResponse#isValid()} to check if the entire response is
|
||||
* valid or not.
|
||||
* </ul>
|
||||
* @deprecated as of 1.0.3 in favor of checking via {@link #getValue()}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean hasValue();
|
||||
|
||||
/**
|
||||
* Return a String representation of the field path as described in
|
||||
* {@link ClientGraphQlResponse#field(String)}.
|
||||
@@ -67,32 +52,6 @@ public interface ResponseField {
|
||||
@Nullable
|
||||
<T> T getValue();
|
||||
|
||||
/**
|
||||
* Return the error that provides the reason for a failed field.
|
||||
* <p>When the field is {@code null}, this method looks for the first field
|
||||
* error. According to the GraphQL spec, section 6.4.4, "Handling Field
|
||||
* Errors", there should be only one error per field. The returned field
|
||||
* error may be:
|
||||
* <ul>
|
||||
* <li>on the field
|
||||
* <li>on a parent field, when the field is not present
|
||||
* <li>on a nested field, when a {@code non-null} nested field error bubbles up
|
||||
* </ul>
|
||||
* <p>As a fallback, this method also checks "request errors" in case the
|
||||
* entire response is not {@link GraphQlResponse#isValid() valid}. If there
|
||||
* are no errors at all, {@code null} is returned, and it implies the field
|
||||
* value was set to {@code null} by its {@code DataFetcher}.
|
||||
* <p>When the field <strong>does</strong> have a value, it is considered
|
||||
* valid and this method returns {@code null}, although the field may be
|
||||
* partial and contain {@link #getErrors() errors} on nested fields.
|
||||
* @return return the error for this field, or {@code null} if there is no
|
||||
* error with the same path as the field path
|
||||
* @deprecated since 1.0.3 in favor of {@link #getErrors()}
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
ResponseError getError();
|
||||
|
||||
/**
|
||||
* Return all errors that have a path, and it is at above, or below the field path.
|
||||
* <p>According to the GraphQL spec, section 6.4.4, "Handling Field Errors"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -55,12 +55,6 @@ final class DefaultClientResponseField implements ClientResponseField {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return (this.field.getValue() != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return this.field.getPath();
|
||||
@@ -76,12 +70,6 @@ final class DefaultClientResponseField implements ClientResponseField {
|
||||
return this.field.getValue();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public ResponseError getError() {
|
||||
return this.field.getError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResponseError> getErrors() {
|
||||
return this.field.getErrors();
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.data.query;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import graphql.schema.DataFetcher;
|
||||
import graphql.schema.FieldCoordinates;
|
||||
import graphql.schema.GraphQLCodeRegistry;
|
||||
import graphql.schema.GraphQLFieldDefinition;
|
||||
import graphql.schema.GraphQLFieldsContainer;
|
||||
import graphql.schema.GraphQLList;
|
||||
import graphql.schema.GraphQLNamedOutputType;
|
||||
import graphql.schema.GraphQLSchemaElement;
|
||||
import graphql.schema.GraphQLType;
|
||||
import graphql.schema.GraphQLTypeVisitorStub;
|
||||
import graphql.schema.PropertyDataFetcher;
|
||||
import graphql.util.TraversalControl;
|
||||
import graphql.util.TraverserContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Given a map of GraphQL type names and DataFetcher factories, find queries
|
||||
* with a matching return type and register DataFetcher's for them, unless they
|
||||
* already have registrations.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @deprecated in favor of {@link AutoRegistrationRuntimeWiringConfigurer}
|
||||
*/
|
||||
@Deprecated
|
||||
class AutoRegistrationTypeVisitor extends GraphQLTypeVisitorStub {
|
||||
|
||||
private final Map<String, Function<Boolean, DataFetcher<?>>> dataFetcherFactories;
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance of the visitor.
|
||||
* @param dataFetcherFactories map with GraphQL type names as keys and
|
||||
* functions as values to create a DataFetcher for single or many values
|
||||
*/
|
||||
public AutoRegistrationTypeVisitor(Map<String, Function<Boolean, DataFetcher<?>>> dataFetcherFactories) {
|
||||
this.dataFetcherFactories = dataFetcherFactories;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TraversalControl visitGraphQLFieldDefinition(
|
||||
GraphQLFieldDefinition fieldDefinition, TraverserContext<GraphQLSchemaElement> context) {
|
||||
|
||||
if (this.dataFetcherFactories.isEmpty()) {
|
||||
return TraversalControl.QUIT;
|
||||
}
|
||||
|
||||
GraphQLType fieldType = fieldDefinition.getType();
|
||||
GraphQLFieldsContainer parent = (GraphQLFieldsContainer) context.getParentNode();
|
||||
if (!parent.getName().equals("Query")) {
|
||||
return TraversalControl.ABORT;
|
||||
}
|
||||
|
||||
DataFetcher<?> dataFetcher = (fieldType instanceof GraphQLList ?
|
||||
getDataFetcher(((GraphQLList) fieldType).getWrappedType(), false) :
|
||||
getDataFetcher(fieldType, true));
|
||||
|
||||
if (dataFetcher != null) {
|
||||
GraphQLCodeRegistry.Builder registry = context.getVarFromParents(GraphQLCodeRegistry.Builder.class);
|
||||
if (!hasDataFetcher(registry, parent, fieldDefinition)) {
|
||||
FieldCoordinates coordinates = FieldCoordinates.coordinates(parent.getName(), fieldDefinition.getName());
|
||||
registry.dataFetcher(coordinates, dataFetcher);
|
||||
}
|
||||
}
|
||||
|
||||
return TraversalControl.CONTINUE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private DataFetcher<?> getDataFetcher(GraphQLType type, boolean single) {
|
||||
if (type instanceof GraphQLNamedOutputType) {
|
||||
String typeName = ((GraphQLNamedOutputType) type).getName();
|
||||
Function<Boolean, DataFetcher<?>> factory = this.dataFetcherFactories.get(typeName);
|
||||
if (factory != null) {
|
||||
return factory.apply(single);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasDataFetcher(
|
||||
GraphQLCodeRegistry.Builder registry, GraphQLFieldsContainer parent,
|
||||
GraphQLFieldDefinition fieldDefinition) {
|
||||
|
||||
FieldCoordinates coordinates = FieldCoordinates.coordinates(parent.getName(), fieldDefinition.getName());
|
||||
DataFetcher<?> fetcher = registry.getDataFetcher(coordinates, fieldDefinition);
|
||||
return (fetcher != null && !(fetcher instanceof PropertyDataFetcher));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import graphql.schema.DataFetcher;
|
||||
import graphql.schema.DataFetchingEnvironment;
|
||||
import graphql.schema.DataFetchingFieldSelectionSet;
|
||||
import graphql.schema.GraphQLArgument;
|
||||
import graphql.schema.GraphQLTypeVisitor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -295,45 +294,6 @@ public abstract class QueryByExampleDataFetcher<T> {
|
||||
return new AutoRegistrationRuntimeWiringConfigurer(factories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link GraphQLTypeVisitor} that finds queries with a return type
|
||||
* whose name matches to the domain type name of the given repositories and
|
||||
* registers {@link DataFetcher}s for those queries.
|
||||
* <p><strong>Note:</strong> currently, this method will match only to
|
||||
* queries under the top-level "Query" type in the GraphQL schema.
|
||||
*
|
||||
* @param executors repositories to consider for registration
|
||||
* @param reactiveExecutors reactive repositories to consider for registration
|
||||
* @return the created visitor
|
||||
* @deprecated in favor of {@link #autoRegistrationConfigurer(List, List)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static GraphQLTypeVisitor autoRegistrationTypeVisitor(
|
||||
List<QueryByExampleExecutor<?>> executors,
|
||||
List<ReactiveQueryByExampleExecutor<?>> reactiveExecutors) {
|
||||
|
||||
Map<String, Function<Boolean, DataFetcher<?>>> factories = new HashMap<>();
|
||||
|
||||
for (QueryByExampleExecutor<?> executor : executors) {
|
||||
String typeName = RepositoryUtils.getGraphQlTypeName(executor);
|
||||
if (typeName != null) {
|
||||
Builder<?, ?> builder = customize(executor, builder(executor));
|
||||
factories.put(typeName, single -> single ? builder.single() : builder.many());
|
||||
}
|
||||
}
|
||||
|
||||
for (ReactiveQueryByExampleExecutor<?> executor : reactiveExecutors) {
|
||||
String typeName = RepositoryUtils.getGraphQlTypeName(executor);
|
||||
if (typeName != null) {
|
||||
ReactiveBuilder<?, ?> builder = customize(executor, builder(executor));
|
||||
factories.put(typeName, single -> single ? builder.single() : builder.many());
|
||||
}
|
||||
}
|
||||
|
||||
return new AutoRegistrationTypeVisitor(factories);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private static Builder customize(QueryByExampleExecutor<?> executor, Builder builder) {
|
||||
if(executor instanceof QueryByExampleBuilderCustomizer<?> customizer){
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.querydsl.core.types.Predicate;
|
||||
import graphql.schema.DataFetcher;
|
||||
import graphql.schema.DataFetchingEnvironment;
|
||||
import graphql.schema.DataFetchingFieldSelectionSet;
|
||||
import graphql.schema.GraphQLTypeVisitor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -326,50 +325,6 @@ public abstract class QuerydslDataFetcher<T> {
|
||||
return new AutoRegistrationRuntimeWiringConfigurer(factories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link GraphQLTypeVisitor} that auto-registers the given
|
||||
* Querydsl repositories for queries that do not already have a registered
|
||||
* {@code DataFetcher} and whose return type matches the simple name of the
|
||||
* repository domain type.
|
||||
*
|
||||
* <p><strong>Note:</strong> Auto-registration applies only to
|
||||
* {@link GraphQlRepository @GraphQlRepository}-annotated repositories.
|
||||
* If a repository is also an instance of {@link QuerydslBinderCustomizer},
|
||||
* this is transparently detected and applied through the
|
||||
* {@code QuerydslDataFetcher} builder methods.
|
||||
*
|
||||
* @param executors repositories to consider for registration
|
||||
* @param reactiveExecutors reactive repositories to consider for registration
|
||||
* @return the created visitor
|
||||
* @deprecated in favor of {@link #autoRegistrationConfigurer(List, List)}
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Deprecated
|
||||
public static GraphQLTypeVisitor autoRegistrationTypeVisitor(
|
||||
List<QuerydslPredicateExecutor<?>> executors,
|
||||
List<ReactiveQuerydslPredicateExecutor<?>> reactiveExecutors) {
|
||||
|
||||
Map<String, Function<Boolean, DataFetcher<?>>> factories = new HashMap<>();
|
||||
|
||||
for (QuerydslPredicateExecutor<?> executor : executors) {
|
||||
String typeName = RepositoryUtils.getGraphQlTypeName(executor);
|
||||
if (typeName != null) {
|
||||
Builder<?, ?> builder = customize(executor, QuerydslDataFetcher.builder(executor).customizer(customizer(executor)));
|
||||
factories.put(typeName, single -> single ? builder.single() : builder.many());
|
||||
}
|
||||
}
|
||||
|
||||
for (ReactiveQuerydslPredicateExecutor<?> executor : reactiveExecutors) {
|
||||
String typeName = RepositoryUtils.getGraphQlTypeName(executor);
|
||||
if (typeName != null) {
|
||||
ReactiveBuilder builder = customize(executor, QuerydslDataFetcher.builder(executor).customizer(customizer(executor)));
|
||||
factories.put(typeName, single -> single ? builder.single() : builder.many());
|
||||
}
|
||||
}
|
||||
|
||||
return new AutoRegistrationTypeVisitor(factories);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private static Builder customize(QuerydslPredicateExecutor<?> executor, Builder builder) {
|
||||
if(executor instanceof QuerydslBuilderCustomizer<?> customizer){
|
||||
|
||||
@@ -134,24 +134,4 @@ public abstract class DataFetcherExceptionResolverAdapter implements DataFetcher
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Factory method to create a {@link DataFetcherExceptionResolverAdapter} that
|
||||
* resolves exceptions with the given {@code BiFunction}.
|
||||
* @param resolver the resolver function to use
|
||||
* @return the created instance
|
||||
* @deprecated as of 1.0.1, please use {@link DataFetcherExceptionResolver#forSingleError(BiFunction)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static DataFetcherExceptionResolverAdapter from(
|
||||
BiFunction<Throwable, DataFetchingEnvironment, GraphQLError> resolver) {
|
||||
|
||||
return new DataFetcherExceptionResolverAdapter() {
|
||||
|
||||
@Override
|
||||
protected GraphQLError resolveToSingleError(Throwable ex, DataFetchingEnvironment env) {
|
||||
return resolver.apply(ex, env);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class WebSocketGraphQlRequest extends WebGraphQlRequest {
|
||||
* Create an instance.
|
||||
* @deprecated as of 1.1.3 in favor of the constructor with cookies
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since = "1.1.3", forRemoval = true)
|
||||
public WebSocketGraphQlRequest(
|
||||
URI uri, HttpHeaders headers, Map<String, Object> body, String id, @Nullable Locale locale,
|
||||
WebSocketSessionInfo sessionInfo) {
|
||||
|
||||
@@ -148,7 +148,7 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
|
||||
* propagate context.
|
||||
* @deprecated as of 1.1.0 in favor of {@link #initWebSocketHttpRequestHandler(HandshakeHandler)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since = "1.1.0", forRemoval = true)
|
||||
public WebSocketHttpRequestHandler asWebSocketHttpRequestHandler(HandshakeHandler handshakeHandler) {
|
||||
return initWebSocketHttpRequestHandler(handshakeHandler);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -160,33 +160,12 @@ public abstract class AbstractGraphQlResponse implements GraphQlResponse {
|
||||
return this.parsedPath;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return (this.value != null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getValue() {
|
||||
return (T) this.value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public ResponseError getError() {
|
||||
if (getValue() != null) {
|
||||
if (!this.fieldErrors.isEmpty()) {
|
||||
return this.fieldErrors.get(0);
|
||||
}
|
||||
if (!this.response.getErrors().isEmpty()) {
|
||||
return this.response.getErrors().get(0);
|
||||
}
|
||||
// No errors, set to null by DataFetcher
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResponseError> getErrors() {
|
||||
return this.fieldErrors;
|
||||
|
||||
Reference in New Issue
Block a user