UNPKG

@rnga/orders

Version:

## Get schema from @prisma-cms 1. yarn get-api-schema -e http://localhost:4000 2. yarn build-api-fragments

109 lines (73 loc) 6.17 kB
'use strict'; exports.__esModule = true; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _class, _temp; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _context = require('@prisma-cms/context'); var _context2 = _interopRequireDefault(_context); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ContextProvider = (_temp = _class = function (_Component) { _inherits(ContextProvider, _Component); function ContextProvider() { _classCallCheck(this, ContextProvider); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } // componentWillMount() { // const { // query, // ...other // } = this.context; // this.newContext = { // query: { // ...query, // ...this.prepareQuery(), // }, // ...other // } // } ContextProvider.prototype.render = function render() { var children = this.props.children; var query = this.context.query; Object.assign(this.context, { query: _extends({}, query, this.prepareQuery()) }); return _react2.default.createElement( _context2.default.Provider, { value: this.context }, children || null ); }; ContextProvider.prototype.prepareQuery = function prepareQuery() { return _extends({}, this.prepareUserQuery()); }; ContextProvider.prototype.prepareUserQuery = function prepareUserQuery() { var queryFragments = this.context.queryFragments; var UserNoNestingFragment = queryFragments.UserNoNestingFragment, BatchPayloadNoNestingFragment = queryFragments.BatchPayloadNoNestingFragment; var usersConnection = '\n query usersConnection (\n $where: UserWhereInput\n $orderBy: UserOrderByInput\n $skip: Int\n $after: String\n $before: String\n $first: Int\n $last: Int\n ){\n objectsConnection: usersConnection (\n where: $where\n orderBy: $orderBy\n skip: $skip\n after: $after\n before: $before\n first: $first\n last: $last\n ){\n aggregate{\n count\n }\n edges{\n node{\n ...UserNoNesting\n }\n }\n }\n }\n\n ' + UserNoNestingFragment + '\n '; var users = '\n query users (\n $where: UserWhereInput\n $orderBy: UserOrderByInput\n $skip: Int\n $after: String\n $before: String\n $first: Int\n $last: Int\n ){\n objects: users (\n where: $where\n orderBy: $orderBy\n skip: $skip\n after: $after\n before: $before\n first: $first\n last: $last\n ){\n ...UserNoNesting\n }\n }\n\n ' + UserNoNestingFragment + '\n '; var user = '\n query user (\n $where: UserWhereUniqueInput!\n ){\n object: user (\n where: $where\n ){\n ...UserNoNesting\n }\n }\n\n ' + UserNoNestingFragment + '\n '; var createUserProcessor = '\n mutation createUserProcessor(\n $data: UserCreateInput!\n ) {\n response: createUserProcessor(\n data: $data\n ){\n success\n message\n errors{\n key\n message\n }\n data{\n ...UserNoNesting\n }\n }\n }\n\n ' + UserNoNestingFragment + '\n '; var updateUserProcessor = '\n mutation updateUserProcessor(\n $data: UserUpdateInput!\n $where: UserWhereUniqueInput!\n ) {\n response: updateUserProcessor(\n data: $data\n where: $where\n ){\n success\n message\n errors{\n key\n message\n }\n data{\n ...UserNoNesting\n }\n }\n }\n\n ' + UserNoNestingFragment + '\n '; var deleteUser = '\n mutation deleteUser (\n $where: UserWhereUniqueInput!\n ){\n deleteUser(\n where: $where\n ){\n ...UserNoNesting\n }\n }\n ' + UserNoNestingFragment + '\n '; var deleteManyUsers = '\n mutation deleteManyUsers (\n $where: UserWhereInput\n ){\n deleteManyUsers(\n where: $where\n ){\n ...BatchPayloadNoNesting\n }\n }\n ' + BatchPayloadNoNestingFragment + '\n '; return { usersConnection: usersConnection, users: users, user: user, createUserProcessor: createUserProcessor, updateUserProcessor: updateUserProcessor, deleteUser: deleteUser, deleteManyUsers: deleteManyUsers }; }; return ContextProvider; }(_react.Component), _class.contextType = _context2.default, _temp); exports.default = ContextProvider; module.exports = exports['default'];