graphql-stitch
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,1 +0,1 @@ | ||
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({uri:a,context:b}){let c=g.ApolloLink.from([new h.RetryLink({max:6,delay:300,interval:(a,b)=>b*b*a}),new f.HttpLink({uri:a,fetch:k.default})]);return b&&(c=(0,i.setContext)(b).concat(c)),c}Object.defineProperty(b,'__esModule',{value:!0}),b.stitch=async function({remotes:c=[],locals:f=[],resolvers:a,context:b,linkBuilder:g=d}){c=c.map((a)=>'string'==typeof a?g({uri:a,context:b}):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=c(6),k=function(a){return a&&a.__esModule?a:{default:a}}(j)},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('apollo-link-context')},function(a){a.exports=require('node-fetch')}]); | ||
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')}]); |
{ | ||
"name": "graphql-stitch", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "inspect and stitch remote graphql schemas with local ones", | ||
@@ -35,3 +35,2 @@ "main": "dist/bundle.js", | ||
"apollo-link": "^1.0.0", | ||
"apollo-link-context": "^1.0.3", | ||
"apollo-link-http": "^1.1.0", | ||
@@ -38,0 +37,0 @@ "apollo-link-retry": "^1.0.0", |
@@ -6,7 +6,6 @@ import { makeRemoteExecutableSchema, mergeSchemas, introspectSchema } from 'graphql-tools'; | ||
import { RetryLink } from "apollo-link-retry"; | ||
import { setContext } from 'apollo-link-context'; | ||
import fetch from 'node-fetch'; | ||
function defaultLink({ uri, context }) { | ||
let link = ApolloLink.from([ | ||
function defaultLink(uri) { | ||
return ApolloLink.from([ | ||
new RetryLink({ | ||
@@ -19,12 +18,16 @@ max: 6, | ||
]); | ||
if (context) { | ||
link = setContext(context).concat(link); | ||
} | ||
return link; | ||
}; | ||
export async function stitch({ remotes = [], locals = [], resolvers, context, linkBuilder = defaultLink }) { | ||
export async function stitch({ remotes = [], locals = [], resolvers, preLink, linkBuilder = defaultLink }) { | ||
remotes = remotes.map(remote => { | ||
if (typeof remote === 'string') return linkBuilder({ uri: remote, context }); | ||
if (typeof remote === 'string') { | ||
remote = linkBuilder({ uri: remote }); | ||
} | ||
if (preLink) { | ||
if (typeof preLink.remote !== 'function') { | ||
throw new Error("option preLink must have method concat"); | ||
} | ||
remote = preLink.concat(remote); | ||
} | ||
return remote; | ||
@@ -31,0 +34,0 @@ }); |
Sorry, the diff of this file is not supported yet
5
93
151313
- Removedapollo-link-context@^1.0.3
- Removedapollo-link-context@1.0.20(transitive)