Last active
November 27, 2020 20:11
-
-
Save jakedohm/860f2dadbf00f0d96c8f8d773c476351 to your computer and use it in GitHub Desktop.
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
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; | |
}); | |
}; |
I ended up removing all the package locks (yarn, npm, pnpm) and doing a fresh reinstall using yarn with these dependencies:
"@gridsome/source-graphql": "~0.1.0",
"graphql": "^14.0.0",
"gridsome": "^0.7.0",
Renaming Types and RootFields section of this article (https://medium.com/hasura/the-ultimate-guide-to-schema-stitching-in-graphql-543ebcb25d42) resolved my issue.
Note: I did not use @gridsome/source-graphql plugin because it has limitations and the graphql query wont work inside api.loadSource() in gridsome.server.js
Would you mind sharing what you did to make it work? I'm having problems following the article mentioned 😕
https://pastebin.com/uTwYZBeh
https://pastebin.com/t7JQPaPg
These are the two functions I created and called them from gridsome.server.config
I hope it helps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, I replied in the issue.