UNPKG

@kiwicom/smart-faq

Version:

62 lines (50 loc) 1.77 kB
"use strict"; require("core-js/modules/es.object.to-string"); require("core-js/modules/es.promise"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _reactRelay = require("react-relay"); var _environment = _interopRequireDefault(require("../../shared/relay/environment")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // @flow var mutation = function mutation() { var node = require("./__generated__/CreateCommentMutation.graphql"); if (node.hash && node.hash !== "d03b041608954e773dd71ec0b7cae92e") { console.error("The definition of 'CreateCommentMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."); } return require("./__generated__/CreateCommentMutation.graphql"); }; var createComment = function createComment(_ref) { var articleId = _ref.articleId, type = _ref.type, comment = _ref.comment; return ( /*: Promise<CreateCommentMutationResponse>*/ new Promise(function (resolve, reject) { var variables = { articleId: articleId, type: type, comment: comment }; (0, _reactRelay.commitMutation)((0, _environment.default)(), { mutation: mutation, variables: variables, onCompleted: function onCompleted(response /*: CreateCommentMutationResponse*/ , errors /*: $ReadOnlyArray<Error>*/ ) { if (errors === null || errors === void 0 ? void 0 : errors.length) { reject(errors[0]); } resolve(response); }, onError: reject }); }) ); }; var _default = createComment; exports.default = _default;