title: Spring Boot GraphQL file upload services does not work after moving the code inside the controller
body: <p>I have written a class in Spring Boot that implements GraphQLMutationResolver in which I have written a mutation function that is responsible for handling file upload. The code is given below:</p>
  <pre><code>package com.example.demo.resolver;
  
  
  
  import org.springframework.stereotype.Component;
  
  import graphql.kickstart.servlet.context.DefaultGraphQLServletContext;
  import graphql.kickstart.tools.GraphQLMutationResolver;
  import graphql.schema.DataFetchingEnvironment;
  
  @Component
  public class UploadFileMutation implements GraphQLMutationResolver {
      
  
      public String uploadFile(DataFetchingEnvironment environment) {
          DefaultGraphQLServletContext defaultGraphQLServletContext = environment.getContext();
          defaultGraphQLServletContext.getFileParts().forEach(part -&gt; {
              System.out.println(&quot;uploading: {} &quot; + part.getSubmittedFileName() + &quot; size: {} &quot; + part.getSize());
          });
          
          return &quot;File uploaded successfully.&quot;;
      }
  
  }
  
  </code></pre>
  <p>The above code works correctly but now, I have decided to move this code to the controller and now my code is this</p>
  <pre><code>@MutationMapping
      public String uploadFile(DataFetchingEnvironment environment) {
              DefaultGraphQLServletContext defaultGraphQLServletContext = environment.getContext();
              defaultGraphQLServletContext.getFileParts().forEach(part -&gt; {
                  System.out.println(&quot;uploading: {} &quot; + part.getSubmittedFileName() + &quot; size: {} &quot; + part.getSize());
              });
              
              return &quot;File uploaded successfully.&quot;;
  }
  </code></pre>
  <p>But the problem is that now when I try to hit server using postman, I am getting this error</p>
  <p><a href="https://i.stack.imgur.com/FK4vG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FK4vG.png" alt="enter image description here" /></a></p>
  <p>I am unable to determine how to solve this issue.</p>