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
Is FileParser safe? #54
Comments
Yep, I had considered that. It used FileParser to track Gatsby's early babel extraction because it doesn't tell me what the query is about. (After that, I don't use it at all) And I thought optimistic that it would be consistent with Gatsby's inner workings and probably stable while Gatsby is v1. I will gonna replace it with my own parser (that is regexp I already have in insert-type worker) in the next version and manage the test cases myself. |
I think I see where you're coming from. Since the state returned by Gatsby only includes components/queries that it will be using to fetch data from the GraphQL store, it doesn't include queries or fragments from plugins (or other places)... which would end up breaking some of the extra functionality you provide (like
very cool 👍 🚀 There may be some small issues, however. For example, Gatsby accepts static queries as a variable: const query = graphql`
query {
/* some query detail here */
}
`
export const Foo = () => {
const data = useStaticQuery(query);
} I assume you already have plans for those use cases, though, so I'll stop and let you do your (fantastic) work 🙂. I'll close this issue, since you've answered my question. Thanks! |
In my investigations while looking for a good way to let
gatsby-plugin-typgen
know about extra queries for parsing, I ran into an issue.I think it may not be safe to use
FileParser
. I was doing some testing to see what I could come up with without having to hook into Gatsby's internals, and I was using your processor. It took me a minute to realize that I was on Gatsby v2.17.11, whereFileParser
keeps the needed data under adefinitions
property... so I had to do this:Since
FileParser
is internal, there is not a requirement for it's API to remain stable. Which could result in additional maintenance in your plugin, to keep it in sync with Gatsby.Would it be safer to loop over
components
andstaticQueryComponents
from the state inonPostBootstrap
?components
contains page components, andstaticQueryComponents
contains the other components that have static queries, like the name suggests.I think those both have the data you need. The
componentPath
property has the physical file location, and thequery
property has the raw query data. Perhaps I am missing something, though.This would eliminate redundant file parsing, too, yeah?
The text was updated successfully, but these errors were encountered: