-
Hi I have been trying to use I am sourcing the GitHub API like this: resolve: `gatsby-source-graphql`,
options: {
typeName: `GitHub`,
fieldName: `github`,
url: `https://api.github.com/graphql`,
headers: {
Authorization: `bearer ${process.env.GITHUB_TOKEN}`,
},
},
}, I want to transform
Do you guys have any tips/suggestions/ideas? I have tried some of these with no avail:
I think the main type of error I'm getting is from either a plugin or my own "gatsby-plugin-graphql-image" threw an error while running the createResolvers lifecycle:
Cannot find ObjectTypeComposer with name GitHub_RepositoryInfo
64 |
65 | if (Object.keys(resolvers).length) {
> 66 | createResolvers(resolvers);
| ^
67 | }
68 | }
File: node_modules/gatsby-plugin-graphql-image/gatsby-node.js:66:5 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You'll want to do something like shown here: https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#feeding-remote-images-into-gatsby-image gatsby-config.js: require("dotenv").config()
module.exports = {
siteMetadata: {
title: "discussion-30413",
},
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
path: "src",
},
},
{
resolve: "gatsby-source-graphql",
options: {
typeName: "GitHub",
fieldName: "github",
url: "https://api.github.com/graphql",
headers: {
Authorization: `bearer ${process.env.GITHUB_TOKEN}`
}
}
}
],
}; gatsby-node.js: const { createRemoteFileNode } = require("gatsby-source-filesystem")
exports.createResolvers = ({ actions, cache, createNodeId, createResolvers, store, reporter }) => {
const { createNode } = actions
createResolvers({
GitHub_User: {
avatarFile: {
type: "File",
resolve(source) {
return createRemoteFileNode({
url: source.avatarUrl,
store,
cache,
createNode,
createNodeId,
reporter
})
}
}
},
GitHub_Repository: {
openGraphImageFile: {
type: "File",
resolve(source) {
return createRemoteFileNode({
url: source.openGraphImageUrl,
store,
cache,
createNode,
createNodeId,
reporter
})
}
}
}
})
} |
Beta Was this translation helpful? Give feedback.
You'll want to do something like shown here: https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#feeding-remote-images-into-gatsby-image
gatsby-config.js:
gatsby-node.js:
c…