-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(main in package selecting correct folder): fix in main so that it…
… is usable within your project
- Loading branch information
1 parent
5d55cb9
commit 9cf087d
Showing
5 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reachWithDispatch = exports.reachGraphQL = undefined; | ||
|
||
var _reachGraphQL = require('./reachGraphQL.js'); | ||
|
||
var _reachWithDispatch = require('./reachWithDispatch.js'); | ||
|
||
exports.reachGraphQL = _reachGraphQL.reachGraphQL; | ||
exports.reachWithDispatch = _reachWithDispatch.reachWithDispatch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reachGraphQL = reachGraphQL; | ||
|
||
var _transport = require("./utils/transport.js"); | ||
|
||
require("babel-polyfill"); | ||
|
||
/** | ||
* [reachGraphQL Makes queres or mutations against GraphQL] | ||
* @param {[String]} path [path to the GraphQL server] | ||
* @param {[Object]} query [The query that GraphQL will use to fetch your data] | ||
* @param {[object]} queryParams = {} [should contain object with different query params] | ||
* @return {[Object]} [Data that was queried or qutated] | ||
*/ | ||
function reachGraphQL(path, query) { | ||
var queryParams = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
|
||
return function _callee() { | ||
var response; | ||
return regeneratorRuntime.async(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.prev = 0; | ||
_context.next = 3; | ||
return regeneratorRuntime.awrap((0, _transport.transport)(path, query, queryParams)); | ||
|
||
case 3: | ||
response = _context.sent; | ||
return _context.abrupt("return", response.data); | ||
|
||
case 7: | ||
_context.prev = 7; | ||
_context.t0 = _context["catch"](0); | ||
|
||
console.log(_context.t0); | ||
|
||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, null, this, [[0, 7]]); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.reachWithDispatch = reachWithDispatch; | ||
|
||
var _transport = require("./utils/transport.js"); | ||
|
||
require("babel-polyfill"); | ||
|
||
/** | ||
* [reachWithDispatch description] | ||
* @param {[String]} path [path to the GraphQL server] | ||
* @param {[Object]} query [The query that GraphQL will use to fetch your data] | ||
* @param {[object]} queryParams = {} [should contain object with different query params] | ||
* @param {[type]} actionCreator = ( [The actionCreator to dispatch] | ||
* @return {[function]} [dispatch to store] | ||
*/ | ||
function reachWithDispatch(path, query) { | ||
var queryParams = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var actionCreator = arguments.length <= 3 || arguments[3] === undefined ? function () {} : arguments[3]; | ||
|
||
return function _callee(dispatch) { | ||
var response; | ||
return regeneratorRuntime.async(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.prev = 0; | ||
_context.next = 3; | ||
return regeneratorRuntime.awrap((0, _transport.transport)(path, query, queryParams)); | ||
|
||
case 3: | ||
response = _context.sent; | ||
|
||
dispatch(actionCreator(response.data)); | ||
_context.next = 10; | ||
break; | ||
|
||
case 7: | ||
_context.prev = 7; | ||
_context.t0 = _context["catch"](0); | ||
|
||
console.log(_context.t0); | ||
|
||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, null, this, [[0, 7]]); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.transport = transport; | ||
|
||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
|
||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function transport(path, query) { | ||
var queryParams = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
|
||
var url = path; | ||
return new Promise(function (resolve, reject) { | ||
(0, _isomorphicFetch2.default)(url, { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
query: query, | ||
queryParams: queryParams | ||
}) | ||
}).then(function (res) { | ||
return res.json(); | ||
}).then(function (response) { | ||
if (response.errors) { | ||
return reject(response.errors); | ||
} | ||
return resolve(response.data); | ||
}).catch(response.error); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters