Dynamic Routes with File System Route API via non-GraphQL data source #28115
-
This is a continuation of some back and forth around related to #25171 I am trying to better understand the new File System Route API and how to implement it in order to solve an issue we have with profile pages being created by a user but because a build has not occurred it ends up 404'ing if that person shared or accessed that URL immediately.
@LekoArts mentioned this in the above thread and after looking through the API docs I am not seeing how I would accomplish what I want to do without using a combination of Basically at build I make a GET request to our API to get all the profile objects and then call My question then becomes, since this is meant to replace the |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
I just spun up version After trying to access one of the pre-built html pages via its direct URL the routing is sending everything to my "fallback" component. As I stated before, I do not use GraphQL with our site and I don't see anywhere how one can create a bunch of pages during build similar to what This is a mission critical architecture problem for me to solve and any help would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
-
As the doc states quite early it expects you to have your data in our GraphQL data layer. Creating nodes with your data you get from your API is fairly easy with
As mentioned in the previous issue also before the Route API this wasn't necessary. The Route API is some syntax sugar that translates into the same underlying Node APIs, so it also only uses
You can certainly continue to use If you can provide a minimal reproduction of your setup I can look into it, maybe you're setting the matchPath incorrectly for example. Side note: My colleague explained the same concept here: https://twitter.com/gill_kyle/status/1329228307104034822 |
Beta Was this translation helpful? Give feedback.
-
@LekoArts Ok thanks for the in-depth explanation. I overlooked the
I have also configured Thanks! |
Beta Was this translation helpful? Give feedback.
-
@LekoArts So I just updated my
|
Beta Was this translation helpful? Give feedback.
-
@LekoArts So I just ran a test which consisted of a simple For both instances I have cleared out my with I can see that after serving the build when I access a route directly for a page that existed prior to build, I see the without Same preliminary steps as above however when I try to access a page that was created at build time, I see the console.log from the fallback component. The page still loads as it normally would however the browser is not being served the pre-rendered version. Let me know if this test is sufficient or if you would like anymore info! |
Beta Was this translation helpful? Give feedback.
As the doc states quite early it expects you to have your data in our GraphQL data layer. Creating nodes with your data you get from your API is fairly easy with
sourceNodes
: https://www.gatsbyjs.com/docs/creating-a-source-plugin/As mentioned in the previou…