Q:

"undefined method `[]=' for nil:NilClass" with graphql

i'm having this issue when i try to sign in through graphiql, the error that cames out in the console is in the line where:

mutations/sign_in_user.rb:27:in `resolve'"
  context[:session][:token] = token

the configuration for the sign in service is the following:
    module Mutations
        class SignInUser < BaseMutation
        null true

        argument :credentials, Types::AuthProviderCredentialsInput, required: false

        field :token, String, null: true
        field :user, Types::UserType, null: true

        def resolve(credentials: nil)
            # basic validation
            return unless credentials

            user = User.find_by email: credentials[:email]
            puts '---userrr------- ' + user.email.to_s
            return Errors unless user

            # ensures we have the correct user
            return unless user
            return unless user.authenticate(credentials[:password])

            # use Ruby on Rails - ActiveSupport::MessageEncryptor, to build a token
            crypt = ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base.byteslice(0..31))
            token = crypt.encrypt_and_sign("user-id:#{ user.id }")
            puts '---------------- ' + token

            context[:session][:token] = token

            { user: user, token: token }
        end
        end
    end

when i did the same my first time my app was running in rails 5.1.7 but now is running on 6.0, i was wondering if the new version that i'm using right now could affect this configuration.

A:

:D, thanks for the help guys! my mistake was that i did not define the context into controller/graphql -> so within the file i just added this line to define the context object.
  def execute
    variables = ensure_hash(params[:variables])
    query = params[:query]
    operation_name = params[:operationName]
    context = {
      # we need to provide session and current user
      session: session,
      current_user: current_user
    }
    result = AppOneSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
    render json: result
  rescue => e
    raise e unless Rails.env.development?
    handle_error_in_development e
  end

