Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gatsby-source-graphql] How to download images from remote schema? #8404

Closed
tomsseisums opened this issue Sep 21, 2018 · 5 comments
Closed
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@tomsseisums
Copy link
Contributor

tomsseisums commented Sep 21, 2018

Summary

I am looking for a way to download images so that Sharp could take over, and have been following this issue to do so: #2902 (comment)

Apparently, onCreateNode doesn't give deep information when using gatsby-source-graphql, since only the "root" node is created. Also, the setFieldsOnGraphQLNodeType doesn't help.

The only relevant node being this:

onCreateNode
{ id: '0e63a2e0-c90e-55a2-995f-73b1a7959dd8',
  typeName: '<Project>',
  fieldName: '<project>',
  parent: null,
  children: [],
  internal:
   { type: 'GraphQLSource',
     contentDigest: 'f46f568173ddc3eb99427dad09a9c96d',
     ignoreType: true,
     owner: 'gatsby-source-graphql' } }

Where do I hook in to createRemoteFileNode?

Relevant information

Environment (if relevant)

  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.7.0 - /usr/local/bin/node
    Yarn: 1.9.2 - /usr/local/bin/yarn
    npm: 6.2.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 69.0.3497.100
    Safari: 12.0
  npmPackages:
    gatsby: ^2.0.6 => 2.0.6
    gatsby-plugin-emotion: ^2.0.5 => 2.0.5
    gatsby-plugin-manifest: ^2.0.2 => 2.0.2
    gatsby-plugin-offline: ^2.0.5 => 2.0.5
    gatsby-plugin-react-helmet: ^3.0.0 => 3.0.0
    gatsby-source-filesystem: ^2.0.1 => 2.0.1
    gatsby-source-graphql: ^2.0.2 => 2.0.2

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js:

exports.setFieldsOnGraphQLNodeType = ({ type }) => {
  console.log('setFieldsOnGraphQLNodeType')
  console.dir(type, { depth: null })
  return
}

exports.onCreateNode = ({ node, actions, createNodeId }) => {
  console.log('onCreateNode')
  console.dir(node, { depth: null })
  return
}

gatsby-browser.js: N/A
gatsby-ssr.js: N/A

@pieh pieh added type: question or discussion Issue discussing or asking a question about Gatsby and removed status: inkteam to review labels Sep 21, 2018
@pieh
Copy link
Contributor

pieh commented Sep 21, 2018

Currently it's not possible to mix 3rd party schemas with goodies like sharp transformation from gatsby - we get 3rd party schema as-is. We do have plans to work on that - see gatsbyjs/rfcs#11 and issues linked there

@pieh pieh closed this as completed Sep 21, 2018
@tomsseisums
Copy link
Contributor Author

Ouch, this hurts a lot. 😢

@gil--
Copy link
Contributor

gil-- commented Sep 26, 2018

Great to hear there's future plans to add support for mixing 3rd party schemas. Definitely seems like it's better to write a custom source if you need these sorts of integration in the meantime.

@osartun
Copy link
Contributor

osartun commented Nov 2, 2018

We have a CMS with a GraphQL endpoint. I was beyond happy to see that you could use the GraphQL endpoint directly with v2 instead of querying all data manually in gatsby-node and then requerying that data within the pages and components.
It's unfortunate to see that this way you can't use the transformer plugins. I'm gonna check out gatsbyjs/rfcs#11 and see if I can contribute to support plugins.

@samburgers
Copy link

Great solution here

@joltmode tears no more

https://dev.to/nevernull/gatsby-with-wpgraphql-acf-and-gatbsy-image-72m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants