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-filesystem] iterate over specific directories and get files from it #3727

Closed
sandys opened this issue Jan 27, 2018 · 12 comments
Closed
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@sandys
Copy link
Contributor

sandys commented Jan 27, 2018

There are other people with similar issues - https://stackoverflow.com/questions/47313856/executing-graphql-queries-on-the-result-of-another-one

We need run one graphql for a specific list of directories and then on those directories, run another graphql query to get specific files within them. One of the issues is that pull request #2060 does not work. Allfile does not return directories. Second issue is that even if it did, how do i get the files inside it.

In general, one of the big usecases around gatsby is able to build logic around directory structure and use it to generate a static website. The biggest missing piece is being able to traverse directories in a seamless way. Today i can only get one level of either directories or files (and not even both simultaneously).

this will be a huge boost to building complex structures using gatsby

@calcsam
Copy link
Contributor

calcsam commented Jan 27, 2018

If you have a specific list of directories, why not include a filter on relativePath in your GraphQL query?

@sandys
Copy link
Contributor Author

sandys commented Jan 28, 2018 via email

@KyleAMathews
Copy link
Contributor

@sandys this would be a sweet addition to Gatsby! What would need to happen is that we add to the Directory type in gatsby-source-filesystem a allFiles field which is the same files connection as used elsewhere but automatically filters file nodes to files in that directory. Would love a PR for this!

@clearsensespw
Copy link

hey guys - do the devs have a plan to fix this ? im a new user of gatsbyjs, but am creating a structure where each folder has many subfolders and results in a page constructuted. This could include a bunch of images, yaml files, etc.
On gatsby build, these directories need to be inspected (as many as there are ) and pages created for it.

Would really really appreciate a better file+directory iteration mechanism that has decent integration with graphql. IMHO this has too many integration points for anyone other than core devs to touch it.

@vnwarrior
Copy link

hi guys - any chance for this to be fixed ?

We want to generate an internal jobs site with a list of jobs in the front page and each job has its own page. We want to do this in the simplest possible way by creating a bunch of subdirectories inside "/jobs" directory (which can be done by our HR team). As soon as they create a new directory (and put a description.md , photo.jpg files)... it gets compiled to show up on the front page.

Removing a job should be as easy as removing a folder.

We are not able to figure out how to do this in gatsbyjs graphql. Can someone help please ?

@KyleAMathews
Copy link
Contributor

@vnwarrior why don't you start working on a PR? Happy to help you through the process! Open source happens because someone needs some code so they write it and contribute it and it sounds like you have a great need for it.

@vnwarrior
Copy link

vnwarrior commented Apr 8, 2018

@adityapandey9 can i request you to put your code inside the <code> </code> formatting ?
it is not visible properly.

Also - it is not a constantly running build. remember, im trying to make it as simple for non coders to add/remove jobs. so the HR manager (who knows very little coding) has to create a new folder, put some markdown in it and that's it... a new job should come on next build.

does your code allow that ?

@sebastienfi sebastienfi changed the title add a way for gatsby-source-filesystem to iterate over specific directories and get files from it [gatsby-source-filesystem] iterate over specific directories and get files from it Apr 8, 2018
ptb pushed a commit to ptb/gatsby that referenced this issue Apr 12, 2018
ptb pushed a commit to ptb/gatsby that referenced this issue Apr 13, 2018
ptb pushed a commit to ptb/gatsby that referenced this issue Apr 13, 2018
ptb pushed a commit to ptb/gatsby that referenced this issue Apr 16, 2018
…#3727

Signed-off-by: Peter T Bosse II <ptb@ioutime.com>
ptb pushed a commit to ptb/gatsby that referenced this issue Apr 16, 2018
…#3727

Signed-off-by: Peter T Bosse II <ptb@ioutime.com>
ptb pushed a commit to ptb/gatsby that referenced this issue Apr 16, 2018
…#3727

Signed-off-by: Peter T Bosse II <ptb@ioutime.com>
@patrick-mcdougle
Copy link

I've been thinking about this and wondering why we don't use the parent / child relationship to handle this? Isn't this a textbook case for when to use parent / child? I think the issue is how to you switch allFile and allDirectory to a usage that has parent / child without breaking BC? Do you create a new node type (name TBD, perhaps fileResource? [suggestions appreciated]) such that all directories and files are duplicated in the datalayer or do you create new queries that abstract the fileResource into the allFile and allDirectory queries? 😕

The use case that I have is that I'd like to be able to have gatsby create a directory node and create a grid gallery component out of all of the images in that directory. This doesn't seem to be very possible right now, suggestions welcome.

I'd be willing to attempt a PR, but I'd want a couple of the details ironed out before I break ground.

@patrick-mcdougle
Copy link

patrick-mcdougle commented Aug 17, 2018

Believe it or not, there's some pseudo code here that might help: #3129 (comment)

@gatsbot
Copy link

gatsbot bot commented Dec 23, 2018

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 23, 2018
@gatsbot
Copy link

gatsbot bot commented Jan 3, 2019

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

@AAverin
Copy link

AAverin commented Jul 28, 2019

@KyleAMathews @ptb
Any plans to continue with this issue?
I build categories for my blog and have the need to get sub-directories of a given directory. Sounds like what you guys were working on could be the solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

8 participants