/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule RelayMutationRequest
* @typechecks
*
*/
'use strict';
var _inherits = require('babel-runtime/helpers/inherits')['default'];
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var Deferred = require('fbjs/lib/Deferred');
var printRelayQuery = require('./printRelayQuery');
/**
* @internal
*
* Instances of these are made available via `RelayNetworkLayer.requestSubscription`.
*/
var RelaySubscriptionRequest = (function (_Deferred) {
_inherits(RelaySubscriptionRequest, _Deferred);
function RelaySubscriptionRequest(subscription, files) {
_classCallCheck(this, RelaySubscriptionRequest);
_Deferred.call(this);
this._subscription = subscription;
this._printedQuery = null;
this._files = files;
}
/**
* @public
*
* Gets a string name used to refer to this request for printing debug output.
*/
RelaySubscriptionRequest.prototype.getDebugName = function getDebugName() {
return this._subscription.getName();
};
/**
* @public
*
* Gets the variables used by the subscription. These variables should be
* serialized and sent in the GraphQL request.
*/
RelaySubscriptionRequest.prototype.getVariables = function getVariables() {
var printedQuery = this._printedQuery;
if (!printedQuery) {
printedQuery = printRelayQuery(this._subscription);
this._printedQuery = printedQuery;
}
return printedQuery.variables;
};
/**
* @public
*
* Gets a string representation of the GraphQL mutation.
*/
RelaySubscriptionRequest.prototype.getQueryString = function getQueryString() {
var printedQuery = this._printedQuery;
if (!printedQuery) {
printedQuery = printRelayQuery(this._subscription);
this._printedQuery = printedQuery;
}
return printedQuery.text;
};
/**
* @public
* @unstable
*/
RelaySubscriptionRequest.prototype.getSubscription = function getSubscription() {
return this._subscription;
};
/**
* @public
*
* Called by the network layer whenever data is received from the server for this subscription.
*/
RelaySubscriptionRequest.prototype.onNext = function onNext(data) {}
// stub
/**
* @public
*
* Called by the network layer if an error occurs. This ends the subscription.
*/
;
RelaySubscriptionRequest.prototype.onError = function onError(err) {
// stub
};
return RelaySubscriptionRequest;
})(Deferred);
module.exports = RelaySubscriptionRequest;