graphql-stitch
Advanced tools
Comparing version 1.0.5 to 1.1.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(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:b=[],locals:c=[],resolvers:a}){b=b.map((a)=>'string'==typeof a?d(a):a);const f=await Promise.all(b.map(async(a)=>(0,e.makeRemoteExecutableSchema)({schema:await(0,e.introspectSchema)(a),link:a})));return(0,e.mergeSchemas)({schemas:[...f,...c],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(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')}]); |
{ | ||
"name": "graphql-stitch", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "inspect and stitch remote graphql schemas with local ones", | ||
@@ -35,2 +35,3 @@ "main": "dist/bundle.js", | ||
"apollo-link": "^1.0.0", | ||
"apollo-link-context": "^1.0.3", | ||
"apollo-link-http": "^1.1.0", | ||
@@ -37,0 +38,0 @@ "apollo-link-retry": "^1.0.0", |
@@ -6,6 +6,7 @@ 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) { | ||
return ApolloLink.from([ | ||
function defaultLink({ uri, context }) { | ||
let link = ApolloLink.from([ | ||
new RetryLink({ | ||
@@ -18,8 +19,12 @@ max: 6, | ||
]); | ||
if (context) { | ||
link = setContext(context).concat(link); | ||
} | ||
return link; | ||
}; | ||
export async function stitch({ remotes = [], locals = [], resolvers }) { | ||
export async function stitch({ remotes = [], locals = [], resolvers, context, linkBuilder = defaultLink }) { | ||
remotes = remotes.map(remote => { | ||
if (typeof remote === 'string') return defaultLink(remote); | ||
if (typeof remote === 'string') return linkBuilder({ uri: remote, context }); | ||
return remote; | ||
@@ -26,0 +31,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
151534
90
6
+ Addedapollo-link-context@^1.0.3
+ Addedapollo-link-context@1.0.20(transitive)