Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/graphql/DeprecatedAt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package graphql;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.TYPE;

/**
* Helper to track deprecation
*
* Please use ISO-8601 format i.e. YYYY-MM-DD
*/
@Retention(RetentionPolicy.SOURCE)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked SOURCE level, as this annotation is only to help contributors. Open to ideas if you want another retention policy

@Target(value = {CONSTRUCTOR, METHOD, TYPE, FIELD, PACKAGE})
public @interface DeprecatedAt {
String value();
}
7 changes: 7 additions & 0 deletions src/main/java/graphql/DirectivesUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class DirectivesUtil {


@Deprecated // use GraphQLAppliedDirectives eventually
@DeprecatedAt("2022-02-24")
public static Map<String, GraphQLDirective> nonRepeatableDirectivesByName(List<GraphQLDirective> directives) {
// filter the repeatable directives
List<GraphQLDirective> singletonDirectives = directives.stream()
Expand All @@ -34,12 +35,14 @@ public static Map<String, GraphQLDirective> nonRepeatableDirectivesByName(List<G
}

@Deprecated // use GraphQLAppliedDirectives eventually
@DeprecatedAt("2022-02-24")
public static Map<String, ImmutableList<GraphQLDirective>> allDirectivesByName(List<GraphQLDirective> directives) {

return ImmutableMap.copyOf(FpKit.groupingBy(directives, GraphQLDirective::getName));
}

@Deprecated // use GraphQLAppliedDirectives eventually
@DeprecatedAt("2022-02-24")
public static Optional<GraphQLArgument> directiveWithArg(List<GraphQLDirective> directives, String directiveName, String argumentName) {
GraphQLDirective directive = nonRepeatableDirectivesByName(directives).get(directiveName);
GraphQLArgument argument = null;
Expand All @@ -51,6 +54,7 @@ public static Optional<GraphQLArgument> directiveWithArg(List<GraphQLDirective>


@Deprecated // use GraphQLAppliedDirectives eventually
@DeprecatedAt("2022-02-24")
public static boolean isAllNonRepeatable(List<GraphQLDirective> directives) {
if (directives == null || directives.isEmpty()) {
return false;
Expand All @@ -64,6 +68,7 @@ public static boolean isAllNonRepeatable(List<GraphQLDirective> directives) {
}

@Deprecated // use GraphQLAppliedDirectives eventually
@DeprecatedAt("2022-02-24")
public static List<GraphQLDirective> add(List<GraphQLDirective> targetList, GraphQLDirective newDirective) {
assertNotNull(targetList, () -> "directive list can't be null");
assertNotNull(newDirective, () -> "directive can't be null");
Expand All @@ -72,6 +77,7 @@ public static List<GraphQLDirective> add(List<GraphQLDirective> targetList, Grap
}

@Deprecated // use GraphQLAppliedDirectives eventually
@DeprecatedAt("2022-02-24")
public static List<GraphQLDirective> addAll(List<GraphQLDirective> targetList, List<GraphQLDirective> newDirectives) {
assertNotNull(targetList, () -> "directive list can't be null");
assertNotNull(newDirectives, () -> "directive list can't be null");
Expand All @@ -80,6 +86,7 @@ public static List<GraphQLDirective> addAll(List<GraphQLDirective> targetList, L
}

@Deprecated // use GraphQLAppliedDirectives eventually
@DeprecatedAt("2022-02-24")
public static GraphQLDirective getFirstDirective(String name, Map<String, List<GraphQLDirective>> allDirectivesByName) {
List<GraphQLDirective> directives = allDirectivesByName.getOrDefault(name, emptyList());
if (directives.isEmpty()) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/graphql/ExecutionInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public String getOperationName() {
* @deprecated - use {@link #getGraphQLContext()}
*/
@Deprecated
@DeprecatedAt("2021-07-05")
public Object getContext() {
return context;
}
Expand Down Expand Up @@ -124,6 +125,7 @@ public DataLoaderRegistry getDataLoaderRegistry() {
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public CacheControl getCacheControl() {
return cacheControl;
}
Expand Down Expand Up @@ -227,6 +229,7 @@ public static class Builder {
// dataloader field tracking away.
//
private DataLoaderRegistry dataLoaderRegistry = DataLoaderDispatcherInstrumentationState.EMPTY_DATALOADER_REGISTRY;
@DeprecatedAt("2022-07-26")
private CacheControl cacheControl = CacheControl.newCacheControl();
private Locale locale = Locale.getDefault();
private ExecutionId executionId;
Expand Down Expand Up @@ -287,6 +290,7 @@ public Builder localContext(Object localContext) {
* @deprecated - the {@link ExecutionInput#getGraphQLContext()} is a fixed mutable instance now
*/
@Deprecated
@DeprecatedAt("2021-07-05")
public Builder context(Object context) {
this.context = context;
return this;
Expand All @@ -302,6 +306,7 @@ public Builder context(Object context) {
* @deprecated - the {@link ExecutionInput#getGraphQLContext()} is a fixed mutable instance now
*/
@Deprecated
@DeprecatedAt("2021-07-05")
public Builder context(GraphQLContext.Builder contextBuilder) {
this.context = contextBuilder.build();
return this;
Expand All @@ -317,6 +322,7 @@ public Builder context(GraphQLContext.Builder contextBuilder) {
* @deprecated - the {@link ExecutionInput#getGraphQLContext()} is a fixed mutable instance now
*/
@Deprecated
@DeprecatedAt("2021-07-05")
public Builder context(UnaryOperator<GraphQLContext.Builder> contextBuilderFunction) {
GraphQLContext.Builder builder = GraphQLContext.newContext();
builder = contextBuilderFunction.apply(builder);
Expand Down Expand Up @@ -394,6 +400,7 @@ public Builder dataLoaderRegistry(DataLoaderRegistry dataLoaderRegistry) {
}

@Deprecated
@DeprecatedAt("2022-07-26")
public Builder cacheControl(CacheControl cacheControl) {
this.cacheControl = assertNotNull(cacheControl);
return this;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/graphql/GraphQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ public ExecutionResult execute(String query) {
* @deprecated Use {@link #execute(ExecutionInput)}
*/
@Deprecated
@DeprecatedAt("2017-06-02")
public ExecutionResult execute(String query, Object context) {
ExecutionInput executionInput = ExecutionInput.newExecutionInput()
.query(query)
Expand All @@ -356,6 +357,7 @@ public ExecutionResult execute(String query, Object context) {
* @deprecated Use {@link #execute(ExecutionInput)}
*/
@Deprecated
@DeprecatedAt("2017-06-02")
public ExecutionResult execute(String query, String operationName, Object context) {
ExecutionInput executionInput = ExecutionInput.newExecutionInput()
.query(query)
Expand All @@ -378,6 +380,7 @@ public ExecutionResult execute(String query, String operationName, Object contex
* @deprecated Use {@link #execute(ExecutionInput)}
*/
@Deprecated
@DeprecatedAt("2017-06-02")
public ExecutionResult execute(String query, Object context, Map<String, Object> variables) {
ExecutionInput executionInput = ExecutionInput.newExecutionInput()
.query(query)
Expand All @@ -401,6 +404,7 @@ public ExecutionResult execute(String query, Object context, Map<String, Object>
* @deprecated Use {@link #execute(ExecutionInput)}
*/
@Deprecated
@DeprecatedAt("2017-06-02")
public ExecutionResult execute(String query, String operationName, Object context, Map<String, Object> variables) {
ExecutionInput executionInput = ExecutionInput.newExecutionInput()
.query(query)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/graphql/TypeResolutionEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public GraphQLSchema getSchema() {
* @deprecated use {@link #getGraphQLContext()} instead
*/
@Deprecated
@DeprecatedAt("2021-12-27")
public <T> T getContext() {
//noinspection unchecked
return (T) context;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/graphql/cachecontrol/CacheControl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package graphql.cachecontrol;

import graphql.DeprecatedAt;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.ExecutionResultImpl;
Expand Down Expand Up @@ -34,6 +35,7 @@
* extensions map as per the specification.
*/
@Deprecated
@DeprecatedAt("2022-07-26")
@PublicApi
public class CacheControl {

Expand Down Expand Up @@ -91,6 +93,7 @@ private CacheControl() {
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public CacheControl hint(ResultPath path, Integer maxAge, Scope scope) {
assertNotNull(path);
assertNotNull(scope);
Expand All @@ -108,6 +111,7 @@ public CacheControl hint(ResultPath path, Integer maxAge, Scope scope) {
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public CacheControl hint(ResultPath path, Scope scope) {
return hint(path, null, scope);
}
Expand All @@ -122,6 +126,7 @@ public CacheControl hint(ResultPath path, Scope scope) {
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public CacheControl hint(ResultPath path, Integer maxAge) {
return hint(path, maxAge, Scope.PUBLIC);
}
Expand All @@ -137,6 +142,7 @@ public CacheControl hint(ResultPath path, Integer maxAge) {
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, Integer maxAge, Scope scope) {
assertNotNull(dataFetchingEnvironment);
assertNotNull(scope);
Expand All @@ -154,6 +160,7 @@ public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, Intege
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, Integer maxAge) {
hint(dataFetchingEnvironment, maxAge, Scope.PUBLIC);
return this;
Expand All @@ -169,6 +176,7 @@ public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, Intege
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, Scope scope) {
return hint(dataFetchingEnvironment, null, scope);
}
Expand All @@ -181,6 +189,7 @@ public CacheControl hint(DataFetchingEnvironment dataFetchingEnvironment, Scope
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public static CacheControl newCacheControl() {
return new CacheControl();
}
Expand All @@ -195,6 +204,7 @@ public static CacheControl newCacheControl() {
* @deprecated - Apollo has deprecated the Cache Control specification
*/
@Deprecated
@DeprecatedAt("2022-07-26")
public ExecutionResult addTo(ExecutionResult executionResult) {
return ExecutionResultImpl.newExecutionResult()
.from(executionResult)
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/graphql/collect/ImmutableMapWithNullValues.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graphql.collect;

import graphql.Assert;
import graphql.DeprecatedAt;
import graphql.Internal;

import java.util.Collection;
Expand Down Expand Up @@ -82,24 +83,28 @@ public V get(Object key) {

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V put(K key, V value) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V remove(Object key) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public void putAll(Map<? extends K, ? extends V> m) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public void clear() {
throw new UnsupportedOperationException();
}
Expand Down Expand Up @@ -141,54 +146,63 @@ public void forEach(BiConsumer<? super K, ? super V> action) {

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V putIfAbsent(K key, V value) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public boolean remove(Object key, Object value) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public boolean replace(K key, V oldValue, V newValue) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V replace(K key, V value) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
@DeprecatedAt("2020-11-10")
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package graphql.execution;

import graphql.DeprecatedAt;
import graphql.ExecutionResult;
import graphql.PublicSpi;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

/**
* This is called when an exception is thrown during {@link graphql.schema.DataFetcher#get(DataFetchingEnvironment)} execution
Expand All @@ -27,6 +27,7 @@ public interface DataFetcherExceptionHandler {
* version
*/
@Deprecated
@DeprecatedAt("2021-06-23")
default DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandlerParameters handlerParameters) {
return SimpleDataFetcherExceptionHandler.defaultImpl.onException(handlerParameters);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/graphql/execution/DataFetcherResult.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graphql.execution;

import com.google.common.collect.ImmutableList;
import graphql.DeprecatedAt;
import graphql.GraphQLError;
import graphql.Internal;
import graphql.PublicApi;
Expand Down Expand Up @@ -41,6 +42,7 @@ public class DataFetcherResult<T> {
*/
@Internal
@Deprecated
@DeprecatedAt("2019-01-11")
public DataFetcherResult(T data, List<GraphQLError> errors) {
this(data, errors, null);
}
Expand Down
Loading