44import graphql .execution .ExecutionId ;
55import graphql .execution .RawVariables ;
66import org .dataloader .DataLoaderRegistry ;
7+ import org .jspecify .annotations .NullMarked ;
8+ import org .jspecify .annotations .NullUnmarked ;
9+ import org .jspecify .annotations .Nullable ;
710
811import java .util .Locale ;
912import java .util .Map ;
1720 * This represents the series of values that can be input on a graphql query execution
1821 */
1922@ PublicApi
23+ @ NullMarked
2024public class ExecutionInput {
2125 private final String query ;
2226 private final String operationName ;
@@ -58,6 +62,7 @@ public String getQuery() {
5862 /**
5963 * @return the name of the query operation
6064 */
65+ @ Nullable
6166 public String getOperationName () {
6267 return operationName ;
6368 }
@@ -71,6 +76,7 @@ public String getOperationName() {
7176 * @deprecated - use {@link #getGraphQLContext()}
7277 */
7378 @ Deprecated (since = "2021-07-05" )
79+ @ Nullable
7480 public Object getContext () {
7581 return context ;
7682 }
@@ -85,13 +91,15 @@ public GraphQLContext getGraphQLContext() {
8591 /**
8692 * @return the local context object to pass to all top level (i.e. query, mutation, subscription) data fetchers
8793 */
94+ @ Nullable
8895 public Object getLocalContext () {
8996 return localContext ;
9097 }
9198
9299 /**
93100 * @return the root object to start the query execution on
94101 */
102+ @ Nullable
95103 public Object getRoot () {
96104 return root ;
97105 }
@@ -119,12 +127,27 @@ public DataLoaderRegistry getDataLoaderRegistry() {
119127
120128
121129 /**
130+ * This value can be null before the execution starts, but once the execution starts, it will be set to a non-null value.
131+ * See #getExecutionIdNonNull() for a non-null version of this.
132+ *
122133 * @return Id that will be/was used to execute this operation.
123134 */
135+ @ Nullable
124136 public ExecutionId getExecutionId () {
125137 return executionId ;
126138 }
127139
140+
141+ /**
142+ * Once the execution starts, GraphQL Java will make sure that this execution id is non-null.
143+ * Therefore use this method if you are sue that the execution has started to get a guaranteed non-null execution id.
144+ *
145+ * @return the non null execution id of this operation.
146+ */
147+ public ExecutionId getExecutionIdNonNull () {
148+ return Assert .assertNotNull (this .executionId );
149+ }
150+
128151 /**
129152 * This returns the locale of this operation.
130153 *
@@ -224,6 +247,7 @@ public static Builder newExecutionInput(String query) {
224247 return new Builder ().query (query );
225248 }
226249
250+ @ NullUnmarked
227251 public static class Builder {
228252
229253 private String query ;
@@ -245,6 +269,7 @@ public static class Builder {
245269
246270 /**
247271 * Package level access to the graphql context
272+ *
248273 * @return shhh but it's the graphql context
249274 */
250275 GraphQLContext graphQLContext () {
@@ -312,7 +337,7 @@ public Builder context(Object context) {
312337 return this ;
313338 }
314339
315- /**
340+ /**
316341 * This will give you a builder of {@link GraphQLContext} and any values you set will be copied
317342 * into the underlying {@link GraphQLContext} of this execution input
318343 *
0 commit comments