code: def query(self, query, variables=None, timeout=None, metadata=None,
                credentials=None):
          
          new_metadata = self._dg.add_login_metadata(metadata)
          req = self._common_query(query, variables=variables)
          try:
              res = self._dc.query(req, timeout=timeout,
                                   metadata=new_metadata,
                                   credentials=credentials)
          except Exception as error:
              if util.is_jwt_expired(error):
                  self._dg.retry_login()
                  new_metadata = self._dg.add_login_metadata(metadata)
                  res = self._dc.query(req, timeout=timeout,
                                       metadata=new_metadata,
                                       credentials=credentials)
              else:
                  raise error
  
          self.merge_context(res.txn)
          return res
docs: Adds a query operation to the transaction.