2121import graphql .language .OperationDefinition ;
2222import org .dataloader .DataLoader ;
2323import org .dataloader .DataLoaderRegistry ;
24- import org .jspecify .annotations .NonNull ;
24+ import org .jspecify .annotations .NullMarked ;
2525import org .jspecify .annotations .Nullable ;
2626
2727import java .util .List ;
3131
3232@ SuppressWarnings ({"unchecked" , "TypeParameterUnusedInFormals" })
3333@ Internal
34+ @ NullMarked
3435public class DataFetchingEnvironmentImpl implements DataFetchingEnvironment {
3536 private final Object source ;
3637 private final Supplier <Map <String , Object >> arguments ;
@@ -112,6 +113,7 @@ public static Builder newDataFetchingEnvironment(ExecutionContext executionConte
112113 }
113114
114115 @ Override
116+ @ Nullable
115117 public <T > T getSource () {
116118 return (T ) source ;
117119 }
@@ -127,7 +129,7 @@ public boolean containsArgument(String name) {
127129 }
128130
129131 @ Override
130- public <T > T getArgument (String name ) {
132+ public @ Nullable <T > T getArgument (String name ) {
131133 return (T ) arguments .get ().get (name );
132134 }
133135
@@ -137,12 +139,12 @@ public <T> T getArgumentOrDefault(String name, T defaultValue) {
137139 }
138140
139141 @ Override
140- public <T > T getContext () {
142+ public @ Nullable <T > T getContext () {
141143 return (T ) context ;
142144 }
143145
144146 @ Override
145- public @ NonNull GraphQLContext getGraphQlContext () {
147+ public GraphQLContext getGraphQlContext () {
146148 return graphQLContext ;
147149 }
148150
@@ -152,7 +154,7 @@ public <T> T getContext() {
152154 }
153155
154156 @ Override
155- public <T > T getRoot () {
157+ public @ Nullable <T > T getRoot () {
156158 return (T ) root ;
157159 }
158160
@@ -333,13 +335,13 @@ public Builder arguments(Supplier<Map<String, Object>> arguments) {
333335 }
334336
335337 @ Deprecated (since = "2021-07-05" )
336- public Builder context (Object context ) {
338+ public Builder context (@ Nullable Object context ) {
337339 this .context = context ;
338340 return this ;
339341 }
340342
341343 public Builder graphQLContext (GraphQLContext context ) {
342- this .graphQLContext = context ;
344+ this .graphQLContext = Assert . assertNotNull ( context , "GraphQLContext cannot be null" ) ;
343345 return this ;
344346 }
345347
0 commit comments