Improve Execution input nullability by andimarek · Pull Request #4046 · graphql-java/graphql-java
Expand Up
@@ -4,6 +4,9 @@
import graphql.execution.ExecutionId;
import graphql.execution.RawVariables;
import org.dataloader.DataLoaderRegistry;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;
import java.util.Locale; import java.util.Map; Expand All @@ -17,6 +20,7 @@ * This represents the series of values that can be input on a graphql query execution */ @PublicApi @NullMarked public class ExecutionInput { private final String query; private final String operationName; Expand Down Expand Up @@ -58,6 +62,7 @@ public String getQuery() { /** * @return the name of the query operation */ @Nullable public String getOperationName() { return operationName; } Expand All @@ -71,6 +76,7 @@ public String getOperationName() { * @deprecated - use {@link #getGraphQLContext()} */ @Deprecated(since = "2021-07-05") @Nullable public Object getContext() { return context; } Expand All @@ -85,13 +91,15 @@ public GraphQLContext getGraphQLContext() { /** * @return the local context object to pass to all top level (i.e. query, mutation, subscription) data fetchers */ @Nullable public Object getLocalContext() { return localContext; }
/** * @return the root object to start the query execution on */ @Nullable public Object getRoot() { return root; } Expand Down Expand Up @@ -119,12 +127,27 @@ public DataLoaderRegistry getDataLoaderRegistry() {
/** * This value can be null before the execution starts, but once the execution starts, it will be set to a non-null value. * See #getExecutionIdNonNull() for a non-null version of this. * * @return Id that will be/was used to execute this operation. */ @Nullable public ExecutionId getExecutionId() { return executionId; }
/** * Once the execution starts, GraphQL Java will make sure that this execution id is non-null. * Therefore use this method if you are sue that the execution has started to get a guaranteed non-null execution id. * * @return the non null execution id of this operation. */ public ExecutionId getExecutionIdNonNull() { return Assert.assertNotNull(this.executionId); }
/** * This returns the locale of this operation. * Expand Down Expand Up @@ -224,6 +247,7 @@ public static Builder newExecutionInput(String query) { return new Builder().query(query); }
@NullUnmarked public static class Builder {
private String query; Expand All @@ -245,6 +269,7 @@ public static class Builder {
/** * Package level access to the graphql context * * @return shhh but it's the graphql context */ GraphQLContext graphQLContext() { Expand Down Expand Up @@ -312,7 +337,7 @@ public Builder context(Object context) { return this; }
/** /** * This will give you a builder of {@link GraphQLContext} and any values you set will be copied * into the underlying {@link GraphQLContext} of this execution input * Expand Down
import java.util.Locale; import java.util.Map; Expand All @@ -17,6 +20,7 @@ * This represents the series of values that can be input on a graphql query execution */ @PublicApi @NullMarked public class ExecutionInput { private final String query; private final String operationName; Expand Down Expand Up @@ -58,6 +62,7 @@ public String getQuery() { /** * @return the name of the query operation */ @Nullable public String getOperationName() { return operationName; } Expand All @@ -71,6 +76,7 @@ public String getOperationName() { * @deprecated - use {@link #getGraphQLContext()} */ @Deprecated(since = "2021-07-05") @Nullable public Object getContext() { return context; } Expand All @@ -85,13 +91,15 @@ public GraphQLContext getGraphQLContext() { /** * @return the local context object to pass to all top level (i.e. query, mutation, subscription) data fetchers */ @Nullable public Object getLocalContext() { return localContext; }
/** * @return the root object to start the query execution on */ @Nullable public Object getRoot() { return root; } Expand Down Expand Up @@ -119,12 +127,27 @@ public DataLoaderRegistry getDataLoaderRegistry() {
/** * This value can be null before the execution starts, but once the execution starts, it will be set to a non-null value. * See #getExecutionIdNonNull() for a non-null version of this. * * @return Id that will be/was used to execute this operation. */ @Nullable public ExecutionId getExecutionId() { return executionId; }
/** * Once the execution starts, GraphQL Java will make sure that this execution id is non-null. * Therefore use this method if you are sue that the execution has started to get a guaranteed non-null execution id. * * @return the non null execution id of this operation. */ public ExecutionId getExecutionIdNonNull() { return Assert.assertNotNull(this.executionId); }
/** * This returns the locale of this operation. * Expand Down Expand Up @@ -224,6 +247,7 @@ public static Builder newExecutionInput(String query) { return new Builder().query(query); }
@NullUnmarked public static class Builder {
private String query; Expand All @@ -245,6 +269,7 @@ public static class Builder {
/** * Package level access to the graphql context * * @return shhh but it's the graphql context */ GraphQLContext graphQLContext() { Expand Down Expand Up @@ -312,7 +337,7 @@ public Builder context(Object context) { return this; }
/** /** * This will give you a builder of {@link GraphQLContext} and any values you set will be copied * into the underlying {@link GraphQLContext} of this execution input * Expand Down