Replies: 4 comments
-
We don't have public APIs for this right now, because for the most part this is considered implementation detail to enable query result caching for now. Can you describe what kind of plugin are you working on? It might warrant public adding some public APIs |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response.
We are planning to work a plugin which would take in page data dependencies (for eg. if it is a blog post page, our plugin would access the blog post's content, category, tags, etc) for ever page of our website and send it to our backend. The backend will analyze the data (for eg. it would run it against our AI models) and send back some insights which would then be made available to the pages. Let me know if you need more information.
If there's not a public API, is there a way we could access it using some internal APIs for eg. if we get access to the store? The problem that I am facing while exploring this is that the page dependencies are computed at the end of the build lifecycle so I can't seem to find a way to access those dependencies in the early lifecycle methods. Is there something we could do to access it in early stages? |
Beta Was this translation helpful? Give feedback.
-
You can. gatsby/packages/gatsby-source-contentful/src/gatsby-node.js Lines 37 to 50 in d8ed76c
The data dependencies are populated as queries get executed (because it gets list of all linked nodes which are not known ahead of time, it's not just query "entry points" that with some effort could be figured out). The earliest you can make use of it is after query running step currently, which might be already too late for your use case (depending on how would you like to make those insights available to the page) |
Beta Was this translation helpful? Give feedback.
-
That makes sense. Although it's an internal project we still wouldn't want it to be that brittle so I agree with you that accessing the For eg. in a blog, we would have multiple blog posts pages sourced from Markdown files. Let's say we are not interested in specific field values excerpt, tags, category and we just want to know that this page with an Is that possible?
I tried a bunch of lifecycle methods to check for the |
Beta Was this translation helpful? Give feedback.
-
Summary
Is there a way to access page ---> node dependency in the node api file? Based on what I read in the documentation gatsby does track a dependency similar to that internally to know when to rebuild pages i.e when there is a change in the nodes used by a page only then rebuild that page.
Can we get access to that information as a plugin developer?
We are working on a plugin that will use that information (what nodes/data is being used by a page).
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions