Created
January 21, 2018 01:51
-
-
Save eduardojmatos/60919ccdadd7cdf7d6a122fed6348075 to your computer and use it in GitHub Desktop.
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
import graphqlTools from 'graphql-tools'; | |
import serverOneFetcher from './server-fetcher-one'; | |
import serverTwoFetcher from './server-fetcher-two'; | |
import SchemaBuilder from './schema-builder'; | |
import serviceStitching from './stitching-service'; | |
import linkServiceCategorySchema from './link-service-with-category'; | |
const schemas = []; | |
const fetchers = { | |
serverOne: serverOneFetcher, | |
serverTwo: serverTwoFetcher, | |
}; | |
export default async () => { | |
try { | |
await Promise.all( | |
Object.values(fetchers).map(async (fetcher) => { | |
schemas.push(await SchemaBuilder(fetcher)); | |
}), | |
); | |
schemas.push(linkServiceCategorySchema); | |
return graphqlTools.mergeSchemas({ | |
schemas, | |
resolvers: mergeInfo => serviceStitching(mergeInfo), | |
}); | |
} catch (error) { | |
console.log('error:', error); | |
return error; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment