Netflix / falcor

A JavaScript library for efficient data fetching
http://netflix.github.io/falcor
Apache License 2.0
10.48k stars 446 forks source link

Serverless usage #816

Closed bryanerayner closed 7 years ago

bryanerayner commented 7 years ago

Falcor is a sublime data access layer. Unfortunately, we won't be able to use it in our corporate project because we have a dot-net backend.

Is there any way to use Falcor without a back-end resource? If the REST API access code we currently use in our project, could be abstracted behind Falcor, it would provide benefits in the caching alone. It would be fantastic if a Falcor Router could be used in the client side browser code, then eventually migrated to the back end. While we wouldn't be able to realize all of the benefits, we would at least benefit from the in-memory cache and be able to cut a lot of cruft from our solution.

Is this a recommended use case?

trxcllnt commented 7 years ago

@bryanerayner you can absolutely run the Falcor client and Falcor router together on the client. It's a fun way to still interface with existing legacy services, while still doing things the Falcor-way in your app.

Unfortunately, the Netflix falcor-router in npm is still on RxJS4, which is slower than RxJS5, and will significantly reduce the snappiness of your app when routing requests. I updated the router to Rx5 almost a year ago and the performance problems away overnight. I can't say when that PR will get merged, but our @graphistry forks of the falcor projects have been updated, including an optimization that can improve the Falcor client cache search speed up to 300x for stable queries.

You can snag them on npm with the @graphistry prefix. Cheers.

tera-sinube commented 7 years ago

+1 to what @trxcllnt says

At Airtime, we're using a client based falcor-router to manage fetches to the REST API until we have time to migrate that router to the backend.

bryanerayner commented 7 years ago

@tera-sinube would you care to share any details about your implementation?

Wondering, would this be something that could be easily implemented in a service worker? Seems to me that might be the most appropriate way to implement a client side router. Are there any samples towards that end out there?

bryanerayner commented 7 years ago

@tera-sinube would you care to share any details about your implementation?

Wondering, would this be something that could be easily implemented in a service worker? Seems to me that might be the most appropriate way to implement a client side router. Are there any samples towards that end out there?

tera-sinube commented 7 years ago

@bryanerayner haven't tried the service worker, yet.

We're basically using a falcor-router as a source or (dataSource) for our falcor.Model instance.

If resources are not available in the model's local cache, it hits the dataSource which is really the router, from there we hit the REST API and return path/values once we have data.

The biggest issue we are running into is the way our REST API is designed (and most are this way): trying to serve all clients equally... we get back way too much information, or information is spread across different endpoints. Not a terrible situation. But in some cases we don't want to drop any of that extra info and have to re-request it at a later point. It'd be better to inject that into the falcor.Model cache so it is there when we eventually do want it.

steveorsomethin commented 7 years ago

I'm currently performing issue triage as we get ready to perform a proper release, and closing/tagging as I go.

Thanks for the good guidance here, and RxJS5 was indeed merged. Closing.