persistgraphql icon indicating copy to clipboard operation
persistgraphql copied to clipboard

No .json file generated when crawling directory.

Open myyellowshoe opened this issue 7 years ago • 10 comments

I'm not getting a .json file pointing it to a directory, like so: $ persistgraphql client/src

When I point it to a file it seams to work fine. Am I missing something here?

Thanks for the all the amazing work contributed to the graphql community!

myyellowshoe avatar Jun 07 '17 19:06 myyellowshoe

I'm having the same problem, I'm crawling specifically using persistgraphql folder/ --js --extension=jsx, and if there is a single file inside one of those directories (different levels of nesting seem to trigger/not trigger it) that does not have a gql tag inside of it, the command makes a mention of this error:

(node:1383) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): 
TypeError: Reduce of empty array with no initial value
(node:1383) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In 
the future, promise rejections that are not handled will terminate the Node.js process with a non-
zero exit code.

Calling it on individual files and so on, including .jsx files works fine, if they contain a gql query. If not, I get the same error. I could probably cobble together some master map with disparate files, but I would really prefer to be able to simply run it over the whole project.

lemccarthy avatar Jun 28 '17 18:06 lemccarthy

Yeah agreed, I've thought of doing a similar thing, but running it over a whole folder structure would be far better.

myyellowshoe avatar Jun 29 '17 18:06 myyellowshoe

@Poincare Just a small bump for some thoughts on this when you get a quick min. Thanks so much! 👍

myyellowshoe avatar Jul 09 '17 20:07 myyellowshoe

@myyellowshoe @lemccarthy Sorry guys - this summer has been pretty busy but I'm back now. To clarify, the issue is that if there is a single file that doesn't contain a gql tag, then it fails because of an empty array being mishandled?

Poincare avatar Aug 19 '17 20:08 Poincare

Yes, I have many directories which contain gql tags, but also files that don't (dumb react view components), and the presence of even a single one without the tag causes the whole process to fail. If I set up a test directory with only tagged files, it succeeds.

On Sat, Aug 19, 2017 at 4:11 PM, Dhaivat Pandya [email protected] wrote:

@myyellowshoe https://github.com/myyellowshoe @lemccarthy https://github.com/lemccarthy Sorry guys - this summer has been pretty busy but I'm back now. To clarify, the issue is that if there is a single file that doesn't contain a gql tag, then it fails because of an empty array being mishandled?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apollographql/persistgraphql/issues/32#issuecomment-323545193, or mute the thread https://github.com/notifications/unsubscribe-auth/ATz215H94fsDEmPpLDloKraqsPtmwzhLks5sZ0FggaJpZM4NzKey .

lemccarthy avatar Sep 02 '17 00:09 lemccarthy

@Poincare All good! Really appreciate the work on this. Haven't tested myself without files that don't have gql tags, only got it to work with a single file.

myyellowshoe avatar Sep 07 '17 15:09 myyellowshoe

@Poincare I am using this library on a large project and the persistgraphql is failing only on some developers computers. I suspect it is the node version causing it. The error happens only with folders that do not contain a gql tag, and we get the same error as @lemccarthy . I noticed that there are no tests for if there are files that do not contain gql tags. If somebody could add one, this should be quick to fix. I will try to do it if I have time, but am not very familiar with the code base.

sepehr500 avatar Sep 21 '17 18:09 sepehr500

@Poincare I have pushed up a fix for the issue. @lemccarthy @myyellowshoe , feel free to try out my fix. It is a small amount of code, and I tried it out around the office by having people modify their node_module folder.

sepehr500 avatar Sep 22 '17 20:09 sepehr500

We should close this issue if nobody is having problems anymore.

sepehr500 avatar Oct 03 '17 15:10 sepehr500

We ran into this issue as well (same thing, only happened on a single developer's machine) and found it also occurs when there is an empty directory somewhere in the input path.

mdeltito avatar Nov 07 '18 20:11 mdeltito