graphqlgatsbygatsby-plugin

How to find Graphql query datasource?


Disclaimer: I am pretty new to this technology.

I have a website built with Gatsby that uses different data sources. Is there a way to understand if a specific graphql query on a page comes from a specific plugin?


Solution

  • Gatsby sources it's data through underlying APIs that "Source Plugins" (https://www.gatsbyjs.com/docs/how-to/plugins-and-themes/creating-a-source-plugin/#what-is-a-source-plugin) use to populate Gatsby's data store. Those source plugins are most often npm packages that you can install, but you can also have a local source plugin in your gatsby-node.js. In the latter case you should read gatsby-node.js and see if it contains a sourceNodes export.

    So you'll want to check your gatsby-config.js what plugins are defined there. This array can either directly contain the individual plugins or it can contain themes (https://www.gatsbyjs.com/docs/themes/what-are-gatsby-themes/). Those themes itself will have a gatsby-config.js then.

    So with this knowledge you know which source plugins are active in your site. They often namespace their queries, so e.g. gatsby-source-contentful has the namespace allContentful. You can explore those queries at localhost:8000/___graphql when you have gatsby develop running.