FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

make DFE more nullable aware by andimarek · Pull Request #4005 · graphql-java/graphql-java · GitHub

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

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import graphql.language.OperationDefinition;
import org.dataloader.DataLoader;
import org.dataloader.DataLoaderRegistry;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

import java.util.List;
Expand All @@ -28,6 +28,7 @@
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
@PublicApi
@NullMarked
public interface DataFetchingEnvironment extends IntrospectionDataFetchingEnvironment {

/**
Expand Down Expand Up @@ -92,6 +93,7 @@ public interface DataFetchingEnvironment extends IntrospectionDataFetchingEnviro
* @deprecated - use {@link #getGraphQlContext()} instead
*/
@Deprecated(since = "2021-07-05")
@Nullable
<T> T getContext();

/**
Expand All @@ -102,7 +104,6 @@ public interface DataFetchingEnvironment extends IntrospectionDataFetchingEnviro
*
* @return can NOT be null
*/
@NonNull
GraphQLContext getGraphQlContext();

/**
Expand Down Expand Up @@ -130,6 +131,7 @@ public interface DataFetchingEnvironment extends IntrospectionDataFetchingEnviro
*
* @return can be null
*/
@Nullable
<T> T getRoot();

/**
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import graphql.language.OperationDefinition;
import org.dataloader.DataLoader;
import org.dataloader.DataLoaderRegistry;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

import java.util.List;
Expand All @@ -31,6 +31,7 @@

@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
@Internal
@NullMarked
public class DataFetchingEnvironmentImpl implements DataFetchingEnvironment {
private final Object source;
private final Supplier<Map<String, Object>> arguments;
Expand Down Expand Up @@ -112,6 +113,7 @@ public static Builder newDataFetchingEnvironment(ExecutionContext executionConte
}

@Override
@Nullable
public <T> T getSource() {
return (T) source;
}
Expand All @@ -127,7 +129,7 @@ public boolean containsArgument(String name) {
}

@Override
public <T> T getArgument(String name) {
public @Nullable <T> T getArgument(String name) {
return (T) arguments.get().get(name);
}

Expand All @@ -137,12 +139,12 @@ public <T> T getArgumentOrDefault(String name, T defaultValue) {
}

@Override
public <T> T getContext() {
public @Nullable <T> T getContext() {
return (T) context;
}

@Override
public @NonNull GraphQLContext getGraphQlContext() {
public GraphQLContext getGraphQlContext() {
return graphQLContext;
}

Expand All @@ -152,7 +154,7 @@ public <T> T getContext() {
}

@Override
public <T> T getRoot() {
public @Nullable <T> T getRoot() {
return (T) root;
}

Expand Down Expand Up @@ -333,13 +335,13 @@ public Builder arguments(Supplier<Map<String, Object>> arguments) {
}

@Deprecated(since = "2021-07-05")
public Builder context(Object context) {
public Builder context(@Nullable Object context) {
this.context = context;
return this;
}

public Builder graphQLContext(GraphQLContext context) {
this.graphQLContext = context;
this.graphQLContext = Assert.assertNotNull(context, "GraphQLContext cannot be null");
return this;
}

Expand Down

Back | FazBrowse Home | New Git URL