title: Understanding 'context' in GraphQL - Ruby on Rails
body: <p>I am reading GraphQL mutation part, and I do not understand what is <code>context</code> in this part, and what <code>context[:current_user]</code> returns</p>
  
  <p>This is the sample code:</p>
  
  <pre class="lang-rb prettyprint-override"><code>class Mutations::PromoteEmployee &lt; Mutations::BaseMutation
    def ready?(**args)
      # Called with mutation args.
      # Use keyword args such as employee_id: or **args to collect them
      if !context[:current_user].admin?
        raise GraphQL::ExecutionError, "Only admins can run this mutation"
      else
        # Return true to continue the mutation:
        true
      end
    end
  
    # ...
  end
  </code></pre>
  
  <p>This is guides link: <a href="https://graphql-ruby.org/mutations/mutation_authorization.html" rel="nofollow noreferrer">https://graphql-ruby.org/mutations/mutation_authorization.html</a></p>