Last active
July 14, 2018 11:14
-
-
Save suciuvlad/b5bab2cc48c1c995bcfb0abed6c39622 to your computer and use it in GitHub Desktop.
graphql-microservices-example
This file contains hidden or 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 { introspectSchema, makeRemoteExecutableSchema, mergeSchemas } from 'graphql-tools'; | |
| import { createHttpLink } from 'apollo-link-http'; | |
| import fetch from 'node-fetch'; | |
| const createSchema = async () => { | |
| const movieServiceLink = createHttpLink({ | |
| uri: `https://w5vwzkn9zz.lp.gql.zone/graphql`, | |
| fetch | |
| }); | |
| const cosmicJsServiceLink = createHttpLink({ | |
| uri: `https://graphql.cosmicjs.com/v1`, | |
| fetch | |
| }); | |
| const createCosmicJsServiceSchema = async () => { | |
| const schema = await introspectSchema(cosmicJsServiceLink); | |
| return makeRemoteExecutableSchema({ | |
| schema, | |
| link: cosmicJsServiceLink | |
| }); | |
| } | |
| const createMovieServiceSchema = async () => { | |
| const schema = await introspectSchema(movieServiceLink); | |
| return makeRemoteExecutableSchema({ | |
| schema, | |
| link: movieServiceLink | |
| }); | |
| } | |
| const movieServiceSchema = await createMovieServiceSchema(); | |
| const cosmicJsServiceSchema = await createCosmicJsServiceSchema(); | |
| return mergeSchemas({ | |
| schemas: [movieServiceSchema, cosmicJsServiceSchema] | |
| }); | |
| } | |
| export const schema = createSchema(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment