Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-stitch

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-stitch - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

236

dist/bundle.js

@@ -1,1 +0,235 @@

require('source-map-support').install(),module.exports=function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:d})},b.n=function(a){var c=a&&a.__esModule?function(){return a['default']}:function(){return a};return b.d(c,'a',c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p='',b(b.s=0)}([function(a,b,c){'use strict';function d(a){return g.ApolloLink.from([new h.RetryLink({max:6,delay:300,interval:(a,b)=>b*b*a}),new f.HttpLink({uri:a,fetch:j.default})])}Object.defineProperty(b,'__esModule',{value:!0}),b.stitch=async function({remotes:c=[],locals:f=[],resolvers:a,preLink:b,linkBuilder:g=d}){c=c.map((a)=>{if('string'==typeof a&&(a=g({uri:a})),b){if('function'!=typeof b.remote)throw new Error('option preLink must have method concat');a=b.concat(a)}return a});const h=await Promise.all(c.map(async(a)=>(0,e.makeRemoteExecutableSchema)({schema:await(0,e.introspectSchema)(a),link:a})));return(0,e.mergeSchemas)({schemas:[...h,...f],resolvers:a})};var e=c(1),f=c(2),g=c(3),h=c(4),i=c(5),j=function(a){return a&&a.__esModule?a:{default:a}}(i)},function(a){a.exports=require('graphql-tools')},function(a){a.exports=require('apollo-link-http')},function(a){a.exports=require('apollo-link')},function(a){a.exports=require('apollo-link-retry')},function(a){a.exports=require('node-fetch')}]);
require("source-map-support").install();
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(1);
module.exports = __webpack_require__(2);
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = require("babel-polyfill");
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.stitch = undefined;
var stitch = exports.stitch = function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref) {
var _this = this;
var _ref$remotes = _ref.remotes,
remotes = _ref$remotes === undefined ? [] : _ref$remotes,
_ref$locals = _ref.locals,
locals = _ref$locals === undefined ? [] : _ref$locals,
resolvers = _ref.resolvers,
preLink = _ref.preLink,
_ref$linkBuilder = _ref.linkBuilder,
linkBuilder = _ref$linkBuilder === undefined ? defaultLink : _ref$linkBuilder;
var schemas;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
remotes = remotes.map(function (remote) {
if (typeof remote === 'string') {
remote = linkBuilder(remote);
}
if (preLink) {
if (typeof preLink.concat !== 'function') {
throw new Error("option preLink must have method concat");
}
remote = preLink.concat(remote);
}
return remote;
});
_context2.next = 3;
return Promise.all(remotes.map(function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(link) {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.t0 = _graphqlTools.makeRemoteExecutableSchema;
_context.next = 3;
return (0, _graphqlTools.introspectSchema)(link);
case 3:
_context.t1 = _context.sent;
_context.t2 = link;
_context.t3 = {
schema: _context.t1,
link: _context.t2
};
return _context.abrupt('return', (0, _context.t0)(_context.t3));
case 7:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}));
return function (_x2) {
return _ref3.apply(this, arguments);
};
}()));
case 3:
schemas = _context2.sent;
return _context2.abrupt('return', (0, _graphqlTools.mergeSchemas)({ schemas: [].concat(_toConsumableArray(schemas), _toConsumableArray(locals)), resolvers: resolvers }));
case 5:
case 'end':
return _context2.stop();
}
}
}, _callee2, this);
}));
return function stitch(_x) {
return _ref2.apply(this, arguments);
};
}();
var _graphqlTools = __webpack_require__(3);
var _apolloLinkHttp = __webpack_require__(4);
var _apolloLink = __webpack_require__(5);
var _apolloLinkRetry = __webpack_require__(6);
var _nodeFetch = __webpack_require__(7);
var _nodeFetch2 = _interopRequireDefault(_nodeFetch);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function defaultLink(uri) {
return _apolloLink.ApolloLink.from([new _apolloLinkRetry.RetryLink({
max: 6,
delay: 300,
interval: function interval(delay, count) {
return count * count * delay;
}
}), new _apolloLinkHttp.HttpLink({ uri: uri, fetch: _nodeFetch2.default })]);
};
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = require("graphql-tools");
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = require("apollo-link-http");
/***/ }),
/* 5 */
/***/ (function(module, exports) {
module.exports = require("apollo-link");
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = require("apollo-link-retry");
/***/ }),
/* 7 */
/***/ (function(module, exports) {
module.exports = require("node-fetch");
/***/ })
/******/ ]);
//# sourceMappingURL=bundle.js.map

13

package.json
{
"name": "graphql-stitch",
"version": "1.2.0",
"version": "1.2.1",
"description": "inspect and stitch remote graphql schemas with local ones",

@@ -13,3 +13,3 @@ "main": "dist/bundle.js",

"watch": "npm-run-all --parallel build:watch test:watch",
"test": "mocha tests/ --require babel-core/register --recursive",
"test": "mocha tests/ --require babel-core/register --require babel-polyfill --recursive",
"test:watch": "yarn test -- --watch",

@@ -35,8 +35,9 @@ "prepublish": "yarn run build"

"dependencies": {
"apollo-link": "^1.0.0",
"apollo-link-http": "^1.1.0",
"apollo-link-retry": "^1.0.0",
"graphql-tools": "^2.7.2",
"apollo-link": "^1.0.6",
"apollo-link-http": "^1.3.1",
"apollo-link-retry": "^2.0.0",
"babel-polyfill": "^6.26.0",
"graphql-tools": "^2.12.0",
"node-fetch": "^1.7.3"
}
}

@@ -23,6 +23,6 @@ import { makeRemoteExecutableSchema, mergeSchemas, introspectSchema } from 'graphql-tools';

if (typeof remote === 'string') {
remote = linkBuilder({ uri: remote });
remote = linkBuilder(remote);
}
if (preLink) {
if (typeof preLink.remote !== 'function') {
if (typeof preLink.concat !== 'function') {
throw new Error("option preLink must have method concat");

@@ -29,0 +29,0 @@ }

@@ -7,14 +7,20 @@

it('should stitch remote schemas', async function () {
const schema = await stitch({ remotes: ['http://graphql.communitygraph.org/graphql/'] });
this.timeout(10000);
const schema = await stitch({ remotes: ['http://fake.graphql.guru/graphql'] });
const query =
`{
Answer {
Fake {
_id
firstName
lastName
}
}`;
const result = await graphql(schema, query);
const { data, errors } = await graphql(schema, query, {});
console.log(result);
expect(errors).not.to.be.ok;
expect(data).to.have.nested.property('Fake._id');
expect(data).to.have.nested.property('Fake.firstName');
expect(data).to.have.nested.property('Fake.lastName');
});

@@ -21,0 +27,0 @@

@@ -7,3 +7,3 @@ var webpack = require('webpack');

module.exports = env => ({
entry: './src/index.js',
entry: ['babel-polyfill', './src/index.js'],
target: 'node',

@@ -34,9 +34,9 @@ output: {

}),
new MinifyPlugin({}, {
sourceMap: new webpack.SourceMapDevToolPlugin({
filename: 'bundle.js.map'
})
}),
// new MinifyPlugin({}, {
// sourceMap: new webpack.SourceMapDevToolPlugin({
// filename: 'bundle.js.map'
// })
// }),
],
//devtool: env.production ? 'source-map' : 'eval-source-map',
devtool: env.production ? 'source-map' : 'eval-source-map',
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc