Skip to content

Instantly share code, notes, and snippets.

@eduardojmatos
Created January 21, 2018 01:51
Show Gist options
  • Save eduardojmatos/60919ccdadd7cdf7d6a122fed6348075 to your computer and use it in GitHub Desktop.
Save eduardojmatos/60919ccdadd7cdf7d6a122fed6348075 to your computer and use it in GitHub Desktop.
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