Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgs/f0108b63989026cb04c16c0aee581190 to your computer and use it in GitHub Desktop.
Save lgs/f0108b63989026cb04c16c0aee581190 to your computer and use it in GitHub Desktop.
const { setContext } = require('apollo-link-context');
const { HttpLink } = require('apollo-link-http');
const { introspectSchema, makeRemoteExecutableSchema } = require('graphql-tools');
const fetch = require('node-fetch');
module.exports = function(api) {
api.createSchema(async function(graphql) {
const http = new HttpLink({
uri: 'http://example.com/api',
fetch
});
const link = setContext((request, previousContext) => ({
headers: {
Authorization: `Bearer JSmxi5ocIhjKGENvgK66TrlqoylAPy8ZeAckiyo-4txKkYhdKSfLlPXLnxoghZm3`
}
})).concat(http);
const schema = await introspectSchema(link);
const executableSchema = await makeRemoteExecutableSchema({
schema: schema,
link
});
return executableSchema;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment